-#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) 2016 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.
// INTERNAL INCLUDES
#include <dali/public-api/math/matrix.h>
#include <dali/public-api/math/vector4.h>
-#include <dali/devel-api/rendering/texture-set.h>
+#include <dali/public-api/rendering/texture-set.h>
#include <dali/internal/common/blending-options.h>
#include <dali/internal/common/message.h>
+#include <dali/internal/common/type-abstraction-enums.h>
+#include <dali/internal/event/common/property-input-impl.h>
#include <dali/internal/event/effects/shader-declarations.h>
+#include <dali/internal/render/data-providers/render-data-provider.h>
#include <dali/internal/render/gl-resources/gl-resource-owner.h>
-#include <dali/integration-api/debug.h>
-#include <dali/internal/common/type-abstraction-enums.h>
-#include <dali/internal/update/manager/prepare-render-instructions.h>
#include <dali/internal/render/renderers/render-geometry.h>
+#include <dali/internal/update/manager/prepare-render-instructions.h>
+#include <dali/integration-api/debug.h>
namespace Dali
{
namespace Render
{
-class UniformNameCache;
/**
* Renderers are used to render meshes
public:
/**
+ * @brief Struct to encapsulate stencil parameters required for control of the stencil buffer.
+ */
+ struct StencilParameters
+ {
+ StencilParameters( StencilMode::Type stencilMode, StencilFunction::Type stencilFunction, int stencilFunctionMask,
+ int stencilFunctionReference, int stencilMask, StencilOperation::Type stencilOperationOnFail,
+ StencilOperation::Type stencilOperationOnZFail, StencilOperation::Type stencilOperationOnZPass )
+ : stencilFunctionMask ( stencilFunctionMask ),
+ stencilFunctionReference ( stencilFunctionReference ),
+ stencilMask ( stencilMask ),
+ stencilFunction ( stencilFunction ),
+ stencilOperationOnFail ( stencilOperationOnFail ),
+ stencilOperationOnZFail ( stencilOperationOnZFail ),
+ stencilOperationOnZPass ( stencilOperationOnZPass ),
+ stencilMode ( stencilMode )
+ {
+ }
+
+ int stencilFunctionMask; ///< The stencil function mask
+ int stencilFunctionReference; ///< The stencil function reference
+ int stencilMask; ///< The stencil mask
+ 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
+ StencilMode::Type stencilMode:2; ///< The stencil mode
+ };
+
+ /**
* @copydoc Dali::Internal::GlResourceOwner::GlContextDestroyed()
*/
void GlContextDestroyed();
/**
* Create a new renderer instance
* @param[in] dataProviders The data providers for the renderer
- * @param[in] renderGeometry The geometry for the renderer
+ * @param[in] geometry The geometry for the renderer
* @param[in] blendingBitmask A bitmask of blending options.
* @param[in] blendColor The blend color to pass to GL
* @param[in] faceCullingMode The face-culling mode.
* @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied.
+ * @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
+ * @param[in] writeToColorBuffer Set to True to write to the color buffer
*/
static Renderer* New( SceneGraph::RenderDataProvider* dataProviders,
- SceneGraph::RenderGeometry* renderGeometry,
+ Render::Geometry* geometry,
unsigned int blendingBitmask,
const Vector4* blendColor,
- Dali::Renderer::FaceCullingMode faceCullingMode,
- bool preMultipliedAlphaEnabled);
+ FaceCullingMode::Type faceCullingMode,
+ bool preMultipliedAlphaEnabled,
+ DepthWriteMode::Type depthWriteMode,
+ DepthTestMode::Type depthTestMode,
+ DepthFunction::Type depthFunction,
+ StencilParameters& stencilParameters,
+ bool writeToColorBuffer );
/**
* Constructor.
* @param[in] dataProviders The data providers for the renderer
- * @param[in] renderGeometry The geometry for the renderer
+ * @param[in] geometry The geometry for the renderer
* @param[in] blendingBitmask A bitmask of blending options.
* @param[in] blendColor The blend color to pass to GL
* @param[in] faceCullingMode The face-culling mode.
* @param[in] preMultipliedAlphaEnabled whether alpha is pre-multiplied.
+ * @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
+ * @param[in] writeToColorBuffer Set to True to write to the color buffer
*/
Renderer( SceneGraph::RenderDataProvider* dataProviders,
- SceneGraph::RenderGeometry* renderGeometry,
+ Render::Geometry* geometry,
unsigned int blendingBitmask,
const Vector4* blendColor,
- Dali::Renderer::FaceCullingMode faceCullingMode,
- bool preMultipliedAlphaEnabled);
+ FaceCullingMode::Type faceCullingMode,
+ bool preMultipliedAlphaEnabled,
+ DepthWriteMode::Type depthWriteMode,
+ DepthTestMode::Type depthTestMode,
+ DepthFunction::Type depthFunction,
+ StencilParameters& stencilParameters,
+ bool writeToColorBuffer );
/**
* Change the data providers of the renderer
/**
* Change the geometry used by the renderer
- * @param[in] renderGeometry The new geometry
+ * @param[in] geometry The new geometry
*/
- void SetGeometry( SceneGraph::RenderGeometry* renderGeometry );
+ 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
+ * @param[in] textureCache The texture cache to use
*/
- void Initialize( Context& context, SceneGraph::TextureCache& textureCache, Render::UniformNameCache& uniformNameCache );
+ void Initialize( Context& context, SceneGraph::TextureCache& textureCache );
/**
* Destructor
* Set the face-culling mode.
* @param[in] mode The face-culling mode.
*/
- void SetFaceCullingMode( Dali::Renderer::FaceCullingMode mode );
+ void SetFaceCullingMode( FaceCullingMode::Type mode );
/**
* Set the bitmask for blending options
void EnablePreMultipliedAlpha( bool preMultipled );
/**
- * Set the sampler used to render the set texture.
- * @param[in] samplerBitfield The packed sampler options used to render.
+ * Sets the depth write mode
+ * @param[in] depthWriteMode The depth write mode
+ */
+ void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
+
+ /**
+ * Query the Renderer's depth write mode
+ * @return The renderer depth write mode
+ */
+ DepthWriteMode::Type GetDepthWriteMode() const;
+
+ /**
+ * Sets the depth test mode
+ * @param[in] depthTestMode The depth test mode
+ */
+ void SetDepthTestMode( DepthTestMode::Type depthTestMode );
+
+ /**
+ * Query the Renderer's depth test mode
+ * @return The renderer depth test mode
+ */
+ DepthTestMode::Type GetDepthTestMode() const;
+
+ /**
+ * Sets the depth function
+ * @param[in] depthFunction The depth function
+ */
+ void SetDepthFunction( DepthFunction::Type depthFunction );
+
+ /**
+ * Query the Renderer's depth function
+ * @return The renderer depth function
+ */
+ DepthFunction::Type GetDepthFunction() const;
+
+ /**
+ * Sets the stencil mode
+ * @param[in] stencilMode The stencil function
+ */
+ void SetStencilMode( StencilMode::Type stencilMode );
+
+ /**
+ * Gets the stencil mode
+ * @return The stencil function
+ */
+ StencilMode::Type GetStencilMode() 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
*/
- void SetSampler( unsigned int samplerBitfield );
+ int GetStencilFunctionMask() const;
/**
- * Query whether the derived type of Renderer requires depth testing.
- * @return True if the renderer requires depth testing.
+ * Sets the stencil function reference
+ * @param[in] stencilFunctionReference The stencil function reference
*/
- bool RequiresDepthTest() const;
+ 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;
+
+ /**
+ * Sets whether or not to write to the color buffer
+ * @param[in] writeToColorBuffer True to write to the color buffer
+ */
+ void SetWriteToColorBuffer( bool writeToColorBuffer );
+
+ /**
+ * Gets whether or not to write to the color buffer
+ * @return True to write to the color buffer
+ */
+ bool GetWriteToColorBuffer() const;
/**
* Called to render during RenderManager::Render().
BufferIndex bufferIndex,
const SceneGraph::NodeDataProvider& node,
SceneGraph::Shader& defaultShader,
+ const Matrix& modelMatrix,
const Matrix& modelViewMatrix,
const Matrix& viewMatrix,
const Matrix& projectionMatrix,
/**
* Set the program uniform in the map from the mapped property
+ * @param[in] bufferIndex The index of the previous update buffer.
+ * @param[in] program The shader program
+ * @param[in] map The uniform
*/
void SetUniformFromProperty( BufferIndex bufferIndex, Program& program, UniformIndexMap& map );
/**
* 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( SceneGraph::TextureCache& textureCache, Program& program );
+ bool BindTextures( Context& context, SceneGraph::TextureCache& textureCache, Program& program );
-public:
+private:
OwnerPointer< SceneGraph::RenderDataProvider > mRenderDataProvider;
-private:
-
- Context* mContext;
- SceneGraph::TextureCache* mTextureCache;
- Render::UniformNameCache* mUniformNameCache;
- SceneGraph::RenderGeometry* mRenderGeometry;
+ Context* mContext;
+ SceneGraph::TextureCache* mTextureCache;
+ 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<GLint> mAttributesLocation;
-
- BlendingOptions mBlendingOptions; /// Blending options including blend color, blend func and blend equation
- Dali::Renderer::FaceCullingMode mFaceCullingMode; /// Mode of face culling
-
- size_t mIndexedDrawFirstElement; /// Offset of first element to draw
- size_t mIndexedDrawElementsCount; /// Number of elements to draw
-
- unsigned int mSamplerBitfield; ///< Sampler options used for texture filtering
- bool mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed
- bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
+ UniformIndexMappings mUniformIndexMap;
+ Vector<GLint> mAttributesLocation;
+
+ 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
+
+ DepthFunction::Type mDepthFunction:3; ///< The depth function
+ FaceCullingMode::Type mFaceCullingMode:2; ///< The mode of face culling
+ BlendMode::Type mBlendMode:2; ///< The mode of blending
+ DepthWriteMode::Type mDepthWriteMode:2; ///< The depth write mode
+ DepthTestMode::Type mDepthTestMode:2; ///< The depth test mode
+ bool mWriteToColorBuffer:1; ///< True if we are writing to the color buffer
+ bool mUpdateAttributesLocation:1; ///< Indicates attribute locations have changed
+ bool mPremultipledAlphaEnabled:1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
};
} // namespace SceneGraph
} // namespace Dali
-#endif // __DALI_INTERNAL_RENDER_RENDERER_H__
+#endif // DALI_INTERNAL_RENDER_RENDERER_H