- material color removed since actor color will always override if (because we can use same renderer with multiple actors)
- blend color changed to pointer in scene graph and non animateable
- blending options cached in event thread and not double buffered in update as they are almost never ever changed
Change-Id: Iec99b52f1bd5ce2d38cd2fa8888117a326383fe4
DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
actor.AddRenderer( renderer );
application.Render(0);
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
application.SendNotification();
DALI_TEST_EQUALS( actor.GetRendererCount(), 0u, TEST_LOCATION );
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
actor.AddRenderer( renderer );
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertexBuffer1 );
- Material material = CreateMaterial(1.f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
actor.SetSize(Vector3::ONE * 100.f);
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertexBuffer1 );
- Material material = CreateMaterial(1.f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
actor.SetSize(Vector3::ONE * 100.f);
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertexBuffer );
- Material material = CreateMaterial(1.f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
actor.SetSize(Vector3::ONE * 100.f);
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( vertexBuffer );
- Material material = CreateMaterial(1.f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
actor.SetSize(Vector3::ONE * 100.f);
geometry.AddVertexBuffer( vertexBuffer );
geometry.SetIndexBuffer( indexBuffer );
- Material material = CreateMaterial(1.f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
actor.SetSize(Vector3::ONE * 100.f);
END_TEST;
}
+
int UtcDaliGeometrySetGetRequireDepthTesting(void)
{
TestApplication application;
geometry.SetRequiresDepthTesting(true);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
// TODO: Not supported yes
-// TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+// TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
// std::ostringstream out;
// out << GL_DEPTH_TEST;
// DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
geometry.SetProperty(Geometry::Property::REQUIRES_DEPTH_TEST, true );
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
-// TODO: Not supported yes
-// TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+// TODO: Not supported yet
+// TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
// std::ostringstream out;
// out << GL_DEPTH_TEST;
// DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", out.str().c_str() ) );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
tet_infoline("Test GetNumberOfTextures()");
Image image = BufferImage::New(32, 32, Pixel::RGBA8888);
- Material material = CreateMaterial(0.5f);
+ Material material = CreateMaterial();
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
tet_infoline("Test SetFaceCullingMode(cullingMode)");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(0.5f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
tet_infoline("Test SetBlendFunc(src, dest) ");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(0.5f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
+ // set a transparent actor color so that blending is enabled
+ actor.SetOpacity( 0.5f );
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 );
+ 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 );
- }
+ 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();
tet_infoline("Test SetBlendFunc(srcRgb, destRgb, srcAlpha, destAlpha) ");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(0.5f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
+ actor.SetOpacity( 0.5f ); // enable blending
actor.AddRenderer(renderer);
actor.SetSize(400, 400);
Stage::GetCurrent().Add(actor);
tet_infoline("Test GetBlendEquation() defaults ");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(0.5f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
Stage::GetCurrent().Add(actor);
// Test the defaults as documented in 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 );
- }
+ 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;
}
tet_infoline("Test SetBlendEquation() ");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(0.5f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
+ actor.SetOpacity( 0.1f );
actor.AddRenderer(renderer);
actor.SetSize(400, 400);
Stage::GetCurrent().Add(actor);
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);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
+ actor.SetOpacity( 0.98f );
actor.AddRenderer(renderer);
actor.SetSize(400, 400);
Stage::GetCurrent().Add(actor);
material.SetBlendMode(BlendingMode::ON);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
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);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
+ actor.SetOpacity( 0.15f );
actor.AddRenderer(renderer);
actor.SetSize(400, 400);
Stage::GetCurrent().Add(actor);
material.SetBlendMode(BlendingMode::OFF);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
tet_infoline("Test setting the blend mode to auto with a transparent material color renders with blending enabled");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(0.5f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
+ actor.SetOpacity( 0.75f );
actor.AddRenderer(renderer);
actor.SetSize(400, 400);
Stage::GetCurrent().Add(actor);
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
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);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
tet_infoline("Test setting the blend mode to auto with an opaque material color and a transparent actor color renders with blending enabled");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
tet_infoline("Test setting the blend mode to auto with an opaque material color and an opaque actor color renders with blending disabled");
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
Geometry geometry = CreateQuadGeometry();
BufferImage image = BufferImage::New( 40, 40, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f, image);
+ Material material = CreateMaterial( image );
Renderer renderer = Renderer::New( geometry, material );
Actor actor = Actor::New();
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
Geometry geometry = CreateQuadGeometry();
Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_TRANSPARENT );
Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Renderer renderer = Renderer::New( geometry, material );
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
Geometry geometry = CreateQuadGeometry();
Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::TRANSPARENT);
Renderer renderer = Renderer::New( geometry, material );
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
Geometry geometry = CreateQuadGeometry();
Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
BufferImage image = BufferImage::New( 50, 50, Pixel::RGB888 );
material.AddTexture( image, "sTexture" );
Renderer renderer = Renderer::New( geometry, material );
material.SetBlendMode(BlendingMode::AUTO);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
- glAbstraction.EnableCullFaceCallTrace(true);
+ glAbstraction.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = glAbstraction.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = glAbstraction.GetEnableDisableTrace();
DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", "GL_BLEND" ) );
END_TEST;
Material material = Material::New(shader);
// default value
- DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::OFF, TEST_LOCATION );
-
- // AUTO
- material.SetBlendMode(BlendingMode::AUTO);
DALI_TEST_EQUALS( material.GetBlendMode(), BlendingMode::AUTO, TEST_LOCATION );
// ON
Geometry geometry = CreateQuadGeometry();
Shader shader = Shader::New( "vertexSrc", "fragmentSrc", Shader::HINT_OUTPUT_IS_OPAQUE );
Material material = Material::New(shader);
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
BufferImage image = BufferImage::New( 50, 50, Pixel::RGBA8888 );
material.AddTexture( image, "sTexture" );
Renderer renderer = Renderer::New( geometry, material );
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
+ material.SetBlendColor( Color::TRANSPARENT );
application.SendNotification();
application.Render();
DALI_TEST_EQUALS( glAbstraction.GetLastBlendColor(), Color::TRANSPARENT, TEST_LOCATION );
Shader shader = Shader::New( "VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New( "VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New( "VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New( "VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.AddTexture( image, "sTexture" );
int textureIndex = material.GetTextureIndex( "sTexture" );
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
Image image2 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.AddTexture( image, "sTexture");
material.SetTextureUniformName( 0, "sEffectTexture" );
material.AddTexture( image2, "sTexture2");
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.AddTexture( image, "sTexture" );
Geometry geometry = CreateQuadGeometry();
// Test SetAffectsTransparency( false )
material.SetTextureAffectsTransparency( 0, false );
- gl.EnableCullFaceCallTrace(true);
+ gl.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
- TraceCallStack& glEnableStack = gl.GetCullFaceTrace();
+ TraceCallStack& glEnableStack = gl.GetEnableDisableTrace();
std::ostringstream blendStr;
blendStr << GL_BLEND;
DALI_TEST_CHECK( ! glEnableStack.FindMethodAndParams( "Enable", blendStr.str().c_str() ) );
material.SetTextureAffectsTransparency( 0, true );
glEnableStack.Reset();
- gl.EnableCullFaceCallTrace(true);
+ gl.EnableEnableDisableCallTrace(true);
application.SendNotification();
application.Render();
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.AddTexture( image, "sTexture");
Geometry geometry = CreateQuadGeometry();
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Sampler sampler = Sampler::New();
sampler.SetFilterMode( FilterMode::NEAREST, FilterMode::NEAREST );
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.RemoveTexture(0);
DALI_TEST_EQUALS( material.GetNumberOfTextures(), 0, TEST_LOCATION );
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.AddTexture( image, "sTexture");
Geometry geometry = CreateQuadGeometry();
Image image3 = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.AddTexture( image0, "sTexture0");
material.AddTexture( image1, "sTexture1");
material.AddTexture( image2, "sTexture2");
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( propertyBuffer );
- Material material = CreateMaterial(1.f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
actor.SetSize(Vector3::ONE * 100.f);
Geometry geometry = Geometry::New();
geometry.AddVertexBuffer( propertyBuffer );
- Material material = CreateMaterial(1.f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
actor.SetSize(Vector3::ONE * 100.f);
TestApplication application;
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
DALI_TEST_EQUALS( (bool)renderer, true, TEST_LOCATION );
TestApplication application;
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Renderer rendererCopy( renderer );
TestApplication application;
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
Renderer renderer2;
TestApplication application;
Geometry geometry = CreateQuadGeometry();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry, material);
BaseHandle handle(renderer);
Geometry geometry2 = CreateQuadGeometry();
geometry2.RegisterProperty( "uFadeColor", Color::GREEN );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Renderer renderer = Renderer::New(geometry1, material);
Actor actor = Actor::New();
actor.AddRenderer(renderer);
TestGlAbstraction& glAbstraction = application.GetGlAbstraction();
glAbstraction.EnableCullFaceCallTrace(true);
- Material material1 = CreateMaterial(1.0f);
+ Material material1 = CreateMaterial();
material1.RegisterProperty( "uFadeColor", Color::RED );
- Material material2 = CreateMaterial(1.0f);
+ Material material2 = CreateMaterial();
material2.RegisterProperty( "uFadeColor", Color::GREEN );
Geometry geometry = CreateQuadGeometry();
tet_infoline("Test SetDepthIndex, GetDepthIndex");
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New(geometry, material);
Actor actor = Actor::New();
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
material.AddTexture( image, "sTexture" );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
PropertyBuffer vertexBuffer = CreatePropertyBuffer();
Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
material.AddTexture( image, "sTexture" );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
PropertyBuffer vertexBuffer = CreatePropertyBuffer();
Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
material.AddTexture( image, "sTexture" );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
PropertyBuffer vertexBuffer = CreatePropertyBuffer();
Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
material.AddTexture( image, "sTexture" );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
PropertyBuffer vertexBuffer = CreatePropertyBuffer();
Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
PropertyBuffer vertexBuffer = CreatePropertyBuffer();
Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
PropertyBuffer vertexBuffer = CreatePropertyBuffer();
Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
Shader shader = Shader::New("VertexSource", "FragmentSource");
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
PropertyBuffer vertexBuffer = CreatePropertyBuffer();
Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
Sampler sampler = Sampler::New();
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
material.AddTexture( image, "sTexture", sampler );
Geometry geometry = CreateQuadGeometry();
TestApplication application;
Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Sampler sampler = Sampler::New();
material.AddTexture( image, "sTexture", sampler );
Shader shader = Shader::New(VertexSource, FragmentSource);
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New(VertexSource, FragmentSource);
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New(VertexSource, FragmentSource);
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
Shader shader = Shader::New(VertexSource, FragmentSource);
Material material = Material::New( shader );
- material.SetProperty(Material::Property::COLOR, Color::WHITE);
Geometry geometry = CreateQuadGeometry();
Renderer renderer = Renderer::New( geometry, material );
namespace Dali
{
-Material CreateMaterial(float opacity)
+Material CreateMaterial()
{
Shader shader = Shader::New( "vertexSrc", "fragmentSrc" );
Material material = Material::New(shader);
- Vector4 color = Color::WHITE;
- color.a = opacity;
- material.SetProperty(Material::Property::COLOR, color);
return material;
}
-Material CreateMaterial(float opacity, Image image)
+Material CreateMaterial( 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);
-
material.AddTexture( image, "sTexture" );
return material;
namespace Dali
{
-Material CreateMaterial(float opacity);
-Material CreateMaterial(float opacity, Image image);
+Material CreateMaterial();
+Material CreateMaterial(Image image);
Geometry CreateQuadGeometry();
Geometry CreateQuadGeometryFromBuffer( PropertyBuffer vertexData );
PropertyBuffer CreatePropertyBuffer();
{
std::stringstream out;
out << cap;
- mCullFaceTrace.PushCall("Disable", out.str());
+ mEnableDisableTrace.PushCall("Disable", out.str());
}
inline void DisableVertexAttribArray(GLuint index)
{
std::stringstream out;
out << cap;
- mCullFaceTrace.PushCall("Enable", out.str());
+ mEnableDisableTrace.PushCall("Enable", out.str());
}
inline void EnableVertexAttribArray(GLuint index)
inline void ResetCullFaceCallStack() { mCullFaceTrace.Reset(); }
inline TraceCallStack& GetCullFaceTrace() { return mCullFaceTrace; }
+ //Methods for Enable/Disable call verification
+ inline void EnableEnableDisableCallTrace(bool enable) { mEnableDisableTrace.Enable(enable); }
+ inline void ResetEnableDisableCallStack() { mEnableDisableTrace.Reset(); }
+ inline TraceCallStack& GetEnableDisableTrace() { return mEnableDisableTrace; }
+
//Methods for Shader verification
inline void EnableShaderCallTrace(bool enable) { mShaderTrace.Enable(enable); }
inline void ResetShaderCallStack() { mShaderTrace.Reset(); }
ActiveTextureType mActiveTextures[ MIN_TEXTURE_UNIT_LIMIT ];
TraceCallStack mCullFaceTrace;
+ TraceCallStack mEnableDisableTrace;
TraceCallStack mShaderTrace;
TraceCallStack mTextureTrace;
TraceCallStack mTexParamaterTrace;
ImageActor actor = ImageActor::New( image );
actor.SetBlendMode( BlendingMode::ON );
actor.SetSize(100, 50);
- application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
+ application.GetGlAbstraction().EnableEnableDisableCallTrace(true); // For Enable(GL_BLEND)
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
- const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
+ const TraceCallStack& callTrace = application.GetGlAbstraction().GetEnableDisableTrace();
DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
END_TEST;
ImageActor actor = ImageActor::New( image );
actor.SetBlendMode( BlendingMode::OFF );
actor.SetSize(100, 50);
- application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
+ application.GetGlAbstraction().EnableEnableDisableCallTrace(true); // For Enable(GL_BLEND)
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
- const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
+ const TraceCallStack& callTrace = application.GetGlAbstraction().GetEnableDisableTrace();
DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
DALI_TEST_EQUALS( BlendEnabled( callTrace), false, TEST_LOCATION );
END_TEST;
actor.SetBlendMode( BlendingMode::AUTO );
actor.SetColor(Vector4(1.0, 1.0, 1.0, 0.5));
actor.SetSize(100, 50);
- application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
+ application.GetGlAbstraction().EnableEnableDisableCallTrace(true); // For Enable(GL_BLEND)
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
- const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
+ const TraceCallStack& callTrace = application.GetGlAbstraction().GetEnableDisableTrace();
DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
END_TEST;
actor.SetBlendMode( BlendingMode::ON );
actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0));
actor.SetSize(100, 50);
- application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
+ application.GetGlAbstraction().EnableEnableDisableCallTrace(true); // For Enable(GL_BLEND)
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
- const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
+ const TraceCallStack& callTrace = application.GetGlAbstraction().GetEnableDisableTrace();
DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
DALI_TEST_EQUALS( BlendEnabled( callTrace), true, TEST_LOCATION );
END_TEST;
actor.SetBlendMode( BlendingMode::AUTO );
actor.SetColor(Vector4(1.0, 1.0, 1.0, 1.0));
actor.SetSize(100, 50);
- application.GetGlAbstraction().EnableCullFaceCallTrace(true); // For Enable(GL_BLEND)
+ application.GetGlAbstraction().EnableEnableDisableCallTrace(true); // For Enable(GL_BLEND)
Stage::GetCurrent().Add(actor);
application.SendNotification();
application.Render();
- const TraceCallStack& callTrace = application.GetGlAbstraction().GetCullFaceTrace();
+ const TraceCallStack& callTrace = application.GetGlAbstraction().GetEnableDisableTrace();
DALI_TEST_EQUALS( BlendDisabled( callTrace ), false, TEST_LOCATION );
DALI_TEST_EQUALS( BlendEnabled( callTrace), false, TEST_LOCATION );
END_TEST;
application.Render();
// There should be a single call to Clear
- DALI_TEST_EQUALS( application.GetGlAbstraction().GetClearCountCalled() , 1u, TEST_LOCATION );
+ DALI_TEST_EQUALS( application.GetGlAbstraction().GetClearCountCalled(), 1u, TEST_LOCATION );
// the last set clear mask should be COLOR, DEPTH & STENCIL which occurs at the start of each frame
GLbitfield mask = application.GetGlAbstraction().GetLastClearMask();
test_return_value = TET_PASS;
}
-
-namespace
-{
-
-Material ConstructMaterial( const std::string& vertexShader,
- const std::string& fragmentShader,
- float opacity )
-{
- Shader shader = Shader::New( vertexShader, fragmentShader );
- Material customMaterial = Material::New(shader);
- Vector4 color = Color::WHITE;
- color.a = opacity;
- customMaterial.SetProperty(Material::Property::COLOR, color);
- return customMaterial;
-}
-
-void TestBlending( TestApplication& application, Material material, float actorOpacity, BlendingMode::Type blendingMode, bool expectedBlend )
-{
- // Generate geometry & renderers
- //Mesh mesh = Mesh::New(meshData);
-
- application.SendNotification();
- application.Render(0);
- application.Render();
- application.SendNotification();
-
- Actor actor = Actor::New();
- Stage::GetCurrent().Add(actor);
-
- //material.SetBlendMode(blendingMode);
- actor.SetOpacity(actorOpacity);
-
- TraceCallStack& cullFaceTrace = application.GetGlAbstraction().GetCullFaceTrace();
- cullFaceTrace.Enable(true);
- application.SendNotification();
- application.Render();
- //DALI_TEST_EQUALS( BlendEnabled( cullFaceTrace ), expectedBlend, TEST_LOCATION );
-}
-
-} // anonymous namespace
-
-
/**
* Test cases
*
CameraActor offscreenCameraActor = CameraActor::New();
Stage::GetCurrent().Add( offscreenCameraActor );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
Integration::ResourceId imageRequestId = imageRequest->GetId();
CameraActor offscreenCameraActor = CameraActor::New();
Stage::GetCurrent().Add( offscreenCameraActor );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
Integration::ResourceId imageRequestId = imageRequest->GetId();
CameraActor offscreenCameraActor = CameraActor::New();
Stage::GetCurrent().Add( offscreenCameraActor );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
Integration::ResourceId imageRequestId = imageRequest->GetId();
CameraActor offscreenCameraActor = CameraActor::New();
Stage::GetCurrent().Add( offscreenCameraActor );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
Integration::ResourceId imageRequestId = imageRequest->GetId();
CameraActor offscreenCameraActor = CameraActor::New();
Stage::GetCurrent().Add( offscreenCameraActor );
- Material material = CreateMaterial(1.0f);
+ Material material = CreateMaterial();
Image image = CreateLoadingImage(application, "aFile.jpg", ResourceImage::IMMEDIATE, Image::UNUSED);
Integration::ResourceRequest* imageRequest = application.GetPlatform().GetRequest();
Integration::ResourceId imageRequestId = imageRequest->GetId();
Material Material::New( Shader shader )
{
- // TODO: MESH_REWORK
Internal::MaterialPtr material = Internal::Material::New();
material->SetShader( GetImplementation(shader) );
GetImplementation(*this).SetFaceCullingMode( cullingMode );
}
+Material::FaceCullingMode Material::GetFaceCullingMode()
+{
+ return GetImplementation(*this).GetFaceCullingMode();
+}
+
void Material::SetBlendMode( BlendingMode::Type mode )
{
GetImplementation(*this).SetBlendMode( mode );
GetImplementation(*this).SetBlendColor( color );
}
-const Vector4& Material::GetBlendColor() const
+Vector4 Material::GetBlendColor() const
{
return GetImplementation(*this).GetBlendColor();
}
{
enum
{
- 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_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
- BLENDING_DEST_FACTOR_ALPHA, ///< name "destination-blend-factor-alpha", type STRING
- BLEND_COLOR, ///< name "blend-color", type VECTOR4
+ FACE_CULLING_MODE = DEFAULT_OBJECT_PROPERTY_START_INDEX, ///< name "face-culling-mode", type INTEGER
+ BLENDING_MODE, ///< name "blending-mode", type INTEGER
+ BLEND_EQUATION_RGB, ///< name "blend-equation-rgb", type INTEGER
+ BLEND_EQUATION_ALPHA, ///< name "blend-equation-alpha", type INTEGER
+ BLENDING_SRC_FACTOR_RGB, ///< name "source-blend-factor-rgb", type INTEGER
+ BLENDING_DEST_FACTOR_RGB, ///< name "destination-blend-factor-rgb", type INTEGER
+ BLENDING_SRC_FACTOR_ALPHA, ///< name "source-blend-factor-alpha", type INTEGER
+ BLENDING_DEST_FACTOR_ALPHA, ///< name "destination-blend-factor-alpha", type INTEGER
+ BLEND_COLOR, ///< name "blend-color", type VECTOR4
};
};
- /// @name Uniform Mapping
- /** @{ */
- ///< property "COLOR", uniform "uMaterialColor"
- /** @} */
-
/**
* @brief Creates a new Material object
*
/**
* @brief Set the culling mode for this material
*
- * Calling this function sets the properties CULLING_MODE
+ * Calling this function sets the property CULLING_MODE
*
* @param[in] cullingMode The culling mode for this material
*/
void SetFaceCullingMode( FaceCullingMode cullingMode );
/**
+ * @brief Get the face culling mode for this material
+ *
+ * @return The face culling mode for this material
+ */
+ FaceCullingMode GetFaceCullingMode();
+
+ /**
* @brief Sets the blending mode.
*
* Possible values are: BlendingMode::OFF, BlendingMode::AUTO and BlendingMode::ON. Default is BlendingMode::AUTO.
*
* @return The blend color.
*/
- const Vector4& GetBlendColor() const;
+ Vector4 GetBlendColor() const;
public:
/**
* |name |type |writable|animatable|constraint-input|enum for index-checking|
*/
DALI_PROPERTY_TABLE_BEGIN
-DALI_PROPERTY( "color", VECTOR4, true, true, true, Dali::Material::Property::COLOR )
-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( "face-culling-mode", INTEGER, true, false, false, Dali::Material::Property::FACE_CULLING_MODE )
+DALI_PROPERTY( "blending-mode", INTEGER, true, false, false, Dali::Material::Property::BLENDING_MODE )
+DALI_PROPERTY( "blend-equation-rgb", INTEGER, true, false, false, Dali::Material::Property::BLEND_EQUATION_RGB )
+DALI_PROPERTY( "blend-equation-alpha", INTEGER, true, false, false, Dali::Material::Property::BLEND_EQUATION_ALPHA )
+DALI_PROPERTY( "source-blend-factor-rgb", INTEGER, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_RGB )
+DALI_PROPERTY( "destination-blend-factor-rgb", INTEGER, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_RGB )
+DALI_PROPERTY( "source-blend-factor-alpha", INTEGER, true, false, false, Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA )
+DALI_PROPERTY( "destination-blend-factor-alpha", INTEGER, true, false, false, Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA )
+DALI_PROPERTY( "blend-color", VECTOR4, true, false, false, Dali::Material::Property::BLEND_COLOR )
DALI_PROPERTY_TABLE_END( DEFAULT_ACTOR_PROPERTY_START_INDEX )
const ObjectImplHelper<DEFAULT_PROPERTY_COUNT> MATERIAL_IMPL = { DEFAULT_PROPERTY_DETAILS };
void Material::SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode )
{
- if( NULL != mSceneObject )
+ if( mFaceCullingMode != cullingMode )
{
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mFaceCullingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, static_cast<int>(cullingMode) );
+ mFaceCullingMode = cullingMode;
+
+ SetFaceCullingModeMessage( GetEventThreadServices(), *mSceneObject, mFaceCullingMode );
}
}
-void Material::SetBlendMode( BlendingMode::Type mode )
+Dali::Material::FaceCullingMode Material::GetFaceCullingMode()
{
- mBlendingMode = mode;
+ return mFaceCullingMode;
+}
- if( NULL != mSceneObject )
+void Material::SetBlendMode( BlendingMode::Type mode )
+{
+ if( mBlendingMode != mode )
{
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, static_cast<int>(mode) );
+ mBlendingMode = mode;
+
+ SetBlendingModeMessage( GetEventThreadServices(), *mSceneObject, mBlendingMode );
}
}
void Material::SetBlendColor( const Vector4& color )
{
- if( mSceneObject )
+ if( !mBlendColor )
+ {
+ mBlendColor = new Vector4();
+ }
+ if( *mBlendColor != color )
{
- SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, color );
+ *mBlendColor = color;
+ SetBlendColorMessage( GetEventThreadServices(), *mSceneObject, *mBlendColor );
}
}
-const Vector4& Material::GetBlendColor() const
+Vector4 Material::GetBlendColor() const
{
- return mSceneObject->mBlendColor[ GetEventThreadServices().GetEventBufferIndex() ];
+ if( mBlendColor )
+ {
+ return *mBlendColor;
+ }
+ return Color::TRANSPARENT; // GL default
}
const SceneGraph::Material* Material::GetMaterialSceneObject() const
{
switch( index )
{
- case Dali::Material::Property::COLOR:
- {
- SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, propertyValue.Get<Vector4>() );
- break;
- }
case Dali::Material::Property::FACE_CULLING_MODE:
{
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mFaceCullingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ int faceCullingMode;
+ if( propertyValue.Get( faceCullingMode ) )
+ {
+ SetFaceCullingMode( Dali::Material::FaceCullingMode( faceCullingMode ) );
+ }
break;
}
case Dali::Material::Property::BLENDING_MODE:
{
- if( mSceneObject )
+ int blendingMode;
+ if( propertyValue.Get( blendingMode ) )
{
- SceneGraph::DoubleBufferedPropertyMessage<int>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendingMode, &SceneGraph::DoubleBufferedProperty<int>::Set, propertyValue.Get<int>() );
+ SetBlendMode( BlendingMode::Type( blendingMode ) );
}
break;
}
case Dali::Material::Property::BLEND_EQUATION_RGB:
{
- BlendingEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
- mBlendingOptions.SetBlendEquation( static_cast<BlendingEquation::Type>(propertyValue.Get<int>()), alphaEquation );
+ int blendingEquation;
+ if( propertyValue.Get( blendingEquation ) )
+ {
+ BlendingEquation::Type alphaEquation = mBlendingOptions.GetBlendEquationAlpha();
+ mBlendingOptions.SetBlendEquation( static_cast<BlendingEquation::Type>( blendingEquation ), alphaEquation );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ }
break;
}
case Dali::Material::Property::BLEND_EQUATION_ALPHA:
{
- BlendingEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
- mBlendingOptions.SetBlendEquation( rgbEquation, static_cast<BlendingEquation::Type>(propertyValue.Get<int>()) );
+ int blendingEquation;
+ if( propertyValue.Get( blendingEquation ) )
+ {
+ BlendingEquation::Type rgbEquation = mBlendingOptions.GetBlendEquationRgb();
+ mBlendingOptions.SetBlendEquation( rgbEquation, static_cast<BlendingEquation::Type>( blendingEquation ) );
+ SetBlendingOptionsMessage( GetEventThreadServices(), *mSceneObject, mBlendingOptions.GetBitmask() );
+ }
break;
}
case Dali::Material::Property::BLENDING_SRC_FACTOR_RGB:
{
- 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 );
+ int blendingFactor;
+ if( propertyValue.Get( blendingFactor ) )
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( static_cast<BlendingFactor::Type>( blendingFactor ),
+ destFactorRgb,
+ srcFactorAlpha,
+ destFactorAlpha );
+ }
break;
}
case Dali::Material::Property::BLENDING_DEST_FACTOR_RGB:
{
- 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 );
+ int blendingFactor;
+ if( propertyValue.Get( blendingFactor ) )
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ static_cast<BlendingFactor::Type>( blendingFactor ),
+ srcFactorAlpha,
+ destFactorAlpha );
+ }
break;
}
case Dali::Material::Property::BLENDING_SRC_FACTOR_ALPHA:
{
- 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 );
+ int blendingFactor;
+ if( propertyValue.Get( blendingFactor ) )
+ {
+ BlendingFactor::Type srcFactorRgb;
+ BlendingFactor::Type destFactorRgb;
+ BlendingFactor::Type srcFactorAlpha;
+ BlendingFactor::Type destFactorAlpha;
+ GetBlendFunc( srcFactorRgb, destFactorRgb, srcFactorAlpha, destFactorAlpha );
+ SetBlendFunc( srcFactorRgb,
+ destFactorRgb,
+ static_cast<BlendingFactor::Type>( blendingFactor ),
+ destFactorAlpha );
+ }
break;
}
case Dali::Material::Property::BLENDING_DEST_FACTOR_ALPHA:
{
- 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>()) );
+ int blendingFactor;
+ if( propertyValue.Get( blendingFactor ) )
+ {
+ 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>( blendingFactor ) );
+ }
break;
}
case Dali::Material::Property::BLEND_COLOR:
{
- SceneGraph::AnimatablePropertyMessage<Vector4>::Send( GetEventThreadServices(), mSceneObject, &mSceneObject->mBlendColor, &SceneGraph::AnimatableProperty<Vector4>::Bake, propertyValue.Get<Vector4>() );
+ Vector4 blendColor;
+ if( propertyValue.Get( blendColor ) )
+ {
+ SetBlendColor( blendColor );
+ }
break;
}
}
Property::Value Material::GetDefaultProperty( Property::Index index ) const
{
- BufferIndex bufferIndex = GetEventThreadServices().GetEventBufferIndex();
Property::Value value;
switch( index )
{
- case Dali::Material::Property::COLOR:
- {
- if( mSceneObject )
- {
- value = mSceneObject->mColor[bufferIndex];
- }
- break;
- }
case Dali::Material::Property::FACE_CULLING_MODE:
{
- if( mSceneObject )
- {
- value = mSceneObject->mFaceCullingMode[bufferIndex];
- }
+ value = mFaceCullingMode;
break;
}
case Dali::Material::Property::BLENDING_MODE:
{
- if( mSceneObject )
- {
- value = mSceneObject->mBlendingMode[bufferIndex];
- }
+ value = mBlendingMode;
break;
}
case Dali::Material::Property::BLEND_EQUATION_RGB:
}
case Dali::Material::Property::BLEND_COLOR:
{
- if( mSceneObject )
- {
- value = mSceneObject->mBlendColor[bufferIndex];
- }
+ value = mBlendColor;
break;
}
}
const SceneGraph::PropertyBase* Material::GetSceneObjectAnimatableProperty( Property::Index index ) const
{
- DALI_ASSERT_ALWAYS( IsPropertyAnimatable( index ) && "Property is not animatable" );
-
- const SceneGraph::PropertyBase* property = NULL;
-
- if( OnStage() )
- {
- property = MATERIAL_IMPL.GetRegisteredSceneGraphProperty( this,
- &Material::FindAnimatableProperty,
- &Material::FindCustomProperty,
- index );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- switch(index)
- {
- case Dali::Material::Property::COLOR:
- {
- property = &mSceneObject->mColor;
- break;
- }
- case Dali::Material::Property::BLEND_COLOR:
- {
- property = &mSceneObject->mBlendColor;
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( 0 && "Property is not animatable");
- break;
- }
- }
- }
- }
-
- return property;
+ PropertyMetadata* property = index >= PROPERTY_CUSTOM_START_INDEX ? static_cast<PropertyMetadata*>(FindCustomProperty( index )) : static_cast<PropertyMetadata*>(FindAnimatableProperty( index ));
+ DALI_ASSERT_ALWAYS( property && "Property index is invalid" );
+ return property->GetSceneGraphProperty();
}
const PropertyInputImpl* Material::GetSceneObjectInputProperty( Property::Index index ) const
{
- const PropertyInputImpl* property = NULL;
-
- if( OnStage() )
- {
- const SceneGraph::PropertyBase* baseProperty =
- MATERIAL_IMPL.GetRegisteredSceneGraphProperty( this,
- &Material::FindAnimatableProperty,
- &Material::FindCustomProperty,
- index );
- property = static_cast<const PropertyInputImpl*>( baseProperty );
-
- if( property == NULL && index < DEFAULT_PROPERTY_MAX_COUNT )
- {
- switch(index)
- {
- case Dali::Material::Property::COLOR:
- {
- property = &mSceneObject->mColor;
- break;
- }
- case Dali::Material::Property::FACE_CULLING_MODE:
- {
- property = &mSceneObject->mFaceCullingMode;
- break;
- }
- case Dali::Material::Property::BLEND_COLOR:
- {
- property = &mSceneObject->mBlendColor;
- break;
- }
- default:
- {
- DALI_ASSERT_ALWAYS( 0 && "Property cannot be a constraint input");
- break;
- }
- }
- }
- }
-
- return property;
+ return GetSceneObjectAnimatableProperty( index );
}
int Material::GetPropertyComponentIndex( Property::Index index ) const
Material::Material()
: mSceneObject( NULL ),
+ mShader( NULL ),
+ mTextures(),
+ mFaceCullingMode( Dali::Material::NONE ),
+ mBlendingMode( Dali::BlendingMode::AUTO ),
+ mBlendingOptions(), // initialises to defaults
+ mBlendColor( NULL ),
mOnStage( false )
{
}
Material::~Material()
{
+ delete mBlendColor;
if( EventThreadServices::IsCoreRunning() )
{
EventThreadServices& eventThreadServices = GetEventThreadServices();
* @copydoc Dali::Material::GetNumberOfTextures()
*/
size_t GetNumberOfTextures() const;
+
/**
* @copydoc Dali::Material::SetFaceCullingMode()
*/
void SetFaceCullingMode( Dali::Material::FaceCullingMode cullingMode );
/**
+ * @copydoc Dali::Material::GetFaceCullingMode()
+ */
+ Dali::Material::FaceCullingMode GetFaceCullingMode();
+
+ /**
* @copydoc Dali::Material::SetBlendMode()
*/
void SetBlendMode( BlendingMode::Type mode );
/**
* @copydoc Dali::Material::GetBlendColor()
*/
- const Vector4& GetBlendColor() const;
+ Vector4 GetBlendColor() const;
/**
* @brief Get the material scene object
Material( const Material& );
Material& operator=( const Material& );
-private: //data
+private: // Data
+
+ SceneGraph::Material* mSceneObject;
IntrusivePtr<Shader> mShader; ///< Connector that holds the shader used by this material
std::vector<Material::Texture> mTextures; ///<Vector of textures used by this material
- SceneGraph::Material* mSceneObject;
- BlendingMode::Type mBlendingMode; ///< Local store
- BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
+ Dali::Material::FaceCullingMode mFaceCullingMode; ///< Local copy of face culling mode
+ BlendingMode::Type mBlendingMode; ///< Local copy of blending mode
+ BlendingOptions mBlendingOptions; ///< Local copy of blending options bitmask
+ Vector4* mBlendColor; ///< Local copy of blend color, pointer only as its reraly used
bool mOnStage;
};
{
namespace Internal
{
+class BlendingOptions;
+
namespace SceneGraph
{
{
}
- virtual const Vector4& GetBlendColor( BufferIndex bufferIndex ) const = 0;
-
- /**
- * Get the RGB source factor
- * @return the RGB source factor
- */
- virtual BlendingFactor::Type GetBlendSrcFactorRgb( BufferIndex bufferIndex ) const = 0;
-
- /**
- * Get the Alpha source factor
- * @return the Alpha source factor
- */
- virtual BlendingFactor::Type GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const = 0;
-
/**
- * Get the RGB destination factor
- * @return the RGB destination factor
+ * Get the blend color
+ * @return blend color of NULL if blend color is not set
*/
- virtual BlendingFactor::Type GetBlendDestFactorRgb( BufferIndex bufferIndex ) const = 0;
+ virtual Vector4* GetBlendColor() const = 0;
/**
- * Get the Alpha destination factor
- * @return the Alpha destination factor
+ * Get the blending options
+ * @return the blending options
*/
- virtual BlendingFactor::Type GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const = 0;
-
- /**
- * Get the RGB blending equation
- * @return the RGB blending equation
- */
- virtual BlendingEquation::Type GetBlendEquationRgb( BufferIndex bufferIndex ) const = 0;
-
- /**
- * Get the Alpha blending equation
- * @return the Alpha blending equation
- */
- virtual BlendingEquation::Type GetBlendEquationAlpha( BufferIndex bufferIndex ) const = 0;
+ virtual const BlendingOptions& GetBlendingOptions() const = 0;
protected:
/**
};
} // namespace SceneGraph
+
} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_SCENE_GRAPH_MATERIAL_DATA_PROVIDER_H
}
}
-void ImageRenderer::DoSetBlending(Context& context, BufferIndex bufferIndex, bool blend )
+void ImageRenderer::DoSetBlending( Context& context )
{
- // Enables/disables blending mode.
- context.SetBlend( blend );
-
// Set the blend color
const Vector4* const customColor = mBlendingOptions.GetBlendColor();
if( customColor )
/**
* @copydoc Dali::Internal::SceneGraph::Renderer::DoSetBlending()
*/
- virtual void DoSetBlending( Context& context, BufferIndex bufferIndex, bool blend );
+ virtual void DoSetBlending( Context& context );
protected: // TextureObserver implementation
{
}
-void NewRenderer::DoSetBlending( Context& context, BufferIndex bufferIndex, bool blend )
+void NewRenderer::DoSetBlending( Context& context )
{
- context.SetBlend( blend );
- if( blend )
- {
- const SceneGraph::MaterialDataProvider& material = mRenderDataProvider->GetMaterial();
+ const SceneGraph::MaterialDataProvider& material = mRenderDataProvider->GetMaterial();
- context.SetCustomBlendColor( material.GetBlendColor( bufferIndex ) );
+ // Blend color is optional and rarely used
+ Vector4* blendColor = material.GetBlendColor();
+ if( blendColor )
+ {
+ context.SetCustomBlendColor( *blendColor );
+ }
- // Set blend source & destination factors
- context.BlendFuncSeparate( material.GetBlendSrcFactorRgb( bufferIndex ),
- material.GetBlendDestFactorRgb( bufferIndex ),
- material.GetBlendSrcFactorAlpha( bufferIndex ),
- material.GetBlendDestFactorAlpha( bufferIndex ) );
+ const BlendingOptions& blending = material.GetBlendingOptions();
+ // Set blend source & destination factors
+ context.BlendFuncSeparate( blending.GetBlendSrcFactorRgb(),
+ blending.GetBlendDestFactorRgb(),
+ blending.GetBlendSrcFactorAlpha(),
+ blending.GetBlendDestFactorAlpha() );
- // Set blend equations
- context.BlendEquationSeparate( material.GetBlendEquationRgb( bufferIndex ),
- material.GetBlendEquationAlpha( bufferIndex ) );
- }
+ // Set blend equations
+ context.BlendEquationSeparate( blending.GetBlendEquationRgb(),
+ blending.GetBlendEquationAlpha() );
}
void NewRenderer::DoRender( Context& context, SceneGraph::TextureCache& textureCache, const SceneGraph::NodeDataProvider& node, BufferIndex bufferIndex, Program& program, const Matrix& modelViewMatrix, const Matrix& viewMatrix )
/**
* @copydoc SceneGraph::Renderer::DoSetCullFaceMode
*/
- virtual void DoSetCullFaceMode(Context& context, BufferIndex bufferIndex );
+ virtual void DoSetCullFaceMode( Context& context, BufferIndex bufferIndex );
/**
* @copydoc SceneGraph::Renderer::DoSetBlending
*/
- virtual void DoSetBlending(Context& context, BufferIndex bufferIndex, bool blend );
+ virtual void DoSetBlending( Context& context );
/**
* @copydoc SceneGraph::Renderer::DoRender()
DoSetCullFaceMode( context, bufferIndex );
- DoSetBlending( context, bufferIndex, blend );
+ // Enable/disable blending
+ context.SetBlend( blend );
+ if( blend )
+ {
+ DoSetBlending( context );
+ }
// Ignore missing uniforms - custom shaders and flat color shaders don't have SAMPLER
// set projection and view matrix if program has not yet received them yet this frame
/**
* Called from Render prior to DoRender(). Default method to set CullFaceMode
- * @todo MESH_REWORK Remove after merge
+ * @param context to use
+ * @param bufferIndex to use
*/
virtual void DoSetCullFaceMode( Context& context, BufferIndex bufferIndex );
/**
* Called from Render prior to DoRender(). Default method to set blending options
- * @todo MESH_REWORK Remove after merge
+ * @param context to use
*/
- virtual void DoSetBlending( Context& context, BufferIndex bufferIndex, bool blend ) = 0;
+ virtual void DoSetBlending( Context& context ) = 0;
/**
* Called from Render; implemented in derived classes.
namespace SceneGraph
{
-namespace
-{
-const unsigned int DEFAULT_BLENDING_OPTIONS( BlendingOptions().GetBitmask() );
-}
-
Material::Material()
-: mColor( Color::WHITE ),
- mBlendColor( Color::TRANSPARENT ),
- mFaceCullingMode(Dali::Material::NONE),
- mBlendingMode(Dali::BlendingMode::AUTO),
- mBlendingOptions( DEFAULT_BLENDING_OPTIONS ),
- mShader(NULL),
- mBlendPolicy(OPAQUE)
+: mShader( NULL ),
+ mBlendColor( NULL ),
+ mSamplers(),
+ mTextureId(),
+ mUniformName(),
+ mIsFullyOpaque(),
+ mAffectsTransparency(),
+ mConnectionObservers(),
+ mFaceCullingMode( Dali::Material::NONE ),
+ mBlendingMode( Dali::BlendingMode::AUTO ),
+ mBlendingOptions(), // initializes to defaults
+ mBlendPolicy( OPAQUE )
{
// Observe own property-owner's uniform map
AddUniformMapObserver( *this );
Shader* Material::GetShader() const
{
- // @todo - Fix this - move shader setup to the Renderer connect to stage...
return mShader;
}
+void Material::SetFaceCullingMode( unsigned int faceCullingMode )
+{
+ mFaceCullingMode = static_cast< Dali::Material::FaceCullingMode >( faceCullingMode );
+}
+
+void Material::SetBlendingMode( unsigned int blendingMode )
+{
+ mBlendingMode = static_cast< BlendingMode::Type >( blendingMode );
+}
+
void Material::PrepareRender( BufferIndex bufferIndex )
{
mBlendPolicy = OPAQUE;
// @todo MESH_REWORK Add dirty flags to reduce processing.
- switch(mBlendingMode[bufferIndex])
+ switch( mBlendingMode )
{
case BlendingMode::OFF:
{
if( opaque )
{
- // Check the material color:
- opaque = ( mColor[ bufferIndex ].a >= FULLY_OPAQUE );
- }
-
- if( opaque )
- {
unsigned int opaqueCount=0;
unsigned int affectingCount=0;
size_t textureCount( GetTextureCount() );
}
}
-
Material::BlendPolicy Material::GetBlendPolicy() const
{
return mBlendPolicy;
}
-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
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendSrcFactorRgb();
-}
-
-BlendingFactor::Type Material::GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const
+void Material::SetBlendingOptions( unsigned int options )
{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendSrcFactorAlpha();
+ mBlendingOptions.SetBitmask( options );
}
-BlendingFactor::Type Material::GetBlendDestFactorRgb( BufferIndex bufferIndex ) const
+void Material::SetBlendColor( const Vector4& blendColor )
{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendDestFactorRgb();
-}
-
-BlendingFactor::Type Material::GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const
-{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendDestFactorAlpha();
+ if( mBlendColor )
+ {
+ *mBlendColor = blendColor;
+ }
+ else
+ {
+ mBlendColor = new Vector4( blendColor );
+ }
}
-BlendingEquation::Type Material::GetBlendEquationRgb( BufferIndex bufferIndex ) const
+Vector4* Material::GetBlendColor() const
{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendEquationRgb();
+ return mBlendColor;
}
-BlendingEquation::Type Material::GetBlendEquationAlpha( BufferIndex bufferIndex ) const
+const BlendingOptions& Material::GetBlendingOptions() const
{
- BlendingOptions blendingOptions;
- blendingOptions.SetBitmask( mBlendingOptions[ bufferIndex ] );
- return blendingOptions.GetBlendEquationAlpha();
+ return mBlendingOptions;
}
void Material::AddTexture( const std::string& name, ResourceId id, Render::Sampler* sampler )
mConnectionObservers.ConnectedUniformMapChanged();
}
-void Material::ResetDefaultProperties( BufferIndex updateBufferIndex )
-{
- mColor.ResetToBaseValue( updateBufferIndex );
- mBlendColor.ResetToBaseValue( updateBufferIndex );
- mFaceCullingMode.CopyPrevious( updateBufferIndex );
-
- mBlendingMode.CopyPrevious( updateBufferIndex );
- mBlendingOptions.CopyPrevious( updateBufferIndex );
-}
-
} // namespace SceneGraph
+
} // namespace Internal
+
} // namespace Dali
* limitations under the License.
*/
+// INTERNAL INCLUDES
+#include <dali/devel-api/rendering/material.h>
#include <dali/internal/common/buffer-index.h>
#include <dali/internal/common/blending-options.h>
#include <dali/internal/event/common/event-thread-services.h>
void SetShader( Shader* shader );
/**
+ * Get the shader effect of this material
+ * @return the shader effect;
+ */
+ Shader* GetShader() const;
+
+ /**
+ * Set the face culling mode
+ * @param[in] faceCullingMode to use
+ */
+ void SetFaceCullingMode( unsigned int faceCullingMode );
+
+ /**
+ * Set the blending mode
+ * @param[in] blendingMode to use
+ */
+ void SetBlendingMode( unsigned int blendingMode );
+
+ /**
* Prepare the material for rendering.
*
* Determine whether blending is enabled for this material, and store the result.
/**
* 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 );
+ void SetBlendingOptions( unsigned int options );
+
+ /**
+ * Set the blend color for blending operation
+ * @param blendColor to pass to GL
+ */
+ void SetBlendColor( const Vector4& blendColor );
/**
* Adds a new texture to be used by the material
* @param[in] index The index of the texture in the array of textures
* @param[in] uniformName The new uniform name
*/
- void SetTextureUniformName( size_t index, const std::string& uniformName);
+ void SetTextureUniformName( size_t index, const std::string& uniformName );
/**
* Establish if a given texture will affect the transparency of the object ( true by default )
/**
* @copydoc MaterialDataProvider::GetBlendColor
*/
- virtual const Vector4& GetBlendColor(BufferIndex bufferIndex) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendSrcFactorRgb
- */
- virtual BlendingFactor::Type GetBlendSrcFactorRgb(BufferIndex bufferIndex) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendSrcFactorAlpha
- */
- virtual BlendingFactor::Type GetBlendSrcFactorAlpha( BufferIndex bufferIndex ) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendDestFactorRgb
- */
- virtual BlendingFactor::Type GetBlendDestFactorRgb( BufferIndex bufferIndex ) const;
+ virtual Vector4* GetBlendColor() const;
/**
- * @copydoc MaterialDataProvider::GetBlendDestFactorAlpha
+ * @copydoc MaterialDataProvider::GetBlendingOptions
*/
- virtual BlendingFactor::Type GetBlendDestFactorAlpha( BufferIndex bufferIndex ) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendEquationRgb
- */
- virtual BlendingEquation::Type GetBlendEquationRgb( BufferIndex bufferIndex ) const;
-
- /**
- * @copydoc MaterialDataProvider::GetBlendEquationAlpha
- */
- virtual BlendingEquation::Type GetBlendEquationAlpha( BufferIndex bufferIndex ) const;
+ virtual const BlendingOptions& GetBlendingOptions() const;
public: // Implementation of ObjectOwnerContainer template methods
+
/**
* Connect the object to the scene graph
*
void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
public: // Implementation of ConnectionChangePropagator
+
/**
* @copydoc ConnectionChangePropagator::AddObserver
*/
void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer);
public:
- /**
- * Get the shader effect of this material
- * @return the shader effect;
- */
- Shader* GetShader() const;
/**
* Get the ResourceId of a texture used by the material
/**
* @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
*/
- virtual void ConnectedUniformMapChanged( );
+ virtual void ConnectedUniformMapChanged();
public: // PropertyOwner implementation
- /**
- * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
- */
- virtual void ResetDefaultProperties( BufferIndex updateBufferIndex );
void SetIsFullyOpaque( size_t index, bool isFullyOpaque )
{
mIsFullyOpaque[index] = isFullyOpaque;
}
-public: // Property data
- AnimatableProperty<Vector4> mColor;
- AnimatableProperty<Vector4> mBlendColor;
- DoubleBufferedProperty<int> mFaceCullingMode;
- DoubleBufferedProperty<int> mBlendingMode;
- DoubleBufferedProperty<int> mBlendingOptions;
+private: // Data
-private:
Shader* mShader;
- Vector<Render::Sampler*> mSamplers; // Not owned
- Vector<ResourceId> mTextureId;
- std::vector<std::string> mUniformName;
- Vector<bool> mIsFullyOpaque;
- Vector<bool> mAffectsTransparency;
+ Vector4* mBlendColor; // not double buffered as its not animateable and not frequently changed
+ Vector< Render::Sampler* > mSamplers; // Not owned
+ Vector< ResourceId > mTextureId;
+ std::vector< std::string > mUniformName;
+ Vector< bool > mIsFullyOpaque;
+ Vector< bool > mAffectsTransparency;
ConnectionChangePropagator mConnectionObservers;
+ Dali::Material::FaceCullingMode mFaceCullingMode; // not double buffered as its not animateable and not frequently changed
+ BlendingMode::Type mBlendingMode; // not double buffered as its not animateable and not frequently changed
+ BlendingOptions mBlendingOptions; // not double buffered as its not animateable and not frequently changed
BlendPolicy mBlendPolicy; ///< The blend policy as determined by PrepareRender
+
};
inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Material& material, Shader& shader )
new (slot) LocalType( &material, &Material::SetShader, &shader );
}
+inline void SetFaceCullingModeMessage( EventThreadServices& eventThreadServices, const Material& material, Dali::Material::FaceCullingMode faceCullingMode )
+{
+ typedef MessageValue1< Material, unsigned int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &material, &Material::SetFaceCullingMode, faceCullingMode );
+}
+
+inline void SetBlendingModeMessage( EventThreadServices& eventThreadServices, const Material& material, BlendingMode::Type blendingMode )
+{
+ typedef MessageValue1< Material, unsigned int > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &material, &Material::SetBlendingMode, blendingMode );
+}
+
inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Material& material, unsigned int options )
{
- typedef MessageDoubleBuffered1< Material, unsigned int > LocalType;
+ typedef MessageValue1< 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 );
}
+inline void SetBlendColorMessage( EventThreadServices& eventThreadServices, const Material& material, const Vector4& blendColor )
+{
+ typedef MessageValue1< Material, Vector4 > LocalType;
+
+ // Reserve some memory inside the message queue
+ unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
+
+ new (slot) LocalType( &material, &Material::SetBlendColor, blendColor );
+}
+
inline void AddTextureMessage( EventThreadServices& eventThreadServices, const Material& material, const std::string& uniformName, ResourceId id, Render::Sampler* sampler )
{
typedef MessageValue3< Material, std::string, ResourceId, Render::Sampler* > LocalType;
}
} // namespace SceneGraph
+
} // namespace Internal
+
} // namespace Dali
#endif // DALI_INTERNAL_SCENE_GRAPH_MATERIAL_H
{
/**
* @brief Blending mode.
- * @see Dali::RenderableActor::SetBlendMode() and Dali::RenderableActor::GetBlendMode()
*/
enum Type
{
OFF, ///< Blending is disabled.
- AUTO, ///< Blending is enabled if there is alpha channel.
+ AUTO, ///< Blending is enabled if there is alpha channel. This is the default mode.
ON ///< Blending is enabled.
};