X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Fupdate%2Frendering%2Fscene-graph-renderer.h;h=f1ef2a729a9cc88d88db203ac1c2d19f54949afc;hb=0643c768fd100bd7ffb522e3358b88d075bc1d2e;hp=34d3606b012f1f86cf7f29365a0ecd4605dc52dd;hpb=719bb2f6939effe2a07155544667789553105518;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/update/rendering/scene-graph-renderer.h b/dali/internal/update/rendering/scene-graph-renderer.h index 34d3606..f1ef2a7 100644 --- a/dali/internal/update/rendering/scene-graph-renderer.h +++ b/dali/internal/update/rendering/scene-graph-renderer.h @@ -1,8 +1,8 @@ -#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDERER2_H -#define DALI_INTERNAL_SCENE_GRAPH_RENDERER2_H +#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDERER_H +#define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H /* - * Copyright (c) 2016 Samsung Electronics Co., Ltd. + * Copyright (c) 2018 Samsung Electronics Co., Ltd. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -17,19 +17,21 @@ * limitations under the License. */ - -#include -#include // Dali::Renderer +#include +#include // Dali::Renderer #include #include #include #include #include #include +#include #include +#include namespace Dali { + namespace Internal { @@ -58,7 +60,7 @@ class Renderer : public PropertyOwner, { public: - enum Opacity + enum OpacityType { OPAQUE, TRANSPARENT, @@ -87,6 +89,14 @@ public: */ void SetTextures( TextureSet* textureSet ); + /** + * Returns current texture set object + * @return Pointer to the texture set + */ + const TextureSet* GetTextures() const + { + return mTextureSet; + } /** * Set the shader for the renderer @@ -98,7 +108,7 @@ public: * Get the shader used by this renderer * @return the shader this renderer uses */ - Shader& GetShader() + const Shader& GetShader() const { return *mShader; } @@ -131,63 +141,186 @@ public: void SetFaceCullingMode( FaceCullingMode::Type faceCullingMode ); /** + * Get face culling mode + * @return The face culling mode + */ + FaceCullingMode::Type GetFaceCullingMode() const; + + /** * Set the blending mode * @param[in] blendingMode to use */ void SetBlendMode( BlendMode::Type blendingMode ); /** + * Get the blending mode + * @return The the blending mode + */ + BlendMode::Type GetBlendMode() const; + + /** * Set the blending options. This should only be called from the update thread. * @param[in] options A bitmask of blending options. */ void SetBlendingOptions( unsigned int options ); /** + * Get the blending options + * @return The the blending mode + */ + unsigned int GetBlendingOptions() const; + + /** * Set the blend color for blending operation * @param blendColor to pass to GL */ void SetBlendColor( const Vector4& blendColor ); /** + * Get the blending color + * @return The blend color + */ + Vector4 GetBlendColor() const; + + /** * Set the index of first element for indexed draw * @param[in] firstElement index of first element to draw */ void SetIndexedDrawFirstElement( size_t firstElement ); /** + * Get the index of first element for indexed draw + * @return The index of first element for indexed draw + */ + size_t GetIndexedDrawFirstElement() const; + + /** * Set the number of elements to draw by indexed draw * @param[in] elementsCount number of elements to draw */ void SetIndexedDrawElementsCount( size_t elementsCount ); /** + * Get the number of elements to draw by indexed draw + * @return The number of elements to draw by indexed draw + */ + size_t GetIndexedDrawElementsCount() const; + + /** * @brief Set whether the Pre-multiplied Alpha Blending is required - * * @param[in] preMultipled whether alpha is pre-multiplied. */ void EnablePreMultipliedAlpha( bool preMultipled ); /** + * @brief Query whether alpha is pre-multiplied. + * @return True is alpha is pre-multiplied, false otherwise. + */ + bool IsPreMultipliedAlphaEnabled() const; + + /** * Sets the depth buffer write mode * @param[in] depthWriteMode The depth buffer write mode */ void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode ); /** + * Get the depth buffer write mode + * @return The depth buffer write mode + */ + DepthWriteMode::Type GetDepthWriteMode() const; + + /** + * Sets the depth buffer test mode + * @param[in] depthTestMode The depth buffer test mode + */ + void SetDepthTestMode( DepthTestMode::Type depthTestMode ); + + /** + * Get the depth buffer test mode + * @return The depth buffer test mode + */ + DepthTestMode::Type GetDepthTestMode() const; + + /** * Sets the depth function * @param[in] depthFunction The depth function */ void SetDepthFunction( DepthFunction::Type depthFunction ); /** - * Called when an actor with this renderer is added to the stage + * Get the depth function + * @return The depth function */ - void OnStageConnect(); + DepthFunction::Type GetDepthFunction() const; - /* - * Called when an actor with this renderer is removed from the stage + /** + * Sets the render mode + * @param[in] mode The render mode + */ + void SetRenderMode( RenderMode::Type mode ); + + /** + * Sets the stencil function + * @param[in] stencilFunction The stencil function + */ + void SetStencilFunction( StencilFunction::Type stencilFunction ); + + /** + * Sets the stencil function mask + * @param[in] stencilFunctionMask The stencil function mask + */ + void SetStencilFunctionMask( int stencilFunctionMask ); + + /** + * Sets the stencil function reference + * @param[in] stencilFunctionReference The stencil function reference + */ + void SetStencilFunctionReference( int stencilFunctionReference ); + + /** + * Sets the stencil mask + * @param[in] stencilMask The stencil mask + */ + void SetStencilMask( int stencilMask ); + + /** + * Sets the stencil operation for when the stencil test fails + * @param[in] stencilOperationOnFail The stencil operation + */ + void SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail ); + + /** + * Sets the stencil operation for when the depth test fails + * @param[in] stencilOperationOnZFail The stencil operation + */ + void SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail ); + + /** + * Sets the stencil operation for when the depth test passes + * @param[in] stencilOperationOnZPass The stencil operation + */ + void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass ); + + /** + * Gets the stencil parameters + * @return The stencil parameters + */ + const Render::Renderer::StencilParameters& GetStencilParameters() const; + + /** + * Bakes the opacity + * @param[in] updateBufferIndex The current update buffer index. + * @param[in] opacity The opacity + */ + void BakeOpacity( BufferIndex updateBufferIndex, float opacity ); + + /** + * Gets the opacity + * @param[in] bufferIndex The buffer to read from. + * @return The opacity */ - void OnStageDisconnect(); + float GetOpacity( BufferIndex updateBufferIndex ) const; /** * Prepare the object for rendering. @@ -196,44 +329,29 @@ public: */ void PrepareRender( BufferIndex updateBufferIndex ); - /* + /** * Retrieve the Render thread renderer * @return The associated render thread renderer */ Render::Renderer& GetRenderer(); /** - * Check whether the renderer has been marked as ready to render - * ready means that renderer has all resources and should produce correct result - * complete means all resources have finished loading - * It's possible that renderer is complete but not ready, - * for example in case of resource load failed - * @param[out] ready TRUE if the renderer has resources to render - * @param[out] complete TRUE if the renderer resources are complete - */ - void GetReadyAndComplete( bool& ready, bool& complete ) const; - - /** * Query whether the renderer is fully opaque, fully transparent or transparent. * @param[in] updateBufferIndex The current update buffer index. * @return OPAQUE if fully opaque, TRANSPARENT if fully transparent and TRANSLUCENT if in between */ - Opacity GetOpacity( BufferIndex updateBufferIndex, const Node& node ) const; + OpacityType GetOpacityType( BufferIndex updateBufferIndex, const Node& node ) const; /** - * Query whether the renderer is currently in use by an actor on the stage + * Called by the TextureSet to notify to the renderer that it has changed */ - bool IsReferenced() const - { - return mReferenceCount > 0; - } + void TextureSetChanged(); /** - * Called by the TextureSet to notify to the renderer that it has changed + * Called by the TextureSet to notify to the renderer that it is about to be deleted */ - void TextureSetChanged(); + void TextureSetDeleted(); -public: // Implementation of ObjectOwnerContainer template methods /** * Connect the object to the scene graph * @@ -260,9 +378,6 @@ public: // Implementation of ConnectionChangePropagator */ void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer){}; -public: - - public: // UniformMap::Observer /** * @copydoc UniformMap::Observer::UniformMappingsChanged @@ -312,41 +427,44 @@ private: Renderer(); /** - * Helper function to create a new render data provider - * @return the new (initialized) data provider + * Update texture set to the render data provider */ - RenderDataProvider* NewRenderDataProvider(); + void UpdateTextureSet(); private: - SceneController* mSceneController; ///< Used for initializing renderers - Render::Renderer* mRenderer; ///< Raw pointer to the renderer (that's owned by RenderManager) - TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned) - Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned) - Shader* mShader; + CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer + + SceneController* mSceneController; ///< Used for initializing renderers + Render::Renderer* mRenderer; ///< Raw pointer to the renderer (that's owned by RenderManager) + TextureSet* mTextureSet; ///< The texture set this renderer uses. (Not owned) + Render::Geometry* mGeometry; ///< The geometry this renderer uses. (Not owned) + Shader* mShader; ///< The shader this renderer uses. (Not owned) + RenderDataProvider* mRenderDataProvider; ///< The render data provider + OwnerPointer< Vector4 > mBlendColor; ///< The blend color for blending operation - Vector4* mBlendColor; ///< The blend color for blending operation - unsigned int mBlendBitmask; ///< The bitmask of blending options - FaceCullingMode::Type mFaceCullingMode; ///< The mode of face culling - BlendMode::Type mBlendMode; ///< The mode of blending - DepthWriteMode::Type mDepthWriteMode; ///< The depth write mode - DepthFunction::Type mDepthFunction; ///< The depth function + Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options - CollectedUniformMap mCollectedUniformMap[2]; ///< Uniform maps collected by the renderer + size_t mIndexedDrawFirstElement; ///< first element index to be drawn using indexed draw + size_t mIndexedDrawElementsCount; ///< number of elements to be drawn using indexed draw + unsigned int mBlendBitmask; ///< The bitmask of blending options + unsigned int mRegenerateUniformMap; ///< 2 if the map should be regenerated, 1 if it should be copied. + unsigned int mResendFlag; ///< Indicate whether data should be resent to the renderer - size_t mIndexedDrawFirstElement; ///< first element index to be drawn using indexed draw - size_t mIndexedDrawElementsCount; ///< number of elements to be drawn using indexed draw - unsigned int mReferenceCount; ///< Number of nodes currently using this renderer - unsigned int mRegenerateUniformMap; ///< 2 if the map should be regenerated, 1 if it should be copied. - unsigned short mResendFlag; ///< Indicate whether data should be resent to the renderer - bool mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame - bool mResourcesReady; ///< Set during the Update algorithm; true if the renderer has resources ready for the current frame. - bool mFinishedResourceAcquisition; ///< Set during DoPrepareResources; true if ready & all resource acquisition has finished (successfully or otherwise) - bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required + DepthFunction::Type mDepthFunction:3; ///< Local copy of the depth function + FaceCullingMode::Type mFaceCullingMode:2; ///< Local copy of the mode of face culling + BlendMode::Type mBlendMode:2; ///< Local copy of the mode of blending + DepthWriteMode::Type mDepthWriteMode:2; ///< Local copy of the depth write mode + DepthTestMode::Type mDepthTestMode:2; ///< Local copy of the depth test mode + bool mUniformMapChanged[2]; ///< Records if the uniform map has been altered this frame + bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required public: - int mDepthIndex; ///< Used only in PrepareRenderInstructions + + AnimatableProperty< float > mOpacity; ///< The opacity value + int mDepthIndex; ///< Used only in PrepareRenderInstructions + }; @@ -475,6 +593,16 @@ inline void SetDepthWriteModeMessage( EventThreadServices& eventThreadServices, new (slot) LocalType( &renderer, &Renderer::SetDepthWriteMode, depthWriteMode ); } +inline void SetDepthTestModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode ) +{ + typedef MessageValue1< Renderer, DepthTestMode::Type > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::SetDepthTestMode, depthTestMode ); +} + inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction ) { typedef MessageValue1< Renderer, DepthFunction::Type > LocalType; @@ -485,26 +613,94 @@ inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, c new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction ); } -inline void OnStageConnectMessage( EventThreadServices& eventThreadServices, const Renderer& renderer ) +inline void SetRenderModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode ) { - typedef Message< Renderer > LocalType; + typedef MessageValue1< Renderer, RenderMode::Type > LocalType; // Reserve some memory inside the message queue unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &renderer, &Renderer::OnStageConnect ); + new (slot) LocalType( &renderer, &Renderer::SetRenderMode, mode ); } -inline void OnStageDisconnectMessage( EventThreadServices& eventThreadServices, const Renderer& renderer ) +inline void SetStencilFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction ) { - typedef Message< Renderer > LocalType; + typedef MessageValue1< Renderer, StencilFunction::Type > LocalType; // Reserve some memory inside the message queue unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); - // Construct message in the message queue memory; note that delete should not be called on the return value - new (slot) LocalType( &renderer, &Renderer::OnStageDisconnect ); + new (slot) LocalType( &renderer, &Renderer::SetStencilFunction, stencilFunction ); +} + +inline void SetStencilFunctionMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int mask ) +{ + typedef MessageValue1< Renderer, int > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionMask, mask ); +} + +inline void SetStencilFunctionReferenceMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference ) +{ + typedef MessageValue1< Renderer, int > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference ); +} + +inline void SetStencilMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask ) +{ + typedef MessageValue1< Renderer, int > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::SetStencilMask, stencilMask ); +} + +inline void SetStencilOperationOnFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation ) +{ + typedef MessageValue1< Renderer, StencilOperation::Type > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnFail, stencilOperation ); +} + +inline void SetStencilOperationOnZFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation ) +{ + typedef MessageValue1< Renderer, StencilOperation::Type > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation ); +} + +inline void SetStencilOperationOnZPassMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation ) +{ + typedef MessageValue1< Renderer, StencilOperation::Type > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation ); +} + +inline void BakeOpacityMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity ) +{ + typedef MessageDoubleBuffered1< Renderer, float > LocalType; + + // Reserve some memory inside the message queue + unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) ); + + new (slot) LocalType( &renderer, &Renderer::BakeOpacity, opacity ); } } // namespace SceneGraph