+void ImageRenderer::EnablePreMultipliedAlpha( bool preMultipled )
+{
+ mIsAlphaPreMultiplied = preMultipled;
+ if( mImpl->mRenderer )
+ {
+ Material material = mImpl->mRenderer.GetMaterial();
+
+ if( preMultipled )
+ {
+ material.SetBlendFunc( BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA,
+ BlendingFactor::ONE, BlendingFactor::ONE );
+ if( !mImpl->mCustomShader || mImpl->mCustomShader->mVertexShader.empty())
+ {
+ material.RegisterProperty( ALPHA_BLENDING_UNIFORM_NAME, 0.f );
+ }
+ }
+ else
+ {
+ // using default blend func
+ material.SetBlendFunc( BlendingFactor::SRC_ALPHA, BlendingFactor::ONE_MINUS_SRC_ALPHA,
+ BlendingFactor::ONE, BlendingFactor::ONE_MINUS_SRC_ALPHA );
+
+ Property::Index index = material.GetPropertyIndex( ALPHA_BLENDING_UNIFORM_NAME );
+ if( index != Property::INVALID_INDEX ) // only set value when the property already exist on the Material
+ {
+ material.SetProperty( index, 1.f );
+ }
+ }
+ }
+}
+