- context.SetBlend( blend );
- if( blend )
- {
- // Blend color is optional and rarely used
- const Vector4* blendColor = mBlendingOptions.GetBlendColor();
- if( blendColor )
- {
- context.SetCustomBlendColor( *blendColor );
- }
- else
- {
- context.SetDefaultBlendColor();
- }
-
- // Set blend source & destination factors
- context.BlendFuncSeparate( mBlendingOptions.GetBlendSrcFactorRgb(),
- mBlendingOptions.GetBlendDestFactorRgb(),
- mBlendingOptions.GetBlendSrcFactorAlpha(),
- mBlendingOptions.GetBlendDestFactorAlpha() );
-
- // Set blend equations
- Dali::DevelBlendEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
- Dali::DevelBlendEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
-
- if( mBlendingOptions.IsAdvancedBlendEquationApplied() && mPremultipledAlphaEnabled )
- {
- if( rgbEquation != alphaEquation )
- {
- DALI_LOG_ERROR( "Advanced Blend Equation have to be appried by using BlendEquation.\n" );
- }
- context.BlendEquation( rgbEquation );
- }
- else
- {
- context.BlendEquationSeparate( rgbEquation, alphaEquation );
- }
- }
-
- mUpdated = true;
-}
-
-void Renderer::GlContextDestroyed()
-{
- mGeometry->GlContextDestroyed();
-}
-
-void Renderer::GlCleanup()
-{
-}
-
-void Renderer::SetUniforms( BufferIndex bufferIndex, const SceneGraph::NodeDataProvider& node, const Vector3& size, Program& program )
-{
- // Check if the map has changed
- DALI_ASSERT_DEBUG( mRenderDataProvider && "No Uniform map data provider available" );
-
- const SceneGraph::UniformMapDataProvider& uniformMapDataProvider = mRenderDataProvider->GetUniformMap();
-
- if( uniformMapDataProvider.GetUniformMapChanged( bufferIndex ) ||
- node.GetUniformMapChanged(bufferIndex) ||
- mUniformIndexMap.Count() == 0 ||
- mShaderChanged )
- {
- // Reset shader pointer
- mShaderChanged = false;
-
- const SceneGraph::CollectedUniformMap& uniformMap = uniformMapDataProvider.GetUniformMap( bufferIndex );
- const SceneGraph::CollectedUniformMap& uniformMapNode = node.GetUniformMap( bufferIndex );
-
- uint32_t maxMaps = static_cast<uint32_t>( uniformMap.Count() + uniformMapNode.Count() ); // 4,294,967,295 maps should be enough
- mUniformIndexMap.Clear(); // Clear contents, but keep memory if we don't change size
- mUniformIndexMap.Resize( maxMaps );
-
- uint32_t mapIndex = 0;
- for(; mapIndex < uniformMap.Count() ; ++mapIndex )
- {
- mUniformIndexMap[mapIndex].propertyValue = uniformMap[mapIndex].propertyPtr;
- mUniformIndexMap[mapIndex].uniformIndex = program.RegisterUniform(uniformMap[mapIndex].uniformName);
- }
-
- for( uint32_t nodeMapIndex = 0; nodeMapIndex < uniformMapNode.Count() ; ++nodeMapIndex )
- {
- uint32_t uniformIndex = program.RegisterUniform(uniformMapNode[nodeMapIndex].uniformName);
- bool found(false);
- for( uint32_t i = 0; i<uniformMap.Count(); ++i )
- {
- if( mUniformIndexMap[i].uniformIndex == uniformIndex )
- {
- mUniformIndexMap[i].propertyValue = uniformMapNode[nodeMapIndex].propertyPtr;
- found = true;
- break;
- }
- }
-
- if( !found )
- {
- mUniformIndexMap[mapIndex].propertyValue = uniformMapNode[nodeMapIndex].propertyPtr;
- mUniformIndexMap[mapIndex].uniformIndex = uniformIndex;
- ++mapIndex;
- }
- }
-
- mUniformIndexMap.Resize( mapIndex );
- }
-
- // Set uniforms in local map
- for( UniformIndexMappings::Iterator iter = mUniformIndexMap.Begin(),
- end = mUniformIndexMap.End() ;
- iter != end ;
- ++iter )
- {
- SetUniformFromProperty( bufferIndex, program, *iter );
- }