+ mStencilParameters.stencilMode = stencilMode;
+}
+
+StencilMode::Type Renderer::GetStencilMode() const
+{
+ return mStencilParameters.stencilMode;
+}
+
+void Renderer::SetStencilFunction( StencilFunction::Type stencilFunction )
+{
+ mStencilParameters.stencilFunction = stencilFunction;
+}
+
+StencilFunction::Type Renderer::GetStencilFunction() const
+{
+ return mStencilParameters.stencilFunction;
+}
+
+void Renderer::SetStencilFunctionMask( int stencilFunctionMask )
+{
+ mStencilParameters.stencilFunctionMask = stencilFunctionMask;
+}
+
+int Renderer::GetStencilFunctionMask() const
+{
+ return mStencilParameters.stencilFunctionMask;
+}
+
+void Renderer::SetStencilFunctionReference( int stencilFunctionReference )
+{
+ mStencilParameters.stencilFunctionReference = stencilFunctionReference;
+}
+
+int Renderer::GetStencilFunctionReference() const
+{
+ return mStencilParameters.stencilFunctionReference;
+}
+
+void Renderer::SetStencilMask( int stencilMask )
+{
+ mStencilParameters.stencilMask = stencilMask;
+}
+
+int Renderer::GetStencilMask() const
+{
+ return mStencilParameters.stencilMask;
+}
+
+void Renderer::SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail )
+{
+ mStencilParameters.stencilOperationOnFail = stencilOperationOnFail;
+}
+
+StencilOperation::Type Renderer::GetStencilOperationOnFail() const
+{
+ return mStencilParameters.stencilOperationOnFail;
+}
+
+void Renderer::SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail )
+{
+ mStencilParameters.stencilOperationOnZFail = stencilOperationOnZFail;
+}
+
+StencilOperation::Type Renderer::GetStencilOperationOnZFail() const
+{
+ return mStencilParameters.stencilOperationOnZFail;
+}
+
+void Renderer::SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass )
+{
+ mStencilParameters.stencilOperationOnZPass = stencilOperationOnZPass;
+}
+
+StencilOperation::Type Renderer::GetStencilOperationOnZPass() const
+{
+ return mStencilParameters.stencilOperationOnZPass;
+}
+
+void Renderer::SetWriteToColorBuffer( bool writeToColorBuffer )
+{
+ mWriteToColorBuffer = writeToColorBuffer;
+}
+
+bool Renderer::GetWriteToColorBuffer() const
+{
+ return mWriteToColorBuffer;
+}
+
+void Renderer::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 )
+{
+ // Get the program to use:
+ Program* program = mRenderDataProvider->GetShader().GetProgram();
+ if( !program )
+ {
+ // if program is NULL it means this is a custom shader with non matching geometry type so we need to use default shaders program
+ program = defaultShader.GetProgram();
+ DALI_ASSERT_DEBUG( program && "Default shader should always have a program available." );
+ if( !program )
+ {
+ DALI_LOG_ERROR( "Failed to get program for shader at address %p.", (void*)&mRenderDataProvider->GetShader() );
+ return;
+ }
+ }
+
+ //Set cull face mode
+ context.CullFace( mFaceCullingMode );
+
+ //Set blending mode
+ SetBlending( context, blend );
+
+ // Take the program into use so we can send uniforms to it
+ program->Use();
+
+ if( DALI_LIKELY( BindTextures( context, textureCache, *program ) ) )
+ {
+ // Only set up and draw if we have textures and they are all valid
+
+ // set projection and view matrix if program has not yet received them yet this frame
+ SetMatrices( *program, modelMatrix, viewMatrix, projectionMatrix, modelViewMatrix );
+
+ // set color uniform
+ GLint loc = program->GetUniformLocation( Program::UNIFORM_COLOR );
+ if( Program::UNIFORM_UNKNOWN != loc )
+ {
+ const Vector4& color = node.GetRenderColor( bufferIndex );
+ if( mPremultipledAlphaEnabled )
+ {
+ program->SetUniform4f( loc, color.r*color.a, color.g*color.a, color.b*color.a, color.a );
+ }
+ else
+ {
+ program->SetUniform4f( loc, color.r, color.g, color.b, color.a );
+ }
+ }
+
+ SetUniforms( bufferIndex, node, size, *program );
+
+ if( mUpdateAttributesLocation || mGeometry->AttributesChanged() )
+ {
+ mGeometry->GetAttributeLocationFromProgram( mAttributesLocation, *program, bufferIndex );
+ mUpdateAttributesLocation = false;
+ }
+
+ mGeometry->UploadAndDraw( context, bufferIndex, mAttributesLocation, mIndexedDrawFirstElement, mIndexedDrawElementsCount );
+ }
+}
+
+void Renderer::SetSortAttributes( BufferIndex bufferIndex, SceneGraph::RendererWithSortAttributes& sortAttributes ) const
+{
+ sortAttributes.shader = &( mRenderDataProvider->GetShader() );
+ const std::vector<Render::Texture>& textures( mRenderDataProvider->GetTextures() );
+ if( !textures.empty() )
+ {
+ sortAttributes.textureResourceId = textures[0].GetTextureId();
+ }
+ else
+ {
+ sortAttributes.textureResourceId = Integration::InvalidResourceId;
+ }
+
+ sortAttributes.geometry = mGeometry;