return material;
}
+Material CreateMaterial(float opacity, Image image)
+{
+ Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
+ Material material = Material::New(shader);
+
+ Vector4 color = Color::WHITE;
+ color.a = opacity;
+ material.SetProperty(Material::Property::COLOR, color);
+
+ Sampler sampler = Sampler::New( image, "sTexture" );
+ material.AddSampler( sampler );
+
+ return material;
+}
+
+
Geometry CreateQuadGeometry()
{
Property::Map texturedQuadVertexFormat;
{
Material CreateMaterial(float opacity);
-
+Material CreateMaterial(float opacity, Image image);
Geometry CreateQuadGeometry();
}
DALI_TEST_EQUALS( (bool)material, false, TEST_LOCATION );
END_TEST;
}
+
+
+
+int UtcDaliMaterialBlendingOptions01(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test SetBlendFunc(src, dest) ");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(0.5f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ material.SetBlendFunc(BlendingFactor::ONE_MINUS_SRC_COLOR, BlendingFactor::SRC_ALPHA_SATURATE);
+
+ // Test that Set was successful:
+ {
+ BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
+ BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
+ BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
+ BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
+ material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+
+ DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_SRC_COLOR, srcFactorAlpha, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingFactor::SRC_ALPHA_SATURATE, destFactorAlpha, TEST_LOCATION );
+ }
+
+ application.SendNotification();
+ application.Render();
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+
+ DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
+ DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
+ DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_SRC_COLOR, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
+ DALI_TEST_EQUALS( (GLenum)GL_SRC_ALPHA_SATURATE, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliMaterialBlendingOptions02(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test SetBlendFunc(srcRgb, destRgb, srcAlpha, destAlpha) ");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(0.5f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ material.SetBlendFunc( BlendingFactor::CONSTANT_COLOR, BlendingFactor::ONE_MINUS_CONSTANT_COLOR,
+ BlendingFactor::CONSTANT_ALPHA, BlendingFactor::ONE_MINUS_CONSTANT_ALPHA );
+
+ // Test that Set was successful:
+ {
+ BlendingFactor::Type srcFactorRgb( BlendingFactor::ZERO );
+ BlendingFactor::Type destFactorRgb( BlendingFactor::ZERO );
+ BlendingFactor::Type srcFactorAlpha( BlendingFactor::ZERO );
+ BlendingFactor::Type destFactorAlpha( BlendingFactor::ZERO );
+ material.GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+
+ DALI_TEST_EQUALS( BlendingFactor::CONSTANT_COLOR, srcFactorRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_COLOR, destFactorRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingFactor::CONSTANT_ALPHA, srcFactorAlpha, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingFactor::ONE_MINUS_CONSTANT_ALPHA, destFactorAlpha, TEST_LOCATION );
+ }
+
+ application.SendNotification();
+ application.Render();
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncSrcRgb(), TEST_LOCATION );
+ DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_COLOR, glAbstraction.GetLastBlendFuncDstRgb(), TEST_LOCATION );
+ DALI_TEST_EQUALS( (GLenum)GL_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncSrcAlpha(), TEST_LOCATION );
+ DALI_TEST_EQUALS( (GLenum)GL_ONE_MINUS_CONSTANT_ALPHA, glAbstraction.GetLastBlendFuncDstAlpha(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+
+
+int UtcDaliMaterialBlendingOptions03(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test GetBlendEquation() defaults ");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(0.5f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ // Test the defaults as documented int blending.h
+ {
+ BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
+ BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
+ material.GetBlendEquation( equationRgb, equationAlpha );
+ DALI_TEST_EQUALS( BlendingEquation::ADD, equationRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingEquation::ADD, equationAlpha, TEST_LOCATION );
+ }
+
+ END_TEST;
+}
+
+
+int UtcDaliMaterialBlendingOptions04(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test SetBlendEquation() ");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(0.5f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ // Test the single blending equation setting
+ {
+ material.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT );
+ BlendingEquation::Type equationRgba( BlendingEquation::SUBTRACT );
+ material.GetBlendEquation( equationRgba, equationRgba );
+ DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgba, TEST_LOCATION );
+ }
+
+ material.SetBlendEquation( BlendingEquation::REVERSE_SUBTRACT, BlendingEquation::REVERSE_SUBTRACT );
+
+ // Test that Set was successful
+ {
+ BlendingEquation::Type equationRgb( BlendingEquation::SUBTRACT );
+ BlendingEquation::Type equationAlpha( BlendingEquation::SUBTRACT );
+ material.GetBlendEquation( equationRgb, equationAlpha );
+ DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationRgb, TEST_LOCATION );
+ DALI_TEST_EQUALS( BlendingEquation::REVERSE_SUBTRACT, equationAlpha, TEST_LOCATION );
+ }
+
+ // Render & check GL commands
+ application.SendNotification();
+ application.Render();
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationRgb(), TEST_LOCATION );
+ DALI_TEST_EQUALS( (GLenum)GL_FUNC_REVERSE_SUBTRACT, glAbstraction.GetLastBlendEquationAlpha(), TEST_LOCATION );
+
+ END_TEST;
+}
+
+int UtcDaliMaterialSetBlendMode01(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test setting the blend mode to on with an opaque color renders with blending enabled");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(1.0f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ material.SetBlendMode(BlendingMode::ON);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableCullFaceCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ std::ostringstream blendStr;
+ blendStr << GL_BLEND;
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+
+ END_TEST;
+}
+
+
+int UtcDaliMaterialSetBlendMode02(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test setting the blend mode to off with a transparent color renders with blending disabled (and not enabled)");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(0.5f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ material.SetBlendMode(BlendingMode::OFF);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableCullFaceCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ std::ostringstream blendStr;
+ blendStr << GL_BLEND;
+ DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+
+ END_TEST;
+}
+
+int UtcDaliMaterialSetBlendMode03(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test setting the blend mode to auto with a transparent color renders with blending enabled");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(0.5f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ material.SetBlendMode(BlendingMode::AUTO);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableCullFaceCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ std::ostringstream blendStr;
+ blendStr << GL_BLEND;
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+
+ END_TEST;
+}
+
+int UtcDaliMaterialSetBlendMode04(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test setting the blend mode to auto with an opaque color renders with blending disabled");
+
+ Geometry geometry = CreateQuadGeometry();
+ Material material = CreateMaterial(1.0f);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ material.SetBlendMode(BlendingMode::AUTO);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableCullFaceCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ std::ostringstream blendStr;
+ blendStr << GL_BLEND;
+ DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+
+ END_TEST;
+}
+
+int UtcDaliMaterialSetBlendMode05(void)
+{
+ TestApplication application;
+
+ tet_infoline("Test setting the blend mode to auto with an opaque color and an image with an alpha channel renders with blending enabled");
+
+ Geometry geometry = CreateQuadGeometry();
+ BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
+ Material material = CreateMaterial(1.0f, image);
+ Renderer renderer = Renderer::New( geometry, material );
+
+ Actor actor = Actor::New();
+ actor.AddRenderer(renderer);
+ actor.SetSize(400, 400);
+ Stage::GetCurrent().Add(actor);
+
+ material.SetBlendMode(BlendingMode::AUTO);
+
+ TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ glAbstraction.EnableCullFaceCallTrace(true);
+
+ application.SendNotification();
+ application.Render();
+
+ TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ std::ostringstream blendStr;
+ blendStr << GL_BLEND;
+ DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
+
+ END_TEST;
+}
*/
DALI_PROPERTY_TABLE_BEGIN
DALI_PROPERTY( "color", VECTOR4, true, true, true, Dali::Material::Property::COLOR )
-DALI_PROPERTY( "face-culling-mode", STRING, true, false, true, Dali::Material::Property::FACE_CULLING_MODE )
-DALI_PROPERTY( "blending-mode", STRING, true, false, true, Dali::Material::Property::BLENDING_MODE )
-DALI_PROPERTY( "blend-equation", STRING, true, false, true, Dali::Material::Property::BLEND_EQUATION )
-DALI_PROPERTY( "source-blend-factor-rgb", STRING, true, false, true, Dali::Material::Property::BLENDING_SRC_FACTOR_RGB )
-DALI_PROPERTY( "destination-blend-factor-rgb", STRING, true, false, true, Dali::Material::Property::BLENDING_DEST_FACTOR_RGB )
-DALI_PROPERTY( "source-blend-factor-alpha", STRING, true, false, true, Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA )
-DALI_PROPERTY( "destination-blend-factor-alpha", STRING, true, false, true, Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA )
+DALI_PROPERTY( "face-culling-mode", STRING, true, false, false, Dali::Material::Property::FACE_CULLING_MODE )
+DALI_PROPERTY( "blending-mode", STRING, true, false, false, Dali::Material::Property::BLENDING_MODE )
+DALI_PROPERTY( "blend-equation-rgb", STRING, true, false, false, Dali::Material::Property::BLEND_EQUATION_RGB )
+DALI_PROPERTY( "blend-equation-alpha", STRING, true, false, false, Dali::Material::Property::BLEND_EQUATION_ALPHA )
+DALI_PROPERTY( "source-blend-factor-rgb", STRING, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_RGB )
+DALI_PROPERTY( "destination-blend-factor-rgb", STRING, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_RGB )
+DALI_PROPERTY( "source-blend-factor-alpha", STRING, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA )
+DALI_PROPERTY( "destination-blend-factor-alpha", STRING, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA )
DALI_PROPERTY( "blend-color", VECTOR4, true, true, true, Dali::Material::Property::BLEND_COLOR )
DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
}
}
-// @todo MESH_REWORK API change, or store here
BlendingMode::Type Material::GetBlendMode() const
{
return mBlendingMode;
void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgba, BlendingFactor::Type destFactorRgba )
{
- // TODO: MESH_REWORK
- DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
+ mBlendingOptions.SetBlendFunc( srcFactorRgba, destFactorRgba, srcFactorRgba, destFactorRgba );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
}
void Material::SetBlendFunc( BlendingFactor::Type srcFactorRgb,
BlendingFactor::Type srcFactorAlpha,
BlendingFactor::Type destFactorAlpha )
{
- // TODO: MESH_REWORK
- DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
+ mBlendingOptions.SetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
}
void Material::GetBlendFunc( BlendingFactor::Type& srcFactorRgb,
BlendingFactor::Type& srcFactorAlpha,
BlendingFactor::Type& destFactorAlpha ) const
{
- // TODO: MESH_REWORK
- DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
+ srcFactorRgb = mBlendingOptions.GetBlendSrcFactorRgb();
+ destFactorRgb = mBlendingOptions.GetBlendDestFactorRgb();
+ srcFactorAlpha = mBlendingOptions.GetBlendSrcFactorAlpha();
+ destFactorAlpha = mBlendingOptions.GetBlendDestFactorAlpha();
}
void Material::SetBlendEquation( BlendingEquation::Type equationRgba )
{
- // TODO: MESH_REWORK
- DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
+ mBlendingOptions.SetBlendEquation( equationRgba, equationRgba );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
}
void Material::SetBlendEquation( BlendingEquation::Type equationRgb,
BlendingEquation::Type equationAlpha )
{
- // TODO: MESH_REWORK
- DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
+ mBlendingOptions.SetBlendEquation( equationRgb, equationAlpha );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
}
void Material::GetBlendEquation( BlendingEquation::Type& equationRgb,
BlendingEquation::Type& equationAlpha ) const
{
- // TODO: MESH_REWORK
- DALI_ASSERT_ALWAYS( false && "TODO: MESH_REWORK" );
+ // These are not animatable, the cached values are up-to-date.
+ equationRgb = mBlendingOptions.GetBlendEquationRgb();
+ equationAlpha = mBlendingOptions.GetBlendEquationAlpha();
}
void Material::SetBlendColor( const Vector4& color )
}
break;
}
- case Dali::Material::Property::BLEND_EQUATION:
+ case Dali::Material::Property::BLEND_EQUATION_RGB:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
+ mBlendingOptions.SetBlendEquation( static_cast<BlendingEquation::Type>(propertyValue.Get<int>()), alphaEquation );
+ break;
+ }
+ case Dali::Material::Property::BLEND_EQUATION_ALPHA:
+ {
+ BlendingEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
+ mBlendingOptions.SetBlendEquation( rgbEquation, static_cast<BlendingEquation::Type>(propertyValue.Get<int>()) );
break;
}
case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
+ destFactorRgb,
+ srcFactorAlpha,
+ destFactorAlpha );
break;
}
case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
+ srcFactorAlpha,
+ destFactorAlpha );
break;
}
case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ destFactorRgb,
+ static_cast<BlendingFactor::Type>(propertyValue.Get<int>()),
+ destFactorAlpha );
break;
}
case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ destFactorRgb,
+ srcFactorAlpha,
+ static_cast<BlendingFactor::Type>(propertyValue.Get<int>()) );
break;
}
case Dali::Material::Property::BLEND_COLOR:
}
break;
}
- case Dali::Material::Property::BLEND_EQUATION:
+ case Dali::Material::Property::BLEND_EQUATION_RGB:
+ {
+ value = static_cast<int>( mBlendingOptions.GetBlendEquationRgb() );
+ break;
+ }
+ case Dali::Material::Property::BLEND_EQUATION_ALPHA:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ value = static_cast<int>( mBlendingOptions.GetBlendEquationAlpha() );
break;
}
case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( srcFactorRgb );
break;
}
case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( destFactorRgb );
break;
}
case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( srcFactorAlpha );
break;
}
case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
{
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ value = static_cast<int>( destFactorAlpha );
break;
}
case Dali::Material::Property::BLEND_COLOR:
property = &mSceneObject->mFaceCullingMode;
break;
}
- case Dali::Material::Property::BLENDING_MODE:
- {
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
- break;
- }
- case Dali::Material::Property::BLEND_EQUATION:
- {
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
- break;
- }
- case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
- {
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
- break;
- }
- case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
- {
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
- break;
- }
- case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
- {
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
- break;
- }
- case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
- {
- DALI_ASSERT_ALWAYS( 0 && "Mesh Rework" );
- break;
- }
case Dali::Material::Property::BLEND_COLOR:
{
property = &mSceneObject->mBlendColor;
#include <dali/internal/event/common/property-buffer-impl.h> // Dali::Internal::PropertyBuffer
#include <dali/internal/event/effects/sampler-impl.h> // Dali::Internal::Sampler
#include <dali/internal/event/effects/shader-impl.h> // Dali::Internal::Shader
+#include <dali/internal/common/blending-options.h>
namespace Dali
{
SceneGraph::Material* mSceneObject;
BlendingMode::Type mBlendingMode; ///< Local store
+ BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
bool mOnStage;
};
// INTERNAL HEADERS
#include <dali/public-api/shader-effects/material.h>
#include <dali/public-api/shader-effects/shader-effect.h>
-#include <dali/internal/render/data-providers/sampler-data-provider.h>
+#include <dali/internal/common/internal-constants.h>
#include <dali/internal/update/effects/scene-graph-sampler.h>
+#include <dali/internal/render/data-providers/sampler-data-provider.h>
#include <dali/internal/render/shaders/scene-graph-shader.h>
#include <dali/public-api/actors/blending.h>
mBlendColor( Color::WHITE ),
mFaceCullingMode(Dali::Material::NONE),
mBlendingMode(Dali::BlendingMode::AUTO),
- mBlendFuncSrcFactorRgb(DEFAULT_BLENDING_SRC_FACTOR_RGB),
- mBlendFuncSrcFactorAlpha(DEFAULT_BLENDING_SRC_FACTOR_ALPHA),
- mBlendFuncDestFactorRgb(DEFAULT_BLENDING_DEST_FACTOR_RGB),
- mBlendFuncDestFactorAlpha(DEFAULT_BLENDING_SRC_FACTOR_ALPHA),
- mBlendEquationRgb(DEFAULT_BLENDING_EQUATION_RGB),
- mBlendEquationAlpha(DEFAULT_BLENDING_EQUATION_ALPHA),
+ mBlendingOptions(DEFAULT_BLENDING_EQUATION_ALPHA),
mShader(NULL),
mBlendingEnabled(false)
{
if( opaque )
{
+ // Check the material color:
+ opaque = ( mColor[ bufferIndex ].a >= FULLY_OPAQUE );
+ }
+
+ if( opaque )
+ {
// Require that all affecting samplers are opaque
unsigned int opaqueCount=0;
unsigned int affectingCount=0;
return mBlendingEnabled[bufferIndex];
}
+void Material::SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options )
+{
+ mBlendingOptions.Set( updateBufferIndex, options );
+}
+
const Vector4& Material::GetBlendColor(BufferIndex bufferIndex) const
{
return mBlendColor[bufferIndex];
BlendingFactor::Type Material::GetBlendSrcFactorRgb( BufferIndex bufferIndex ) const
{
- return static_cast<Dali::BlendingFactor::Type>(mBlendFuncSrcFactorRgb[bufferIndex]);
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendSrcFactorRgb();
}
BlendingFactor::Type Material::GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const
{
- return static_cast<Dali::BlendingFactor::Type>(mBlendFuncSrcFactorAlpha[bufferIndex]);
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendSrcFactorAlpha();
}
BlendingFactor::Type Material::GetBlendDestFactorRgb( BufferIndex bufferIndex ) const
{
- return static_cast<Dali::BlendingFactor::Type>(mBlendFuncDestFactorRgb[bufferIndex]);
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendDestFactorRgb();
}
BlendingFactor::Type Material::GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const
{
- return static_cast<Dali::BlendingFactor::Type>(mBlendFuncDestFactorAlpha[bufferIndex]);
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendDestFactorAlpha();
}
BlendingEquation::Type Material::GetBlendEquationRgb( BufferIndex bufferIndex ) const
{
- return static_cast<Dali::BlendingEquation::Type>(mBlendEquationRgb[bufferIndex]);
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendEquationRgb();
}
BlendingEquation::Type Material::GetBlendEquationAlpha( BufferIndex bufferIndex ) const
{
- return static_cast<Dali::BlendingEquation::Type>(mBlendEquationAlpha[bufferIndex]);
+ BlendingOptions blendingOptions;
+ blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
+ return blendingOptions.GetBlendEquationAlpha();
}
void Material::ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex )
mFaceCullingMode.CopyPrevious( updateBufferIndex );
mBlendingMode.CopyPrevious( updateBufferIndex );
- mBlendFuncSrcFactorRgb.CopyPrevious( updateBufferIndex );
- mBlendFuncSrcFactorAlpha.CopyPrevious( updateBufferIndex );
- mBlendFuncDestFactorRgb.CopyPrevious( updateBufferIndex );
- mBlendFuncDestFactorAlpha.CopyPrevious( updateBufferIndex );
- mBlendEquationRgb.CopyPrevious( updateBufferIndex );
- mBlendEquationAlpha.CopyPrevious( updateBufferIndex );
+ mBlendingOptions.CopyPrevious( updateBufferIndex );
}
} // namespace SceneGraph
*/
bool GetBlendingEnabled( BufferIndex bufferIndex ) const;
+ /**
+ * Set the blending options. This should only be called from the update-thread.
+ * @param[in] updateBufferIndex The current update buffer index.
+ * @param[in] options A bitmask of blending options.
+ */
+ void SetBlendingOptions( BufferIndex updateBufferIndex, unsigned int options );
+
public: // Implementation of MaterialDataProvider
/**
AnimatableProperty<Vector4> mBlendColor;
DoubleBufferedProperty<int> mFaceCullingMode;
DoubleBufferedProperty<int> mBlendingMode;
-
- // @todo MESH_REWORK Consider storing only mBlendingOptions bitmask
- DoubleBufferedProperty<int> mBlendFuncSrcFactorRgb;
- DoubleBufferedProperty<int> mBlendFuncSrcFactorAlpha;
- DoubleBufferedProperty<int> mBlendFuncDestFactorRgb;
- DoubleBufferedProperty<int> mBlendFuncDestFactorAlpha;
- DoubleBufferedProperty<int> mBlendEquationRgb;
- DoubleBufferedProperty<int> mBlendEquationAlpha;
+ DoubleBufferedProperty<int> mBlendingOptions;
private:
Shader* mShader;
Vector<Sampler*> mSamplers; // Not owned
ConnectionChangePropagator mConnectionObservers;
- DoubleBuffered<bool> mBlendingEnabled; // The output of the current blending mode and sampler properties
+ DoubleBuffered<int> mBlendingEnabled; // The output of the current blending mode and sampler properties
};
inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Material& material, const Shader& shader )
new (slot) LocalType( &material, &Material::RemoveSampler, const_cast<Sampler*>(&sampler) );
}
+inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Material& material, unsigned int options )
+{
+ typedef MessageDoubleBuffered1< Material, unsigned int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &material, &Material::SetBlendingOptions, options );
+}
+
+
} // namespace SceneGraph
} // namespace Internal
} // namespace Dali
mMagFilter( Dali::Sampler::DEFAULT ),
mUWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
mVWrapMode( Dali::Sampler::CLAMP_TO_EDGE ),
- mAffectsTransparency( false ),
+ mAffectsTransparency( true ),
mTextureUnitUniformName( textureUnitUniformName ),
mTextureId( 0u ),
mFullyOpaque(true)
COLOR = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "color", type VECTOR4
FACE_CULLING_MODE, ///< name "face-culling-mode", type STRING
BLENDING_MODE, ///< name "blending-mode", type STRING
- BLEND_EQUATION, ///< name "blend-equation", type STRING
+ BLEND_EQUATION_RGB, ///< name "blend-equation-rgb", type STRING
+ BLEND_EQUATION_ALPHA, ///< name "blend-equation-alpha", type STRING
BLENDING_SRC_FACTOR_RGB, ///< name "source-blend-factor-rgb", type STRING
BLENDING_DEST_FACTOR_RGB, ///< name "destination-blend-factor-rgb", type STRING
BLENDING_SRC_FACTOR_ALPHA, ///< name "source-blend-factor-alpha", type STRING