X-Git-Url: http://review.tizen.org/git/?a=blobdiff_plain;f=dali%2Finternal%2Frender%2Frenderers%2Frender-renderer.h;h=6e1a1f7113ccfb3f4b8c972f502b33ff1f7be35c;hb=649ec06daecb510fb84fe4642a6af957f127e7ab;hp=2faf69b7e350209a11aa77dd208c239fca98a982;hpb=e317f59daa2ce5577e08c07f515d607a2dbc34e1;p=platform%2Fcore%2Fuifw%2Fdali-core.git diff --git a/dali/internal/render/renderers/render-renderer.h b/dali/internal/render/renderers/render-renderer.h index 2faf69b..6e1a1f7 100644 --- a/dali/internal/render/renderers/render-renderer.h +++ b/dali/internal/render/renderers/render-renderer.h @@ -1,8 +1,8 @@ -#ifndef __DALI_INTERNAL_RENDER_RENDERER_H__ -#define __DALI_INTERNAL_RENDER_RENDERER_H__ +#ifndef DALI_INTERNAL_RENDER_RENDERER_H +#define DALI_INTERNAL_RENDER_RENDERER_H /* - * Copyright (c) 2015 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. @@ -21,17 +21,16 @@ // INTERNAL INCLUDES #include #include -#include +#include #include #include -#include -#include -#include -#include #include -#include +#include #include +#include #include +#include +#include namespace Dali { @@ -46,14 +45,11 @@ namespace SceneGraph { class SceneController; class Shader; -class TextureCache; class NodeDataProvider; } - namespace Render { -class UniformNameCache; /** * Renderers are used to render meshes @@ -65,6 +61,35 @@ class Renderer : public GlResourceOwner public: /** + * @brief Struct to encapsulate stencil parameters required for control of the stencil buffer. + */ + struct StencilParameters + { + StencilParameters( RenderMode::Type renderMode, StencilFunction::Type stencilFunction, int stencilFunctionMask, + int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail, + StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass ) + : stencilFunctionMask ( stencilFunctionMask ), + stencilFunctionReference ( stencilFunctionReference ), + stencilMask ( stencilMask ), + renderMode ( renderMode ), + stencilFunction ( stencilFunction ), + stencilOperationOnFail ( stencilOperationOnFail ), + stencilOperationOnZFail ( stencilOperationOnZFail ), + stencilOperationOnZPass ( stencilOperationOnZPass ) + { + } + + int stencilFunctionMask; ///< The stencil function mask + int stencilFunctionReference; ///< The stencil function reference + int stencilMask; ///< The stencil mask + RenderMode::Type renderMode:3; ///< The render mode + StencilFunction::Type stencilFunction:3; ///< The stencil function + StencilOperation::Type stencilOperationOnFail:3; ///< The stencil operation for stencil test fail + StencilOperation::Type stencilOperationOnZFail:3; ///< The stencil operation for depth test fail + StencilOperation::Type stencilOperationOnZPass:3; ///< The stencil operation for depth test pass + }; + + /** * @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed() */ void GlContextDestroyed(); @@ -85,16 +110,18 @@ public: * @param[in] depthWriteMode Depth buffer write mode * @param[in] depthTestMode Depth buffer test mode * @param[in] depthFunction Depth function + * @param[in] stencilParameters Struct containing all stencil related options */ static Renderer* New( SceneGraph::RenderDataProvider* dataProviders, Render::Geometry* geometry, unsigned int blendingBitmask, - const Vector4* blendColor, + const Vector4& blendColor, FaceCullingMode::Type faceCullingMode, bool preMultipliedAlphaEnabled, DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction ); + DepthFunction::Type depthFunction, + StencilParameters& stencilParameters ); /** * Constructor. @@ -107,36 +134,31 @@ public: * @param[in] depthWriteMode Depth buffer write mode * @param[in] depthTestMode Depth buffer test mode * @param[in] depthFunction Depth function + * @param[in] stencilParameters Struct containing all stencil related options */ Renderer( SceneGraph::RenderDataProvider* dataProviders, Render::Geometry* geometry, unsigned int blendingBitmask, - const Vector4* blendColor, + const Vector4& blendColor, FaceCullingMode::Type faceCullingMode, bool preMultipliedAlphaEnabled, DepthWriteMode::Type depthWriteMode, DepthTestMode::Type depthTestMode, - DepthFunction::Type depthFunction ); - - /** - * Change the data providers of the renderer - * @param[in] dataProviders The data providers - */ - void SetRenderDataProvider( SceneGraph::RenderDataProvider* dataProviders ); + DepthFunction::Type depthFunction, + StencilParameters& stencilParameters ); /** * Change the geometry used by the renderer * @param[in] geometry The new geometry */ void SetGeometry( Render::Geometry* geometry ); + /** * Second-phase construction. * This is called when the renderer is inside render thread - * @param[in] context to use - * @param[in] textureCache to use - * @param[in] uniformNameCache to use + * @param[in] context Context used by the renderer */ - void Initialize( Context& context, SceneGraph::TextureCache& textureCache, Render::UniformNameCache& uniformNameCache ); + void Initialize( Context& context ); /** * Destructor @@ -159,7 +181,7 @@ public: * Set the blend color for blending options * @param[in] blendColor The blend color to pass to GL */ - void SetBlendColor( const Vector4* color ); + void SetBlendColor( const Vector4& color ); /** * Set the first element index to draw by the indexed draw @@ -217,27 +239,121 @@ public: DepthFunction::Type GetDepthFunction() const; /** + * Sets the render mode + * @param[in] renderMode The render mode + */ + void SetRenderMode( RenderMode::Type mode ); + + /** + * Gets the render mode + * @return The render mode + */ + RenderMode::Type GetRenderMode() const; + + /** + * Sets the stencil function + * @param[in] stencilFunction The stencil function + */ + void SetStencilFunction( StencilFunction::Type stencilFunction ); + + /** + * Gets the stencil function + * @return The stencil function + */ + StencilFunction::Type GetStencilFunction() const; + + /** + * Sets the stencil function mask + * @param[in] stencilFunctionMask The stencil function mask + */ + void SetStencilFunctionMask( int stencilFunctionMask ); + + /** + * Gets the stencil function mask + * @return The stencil function mask + */ + int GetStencilFunctionMask() const; + + /** + * Sets the stencil function reference + * @param[in] stencilFunctionReference The stencil function reference + */ + void SetStencilFunctionReference( int stencilFunctionReference ); + + /** + * Gets the stencil function reference + * @return The stencil function reference + */ + int GetStencilFunctionReference() const; + + /** + * Sets the stencil mask + * @param[in] stencilMask The stencil mask + */ + void SetStencilMask( int stencilMask ); + + /** + * Gets the stencil mask + * @return The stencil mask + */ + int GetStencilMask() const; + + /** + * Sets the stencil operation for when the stencil test fails + * @param[in] stencilOperationOnFail The stencil operation + */ + void SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail ); + + /** + * Gets the stencil operation for when the stencil test fails + * @return The stencil operation + */ + StencilOperation::Type GetStencilOperationOnFail() const; + + /** + * Sets the stencil operation for when the depth test fails + * @param[in] stencilOperationOnZFail The stencil operation + */ + void SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail ); + + /** + * Gets the stencil operation for when the depth test fails + * @return The stencil operation + */ + StencilOperation::Type GetStencilOperationOnZFail() const; + + /** + * Sets the stencil operation for when the depth test passes + * @param[in] stencilOperationOnZPass The stencil operation + */ + void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass ); + + /** + * Gets the stencil operation for when the depth test passes + * @return The stencil operation + */ + StencilOperation::Type GetStencilOperationOnZPass() const; + + /** * Called to render during RenderManager::Render(). * @param[in] context The context used for rendering - * @param[in] textureCache The texture cache used to get textures * @param[in] bufferIndex The index of the previous update buffer. * @param[in] node The node using this renderer - * @param[in] defaultShader in case there is no custom shader * @param[in] modelViewMatrix The model-view matrix. * @param[in] viewMatrix The view matrix. * @param[in] projectionMatrix The projection matrix. + * @param[in] size Size of the render item + * @param[in] blend If true, blending is enabled */ void Render( Context& context, - SceneGraph::TextureCache& textureCache, BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, - SceneGraph::Shader& defaultShader, const Matrix& modelMatrix, const Matrix& modelViewMatrix, const Matrix& viewMatrix, const Matrix& projectionMatrix, const Vector3& size, - bool blend); + bool blend ); /** * Write the renderer's sort attributes to the passed in reference @@ -245,7 +361,7 @@ public: * @param[in] bufferIndex The current update buffer index. * @param[out] sortAttributes */ - void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const; + void SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RenderInstructionProcessor::SortAttributes& sortAttributes ) const; private: @@ -284,44 +400,42 @@ private: /** * Bind the textures and setup the samplers * @param[in] context The GL context - * @param[in] textureCache The texture cache * @param[in] program The shader program * @return False if create or bind failed, true if success. */ - bool BindTextures( Context& context, SceneGraph::TextureCache& textureCache, Program& program ); + bool BindTextures( Context& context, Program& program ); private: OwnerPointer< SceneGraph::RenderDataProvider > mRenderDataProvider; - Context* mContext; - SceneGraph::TextureCache* mTextureCache; - Render::UniformNameCache* mUniformNameCache; - Render::Geometry* mGeometry; + Context* mContext; + Render::Geometry* mGeometry; struct UniformIndexMap { - unsigned int uniformIndex; // The index of the cached location in the Program - const PropertyInputImpl* propertyValue; + unsigned int uniformIndex; ///< The index of the cached location in the Program + const PropertyInputImpl* propertyValue; }; typedef Dali::Vector< UniformIndexMap > UniformIndexMappings; - UniformIndexMappings mUniformIndexMap; - Vector mAttributesLocation; + UniformIndexMappings mUniformIndexMap; + Vector mAttributesLocation; - BlendingOptions mBlendingOptions; /// Blending options including blend color, blend func and blend equation - FaceCullingMode::Type mFaceCullingMode; /// Mode of face culling - DepthFunction::Type mDepthFunction; /// Depth function + StencilParameters mStencilParameters; ///< Struct containing all stencil related options + BlendingOptions mBlendingOptions; ///< Blending options including blend color, blend func and blend equation - size_t mIndexedDrawFirstElement; /// Offset of first element to draw - size_t mIndexedDrawElementsCount; /// Number of elements to draw + size_t mIndexedDrawFirstElement; ///< Offset of first element to draw + size_t mIndexedDrawElementsCount; ///< Number of elements to draw - DepthWriteMode::Type mDepthWriteMode:2; /// Depth write mode - DepthTestMode::Type mDepthTestMode:2; /// Depth test mode + DepthFunction::Type mDepthFunction:3; ///< The depth function + FaceCullingMode::Type mFaceCullingMode:2; ///< The mode of face culling + DepthWriteMode::Type mDepthWriteMode:2; ///< The depth write mode + DepthTestMode::Type mDepthTestMode:2; ///< The depth test mode + bool mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed + bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required - bool mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed - bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required }; } // namespace SceneGraph @@ -330,4 +444,4 @@ private: } // namespace Dali -#endif // __DALI_INTERNAL_RENDER_RENDERER_H__ +#endif // DALI_INTERNAL_RENDER_RENDERER_H