+ 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;