Added test cases and fixed bugs 66/39566/2
authorDavid Steele <david.steele@partner.samsung.com>
Mon, 18 May 2015 19:04:04 +0000 (20:04 +0100)
committerDavid Steele <david.steele@partner.samsung.com>
Thu, 21 May 2015 15:26:00 +0000 (16:26 +0100)
Added test cases for property values on each property owner,
testing constraints and animations on these properties.

Checked that using the properties as uniform maps correctly
set the right uniform in the shader program.

Added tests for uniform mapping
 - checked the precedence of each object
 - checked the collection of uniform maps and types was correct

Change-Id: Iffc5ce9d94a2c14401bee8c568208dc7bdd91cf3

16 files changed:
automated-tests/src/dali/dali-test-suite-utils/dali-test-suite-utils.cpp
automated-tests/src/dali/dali-test-suite-utils/mesh-builder.cpp
automated-tests/src/dali/dali-test-suite-utils/mesh-builder.h
automated-tests/src/dali/utc-Dali-Geometry.cpp
automated-tests/src/dali/utc-Dali-Material.cpp
automated-tests/src/dali/utc-Dali-PropertyBuffer.cpp
automated-tests/src/dali/utc-Dali-Renderer.cpp
automated-tests/src/dali/utc-Dali-Sampler.cpp
automated-tests/src/dali/utc-Dali-Shader.cpp
dali/internal/event/common/property-buffer-impl.cpp
dali/internal/event/effects/material-impl.cpp
dali/internal/event/effects/shader-impl.cpp
dali/internal/event/geometry/geometry-impl.cpp
dali/internal/update/effects/scene-graph-material.cpp
dali/internal/update/manager/update-algorithms.cpp
dali/internal/update/manager/update-manager.cpp

index 938d585..11a6ecb 100644 (file)
@@ -84,10 +84,13 @@ void DALI_TEST_EQUALS( const Matrix3& matrix1, const Matrix3& matrix2, const cha
 
   for (int i=0;i<9;++i)
   {
-    equivalent &= (m1[i] != m2[i]);
+    if( m1[i] != m2[i] )
+    {
+      equivalent = false;
+    }
   }
 
-  if (!equivalent)
+  if( !equivalent )
   {
     fprintf(stderr, "%s, checking\n"
                "(%f, %f, %f)    (%f, %f, %f)\n"
index dacecc2..92d6ca6 100644 (file)
@@ -45,8 +45,7 @@ Material CreateMaterial(float opacity, Image image)
   return material;
 }
 
-
-Geometry CreateQuadGeometry()
+PropertyBuffer CreatePropertyBuffer()
 {
   Property::Map texturedQuadVertexFormat;
   texturedQuadVertexFormat["aPosition"] = Property::VECTOR2;
@@ -54,7 +53,17 @@ Geometry CreateQuadGeometry()
 
   PropertyBuffer vertexData = PropertyBuffer::New( PropertyBuffer::STATIC,
                                                    texturedQuadVertexFormat, 4 );
+  return vertexData;
+}
+
+Geometry CreateQuadGeometry(void)
+{
+  PropertyBuffer vertexData = CreatePropertyBuffer();
+  return CreateQuadGeometryFromBuffer( vertexData );
+}
 
+Geometry CreateQuadGeometryFromBuffer( PropertyBuffer vertexData )
+{
   const float halfQuadSize = .5f;
   struct TexturedQuadVertex { Vector2 position; Vector2 textureCoordinates; };
   TexturedQuadVertex texturedQuadVertexData[4] = {
index cdabbf5..528d87e 100644 (file)
@@ -25,6 +25,8 @@ namespace Dali
 Material CreateMaterial(float opacity);
 Material CreateMaterial(float opacity, Image image);
 Geometry CreateQuadGeometry();
+Geometry CreateQuadGeometryFromBuffer( PropertyBuffer vertexData );
+PropertyBuffer CreatePropertyBuffer();
 
 }
 
index cddb8b4..11963d7 100644 (file)
@@ -34,6 +34,12 @@ void geometry_test_cleanup(void)
 
 namespace
 {
+
+void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
+{
+  current.b = 0.0f;
+}
+
 }
 
 
@@ -76,3 +82,206 @@ int UtcDaliGeometryDownCast02(void)
   DALI_TEST_EQUALS( (bool)geometry, false, TEST_LOCATION );
   END_TEST;
 }
+
+
+int UtcDaliGeometryConstraint01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform geometry property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = geometry.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( geometry, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect no blue component in either buffer - yellow
+  DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+  application.Render(0);
+  DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+
+  geometry.RemoveConstraints();
+  geometry.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliGeometryConstraint02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map geometry property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = geometry.RegisterProperty( "fade-color", initialColor );
+  geometry.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( geometry, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+   // Expect no blue component in either buffer - yellow
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  application.Render(0);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  geometry.RemoveConstraints();
+  geometry.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+
+int UtcDaliGeometryAnimatedProperty01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform geometry property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = geometry.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( geometry, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+
+  DALI_TEST_EQUALS( geometry.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliGeometryAnimatedProperty02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map geometry property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = geometry.RegisterProperty( "fade-color", initialColor );
+  geometry.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( geometry, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
index d5dd995..09a5260 100644 (file)
@@ -22,6 +22,15 @@ using namespace Dali;
 
 #include <mesh-builder.h>
 
+namespace
+{
+void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
+{
+  current.b = 0.0f;
+}
+}
+
+
 void material_test_startup(void)
 {
   test_return_value = TET_UNDEF;
@@ -558,3 +567,206 @@ int UtcDaliMaterialSetBlendMode08(void)
 
   END_TEST;
 }
+
+
+int UtcDaliMaterialConstraint01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform shader property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = material.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( material, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect no blue component in either buffer - yellow
+  DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+  application.Render(0);
+  DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+
+  material.RemoveConstraints();
+  material.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliMaterialConstraint02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map material property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = material.RegisterProperty( "fade-color", initialColor );
+  material.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( material, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+   // Expect no blue component in either buffer - yellow
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  application.Render(0);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  material.RemoveConstraints();
+  material.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+
+int UtcDaliMaterialAnimatedProperty01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform material property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = material.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( material, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+
+  DALI_TEST_EQUALS( material.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliMaterialAnimatedProperty02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map material property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = material.RegisterProperty( "fade-color", initialColor );
+  material.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( material, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
index 7e69a5e..900d76e 100644 (file)
@@ -22,6 +22,14 @@ using namespace Dali;
 
 #include <mesh-builder.h>
 
+namespace
+{
+void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
+{
+  current.b = 0.0f;
+}
+}
+
 void propertyBuffer_test_startup(void)
 {
   test_return_value = TET_UNDEF;
@@ -82,6 +90,213 @@ int UtcDaliPropertyBufferDownCast02(void)
   END_TEST;
 }
 
+
+int UtcDaliPropertyBufferConstraint01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform propertyBuffer property can be constrained");
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer propertyBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( propertyBuffer, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect no blue component in either buffer - yellow
+  DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+  application.Render(0);
+  DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+
+  propertyBuffer.RemoveConstraints();
+  propertyBuffer.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPropertyBufferConstraint02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map propertyBuffer property can be constrained");
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer propertyBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
+  propertyBuffer.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( propertyBuffer, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+   // Expect no blue component in either buffer - yellow
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  application.Render(0);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  propertyBuffer.RemoveConstraints();
+  propertyBuffer.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+
+int UtcDaliPropertyBufferAnimatedProperty01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform propertyBuffer property can be animated");
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer propertyBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( propertyBuffer, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+
+  DALI_TEST_EQUALS( propertyBuffer.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliPropertyBufferAnimatedProperty02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map propertyBuffer property can be animated");
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer propertyBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(propertyBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = propertyBuffer.RegisterProperty( "fade-color", initialColor );
+  propertyBuffer.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( propertyBuffer, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
 int UtcDaliPropertyBufferSetData01(void)
 {
   TestApplication application;
index 6cec8b6..1f3932d 100644 (file)
@@ -22,6 +22,14 @@ using namespace Dali;
 
 #include <mesh-builder.h>
 
+namespace
+{
+void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
+{
+  current.b = 0.0f;
+}
+}
+
 void renderer_test_startup(void)
 {
   test_return_value = TET_UNDEF;
@@ -76,3 +84,887 @@ int UtcDaliRendererDownCast02(void)
   DALI_TEST_EQUALS( (bool)renderer, false, TEST_LOCATION );
   END_TEST;
 }
+
+
+int UtcDaliRendererConstraint01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform renderer property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = renderer.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect no blue component in either buffer - yellow
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+  application.Render(0);
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+
+  renderer.RemoveConstraints();
+  renderer.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliRendererConstraint02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map renderer property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = renderer.RegisterProperty( "fade-color", initialColor );
+  renderer.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( renderer, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+   // Expect no blue component in either buffer - yellow
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  application.Render(0);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  renderer.RemoveConstraints();
+  renderer.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+
+int UtcDaliRendererAnimatedProperty01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform renderer property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = renderer.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+
+  DALI_TEST_EQUALS( renderer.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliRendererAnimatedProperty02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map renderer property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = renderer.RegisterProperty( "fade-color", initialColor );
+  renderer.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( renderer, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+
+
+int UtcDaliRendererUniformMapPrecendence01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform map precedence is applied properly");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Property::Index rendererFadeColorIndex = renderer.RegisterProperty( "fade-color-a", Color::RED );
+  renderer.AddUniformMapping( rendererFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index actorFadeColorIndex = actor.RegisterProperty( "fade-color-b", Color::GREEN );
+  actor.AddUniformMapping( actorFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index materialFadeColorIndex = material.RegisterProperty( "fade-color-c", Color::BLUE );
+  material.AddUniformMapping( materialFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index samplerFadeColorIndex = sampler.RegisterProperty( "fade-color-d", Color::CYAN );
+  sampler.AddUniformMapping( samplerFadeColorIndex, std::string("uFadeColor") );
+  Property::Index shaderFadeColorIndex = shader.RegisterProperty( "fade-color-e", Color::MAGENTA );
+  shader.AddUniformMapping( shaderFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "fade-color-f", Color::YELLOW );
+  geometry.AddUniformMapping( geometryFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color-g", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uFadeColor") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that the renderer's fade color property is accessed
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
+
+  // Animate material's fade color property. Should be no change to uniform
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Color::WHITE);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( material, materialFadeColorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::RED, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliRendererUniformMapPrecendence02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform map precedence is applied properly");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  // Don't add property / uniform map to renderer
+
+  Property::Index actorFadeColorIndex = actor.RegisterProperty( "fade-color-b", Color::GREEN );
+  actor.AddUniformMapping( actorFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index materialFadeColorIndex = material.RegisterProperty( "fade-color-c", Color::BLUE );
+  material.AddUniformMapping( materialFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index samplerFadeColorIndex = sampler.RegisterProperty( "fade-color-d", Color::CYAN );
+  sampler.AddUniformMapping( samplerFadeColorIndex, std::string("uFadeColor") );
+  Property::Index shaderFadeColorIndex = shader.RegisterProperty( "fade-color-e", Color::MAGENTA );
+  shader.AddUniformMapping( shaderFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "fade-color-f", Color::YELLOW );
+  geometry.AddUniformMapping( geometryFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color-g", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uFadeColor") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that the actor's fade color property is accessed
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
+
+  // Animate material's fade color property. Should be no change to uniform
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Color::WHITE);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( material, materialFadeColorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::GREEN, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+int UtcDaliRendererUniformMapPrecendence03(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform map precedence is applied properly");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  // Don't add property / uniform map to renderer or actor
+
+  Property::Index materialFadeColorIndex = material.RegisterProperty( "fade-color-c", Color::BLUE );
+  material.AddUniformMapping( materialFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index samplerFadeColorIndex = sampler.RegisterProperty( "fade-color-d", Color::CYAN );
+  sampler.AddUniformMapping( samplerFadeColorIndex, std::string("uFadeColor") );
+  Property::Index shaderFadeColorIndex = shader.RegisterProperty( "fade-color-e", Color::MAGENTA );
+  shader.AddUniformMapping( shaderFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "fade-color-f", Color::YELLOW );
+  geometry.AddUniformMapping( geometryFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color-g", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uFadeColor") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that the material's fade color property is accessed
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
+
+  // Animate geometry's fade color property. Should be no change to uniform
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Color::WHITE);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( geometry, geometryFadeColorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::BLUE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+int UtcDaliRendererUniformMapPrecendence04(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform map precedence is applied properly");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  // Don't add property / uniform map to renderer/actor/material
+
+  Property::Index samplerFadeColorIndex = sampler.RegisterProperty( "fade-color-d", Color::CYAN );
+  sampler.AddUniformMapping( samplerFadeColorIndex, std::string("uFadeColor") );
+  Property::Index shaderFadeColorIndex = shader.RegisterProperty( "fade-color-e", Color::MAGENTA );
+  shader.AddUniformMapping( shaderFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "fade-color-f", Color::YELLOW );
+  geometry.AddUniformMapping( geometryFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color-g", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uFadeColor") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that the sampler's fade color property is accessed
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
+
+  // Animate geometry's fade color property. Should be no change to uniform
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Color::WHITE);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( geometry, geometryFadeColorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::CYAN, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliRendererUniformMapPrecendence05(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform map precedence is applied properly");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  // Don't add property / uniform map to renderer/actor/material/sampler
+
+  Property::Index shaderFadeColorIndex = shader.RegisterProperty( "fade-color-e", Color::MAGENTA );
+  shader.AddUniformMapping( shaderFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "fade-color-f", Color::YELLOW );
+  geometry.AddUniformMapping( geometryFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color-g", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uFadeColor") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that the shader's fade color property is accessed
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
+
+  // Animate geometry's fade color property. Should be no change to uniform
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Color::WHITE);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( geometry, geometryFadeColorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::MAGENTA, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliRendererUniformMapPrecendence06(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform map precedence is applied properly");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  // Don't add property / uniform map to renderer/actor/material/sampler/shader
+
+  Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "fade-color-f", Color::YELLOW );
+  geometry.AddUniformMapping( geometryFadeColorIndex, std::string("uFadeColor") );
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color-g", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uFadeColor") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that the geometry's fade color property is accessed
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  // Animate vertex buffer's fade color property. Should be no change to uniform
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Color::WHITE);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( vertexBuffer, vertexFadeColorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliRendererUniformMapPrecendence07(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform map precedence is applied properly");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  // Don't add property / uniform map to renderer/actor/material/sampler/shader/geometry
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color-g", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that the vertex buffer's fade color property is accessed
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::BLACK, TEST_LOCATION );
+
+  // Animate vertex buffer's fade color property. Should change the uniform
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, Color::WHITE);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( vertexBuffer, vertexFadeColorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE*0.5f, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+int UtcDaliRendererUniformMapMultipleUniforms01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform maps are collected from all objects (same type)");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Property::Index rendererFadeColorIndex = renderer.RegisterProperty( "fade-color", Color::RED );
+  renderer.AddUniformMapping( rendererFadeColorIndex, std::string("uUniform1") );
+
+  Property::Index actorFadeColorIndex = actor.RegisterProperty( "fade-color", Color::GREEN );
+  actor.AddUniformMapping( actorFadeColorIndex, std::string("uUniform2") );
+
+  Property::Index materialFadeColorIndex = material.RegisterProperty( "fade-color", Color::BLUE );
+  material.AddUniformMapping( materialFadeColorIndex, std::string("uUniform3") );
+
+  Property::Index samplerFadeColorIndex = sampler.RegisterProperty( "fade-color", Color::CYAN );
+  sampler.AddUniformMapping( samplerFadeColorIndex, std::string("uUniform4") );
+  Property::Index shaderFadeColorIndex = shader.RegisterProperty( "fade-color", Color::MAGENTA );
+  shader.AddUniformMapping( shaderFadeColorIndex, std::string("uUniform5") );
+
+  Property::Index geometryFadeColorIndex = geometry.RegisterProperty( "fade-color", Color::YELLOW );
+  geometry.AddUniformMapping( geometryFadeColorIndex, std::string("uUniform6") );
+
+  Property::Index vertexFadeColorIndex = vertexBuffer.RegisterProperty( "fade-color", Color::BLACK );
+  vertexBuffer.AddUniformMapping( vertexFadeColorIndex, std::string("uUniform7") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that each of the object's uniforms are set
+  Vector4 uniform1Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
+  DALI_TEST_EQUALS( uniform1Value, Color::RED, TEST_LOCATION );
+
+  Vector4 uniform2Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform2", uniform2Value ) );
+  DALI_TEST_EQUALS( uniform2Value, Color::GREEN, TEST_LOCATION );
+
+  Vector4 uniform3Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform3", uniform3Value ) );
+  DALI_TEST_EQUALS( uniform3Value, Color::BLUE, TEST_LOCATION );
+
+  Vector4 uniform4Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform4", uniform4Value ) );
+  DALI_TEST_EQUALS( uniform4Value, Color::CYAN, TEST_LOCATION );
+
+  Vector4 uniform5Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform5", uniform5Value ) );
+  DALI_TEST_EQUALS( uniform5Value, Color::MAGENTA, TEST_LOCATION );
+
+  Vector4 uniform6Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform6", uniform6Value ) );
+  DALI_TEST_EQUALS( uniform6Value, Color::YELLOW, TEST_LOCATION );
+
+  Vector4 uniform7Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform7", uniform7Value ) );
+  DALI_TEST_EQUALS( uniform7Value, Color::BLACK, TEST_LOCATION );
+
+
+  END_TEST;
+}
+
+
+int UtcDaliRendererUniformMapMultipleUniforms02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test the uniform maps are collected from all objects (different types)");
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Shader shader = Shader::New("VertexSource", "FragmentSource");
+  Material material = Material::New( shader );
+  material.AddSampler( sampler );
+  material.SetProperty(Material::Property::COLOR, Color::WHITE);
+
+  PropertyBuffer vertexBuffer = CreatePropertyBuffer();
+  Geometry geometry = CreateQuadGeometryFromBuffer(vertexBuffer);
+  Renderer renderer = Renderer::New( geometry, material );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Property::Value value1(Color::RED);
+  Property::Index rendererIndex = renderer.RegisterProperty( "fade-color", value1 );
+  renderer.AddUniformMapping( rendererIndex, std::string("uUniform1") );
+
+  Property::Value value2(1.0f);
+  Property::Index actorIndex = actor.RegisterProperty( "fade-progress", value2 );
+  actor.AddUniformMapping( actorIndex, std::string("uUniform2") );
+
+  Property::Value value3(Vector3(0.5f, 0.5f, 1.0f));
+  Property::Index materialIndex = material.RegisterProperty( "fade-position", value3);
+  material.AddUniformMapping( materialIndex, std::string("uUniform3") );
+
+  Property::Value value4(Vector2(0.5f, 1.0f));
+  Property::Index samplerIndex = sampler.RegisterProperty( "fade-uv", value4 );
+  sampler.AddUniformMapping( samplerIndex, std::string("uUniform4") );
+
+  Property::Value value5(Matrix3::IDENTITY);
+  Property::Index shaderIndex = shader.RegisterProperty( "a-normal-matrix", value5 );
+  shader.AddUniformMapping( shaderIndex, std::string("uUniform5") );
+
+  Property::Value value6(Matrix::IDENTITY);
+  Property::Index geometryIndex = geometry.RegisterProperty( "a-world-matrix", value6 );
+  geometry.AddUniformMapping( geometryIndex, std::string("uUniform6") );
+
+  Property::Value value7(7);
+  Property::Index vertexIndex = vertexBuffer.RegisterProperty( "fade-color", value7 );
+  vertexBuffer.AddUniformMapping( vertexIndex, std::string("uUniform7") );
+
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect that each of the object's uniforms are set
+  Vector4 uniform1Value(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uUniform1", uniform1Value ) );
+  DALI_TEST_EQUALS( uniform1Value, value1.Get<Vector4>(), TEST_LOCATION );
+
+  float uniform2Value(0.0f);
+  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uUniform2", uniform2Value ) );
+  DALI_TEST_EQUALS( uniform2Value, value2.Get<float>(), TEST_LOCATION );
+
+  Vector3 uniform3Value(Vector3::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector3>( "uUniform3", uniform3Value ) );
+  DALI_TEST_EQUALS( uniform3Value, value3.Get<Vector3>(), TEST_LOCATION );
+
+  Vector2 uniform4Value(Vector2::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector2>( "uUniform4", uniform4Value ) );
+  DALI_TEST_EQUALS( uniform4Value, value4.Get<Vector2>(), TEST_LOCATION );
+
+  Matrix3 uniform5Value;
+  DALI_TEST_CHECK( gl.GetUniformValue<Matrix3>( "uUniform5", uniform5Value ) );
+  DALI_TEST_EQUALS( uniform5Value, value5.Get<Matrix3>(), TEST_LOCATION );
+
+  Matrix uniform6Value;
+  DALI_TEST_CHECK( gl.GetUniformValue<Matrix>( "uUniform6", uniform6Value ) );
+  DALI_TEST_EQUALS( uniform6Value, value6.Get<Matrix>(), TEST_LOCATION );
+
+  int uniform7Value = 0;
+  DALI_TEST_CHECK( gl.GetUniformValue<int>( "uUniform7", uniform7Value ) );
+  DALI_TEST_EQUALS( uniform7Value, value7.Get<int>(), TEST_LOCATION );
+
+  END_TEST;
+}
index 2ff8194..09b45eb 100644 (file)
@@ -145,3 +145,56 @@ int UtcDaliSamplerSetUniformName02(void)
 
   END_TEST;
 }
+
+
+int UtcDaliSamplerUniformMap01(void)
+{
+  TestApplication application;
+
+  Image image = BufferImage::New( 64, 64, Pixel::RGBA8888 );
+  Sampler sampler = Sampler::New(image, "sTexture");
+  sampler.SetUniformName( "sEffectTexture" );
+
+  Material material = CreateMaterial(1.0f);
+  material.AddSampler( sampler );
+
+  Geometry geometry = CreateQuadGeometry();
+  Renderer renderer = Renderer::New( geometry, material );
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetParentOrigin( ParentOrigin::CENTER );
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add( actor );
+
+  float initialValue = 1.0f;
+  Property::Index widthClampIndex = sampler.RegisterProperty("width-clamp", initialValue );
+  sampler.AddUniformMapping( widthClampIndex, std::string("uWidthClamp") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render();
+
+  float actualValue=0.0f;
+  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uWidthClamp", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialValue, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, 0.0f);
+  keyFrames.Add(1.0f, 640.0f);
+  animation.AnimateBetween( Property( sampler, widthClampIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render( 500 );
+
+  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uWidthClamp", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, 320.0f, TEST_LOCATION );
+
+  application.Render( 500 );
+  DALI_TEST_CHECK( gl.GetUniformValue<float>( "uWidthClamp", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, 640.0f, TEST_LOCATION );
+
+  END_TEST;
+}
index dc82a47..2a9c404 100644 (file)
@@ -20,6 +20,7 @@
 #include <stdlib.h>
 #include <dali/public-api/dali-core.h>
 #include <dali-test-suite-utils.h>
+#include <mesh-builder.h>
 
 using namespace Dali;
 
@@ -44,6 +45,13 @@ static const char* FragmentSource =
 "This is a custom fragment shader\n"
 "made on purpose to look nothing like a normal fragment shader inside dali\n";
 
+
+void TestConstraintNoBlue( Vector4& current, const PropertyInputContainer& inputs )
+{
+  current.b = 0.0f;
+}
+
+
 } // anon namespace
 
 
@@ -86,3 +94,205 @@ int UtcDaliShaderDownCast02(void)
   DALI_TEST_EQUALS( (bool)shader, false, TEST_LOCATION );
   END_TEST;
 }
+
+int UtcDaliShaderConstraint01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform shader property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = shader.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( shader.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( shader, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+  // Expect no blue component in either buffer - yellow
+  DALI_TEST_EQUALS( shader.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+  application.Render(0);
+  DALI_TEST_EQUALS( shader.GetProperty<Vector4>(colorIndex), Color::YELLOW, TEST_LOCATION );
+
+  shader.RemoveConstraints();
+  shader.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( shader.GetProperty<Vector4>(colorIndex), Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliShaderConstraint02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map shader property can be constrained");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = shader.RegisterProperty( "fade-color", initialColor );
+  shader.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  // Apply constraint
+  Constraint constraint = Constraint::New<Vector4>( shader, colorIndex, TestConstraintNoBlue );
+  constraint.Apply();
+  application.SendNotification();
+  application.Render(0);
+
+   // Expect no blue component in either buffer - yellow
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  application.Render(0);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::YELLOW, TEST_LOCATION );
+
+  shader.RemoveConstraints();
+  shader.SetProperty(colorIndex, Color::WHITE );
+  application.SendNotification();
+  application.Render(0);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE, TEST_LOCATION );
+
+  END_TEST;
+}
+
+
+
+int UtcDaliShaderAnimatedProperty01(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a non-uniform shader property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = shader.RegisterProperty( "fade-color", initialColor );
+
+  application.SendNotification();
+  application.Render(0);
+  DALI_TEST_EQUALS( shader.GetProperty<Vector4>(colorIndex), initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( shader, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_EQUALS( shader.GetProperty<Vector4>(colorIndex), Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+
+  DALI_TEST_EQUALS( shader.GetProperty<Vector4>(colorIndex), Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
+
+int UtcDaliShaderAnimatedProperty02(void)
+{
+  TestApplication application;
+
+  tet_infoline("Test that a uniform map shader property can be animated");
+
+  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 );
+
+  Actor actor = Actor::New();
+  actor.AddRenderer(renderer);
+  actor.SetSize(400, 400);
+  Stage::GetCurrent().Add(actor);
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 initialColor = Color::WHITE;
+  Property::Index colorIndex = shader.RegisterProperty( "fade-color", initialColor );
+  shader.AddUniformMapping( colorIndex, std::string("uFadeColor") );
+
+  TestGlAbstraction& gl = application.GetGlAbstraction();
+
+  application.SendNotification();
+  application.Render(0);
+
+  Vector4 actualValue(Vector4::ZERO);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, initialColor, TEST_LOCATION );
+
+  Animation  animation = Animation::New(1.0f);
+  KeyFrames keyFrames = KeyFrames::New();
+  keyFrames.Add(0.0f, initialColor);
+  keyFrames.Add(1.0f, Color::TRANSPARENT);
+  animation.AnimateBetween( Property( shader, colorIndex ), keyFrames );
+  animation.Play();
+
+  application.SendNotification();
+  application.Render(500);
+
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::WHITE * 0.5f, TEST_LOCATION );
+
+  application.Render(500);
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uFadeColor", actualValue ) );
+  DALI_TEST_EQUALS( actualValue, Color::TRANSPARENT, TEST_LOCATION );
+
+  END_TEST;
+}
index d931404..759fb1d 100644 (file)
@@ -359,7 +359,7 @@ const PropertyInputImpl* PropertyBuffer::GetSceneObjectInputProperty( Property::
 
 int PropertyBuffer::GetPropertyComponentIndex( Property::Index index ) const
 {
-  return PROPERTY_BUFFER_IMPL.GetPropertyComponentIndex( index );
+  return Property::INVALID_COMPONENT_INDEX;
 }
 
 bool PropertyBuffer::OnStage() const
index 51a2841..ecfd1fd 100644 (file)
@@ -510,6 +510,7 @@ const PropertyInputImpl* Material::GetSceneObjectInputProperty( Property::Index
 
 int Material::GetPropertyComponentIndex( Property::Index index ) const
 {
+  // @todo MESH_REWORK - Change this if component properties are added for color/blend-color
   return Property::INVALID_COMPONENT_INDEX;
 }
 
@@ -529,6 +530,7 @@ void Material::Connect()
   {
     it->OnStageConnect();
   }
+  mShaderConnector.OnStageConnect();
 }
 
 void Material::Disconnect()
@@ -542,6 +544,7 @@ void Material::Disconnect()
   {
     it->OnStageDisconnect();
   }
+  mShaderConnector.OnStageDisconnect();
 }
 
 Material::Material()
index ba3fb69..c6b49c6 100644 (file)
@@ -215,7 +215,7 @@ const PropertyInputImpl* Shader::GetSceneObjectInputProperty( Property::Index in
 
 int Shader::GetPropertyComponentIndex( Property::Index index ) const
 {
-  return SHADER_IMPL.GetPropertyComponentIndex( index );
+  return Property::INVALID_COMPONENT_INDEX;
 }
 
 bool Shader::OnStage() const
index 7e991f9..902ef15 100644 (file)
@@ -347,7 +347,8 @@ const PropertyInputImpl* Geometry::GetSceneObjectInputProperty( Property::Index
 
 int Geometry::GetPropertyComponentIndex( Property::Index index ) const
 {
-  return GEOMETRY_IMPL.GetPropertyComponentIndex( index );
+  // @todo MESH_REWORK - Change this if component properties are added for center/half-extent
+  return Property::INVALID_COMPONENT_INDEX;
 }
 
 bool Geometry::OnStage() const
index fd22706..6db9fe0 100644 (file)
@@ -58,6 +58,8 @@ Material::~Material()
 void Material::SetShader( Shader* shader )
 {
   mShader = shader;
+  mShader->AddUniformMapObserver( *this );
+
   // Inform NewRenderer about this shader: (Will force a re-load of the
   // shader from the data providers)
   mConnectionObservers.ConnectionsChanged(*this);
index 0afb73f..6a2d8ed 100644 (file)
@@ -81,6 +81,20 @@ void ConstrainNodes( Node& node, BufferIndex updateBufferIndex )
 {
   ConstrainPropertyOwner( node, updateBufferIndex );
 
+  if( node.HasAttachment() )
+  {
+    // @todo MESH_REWORK Remove dynamic cast.
+    // (Or, if RendererAttachment split into RendererPropertyOwner(?),
+    // do as separate pass as per other mesh objects - see also
+    // UpdateManager::ResetNodeProperty())
+    NodeAttachment& attachment = node.GetAttachment();
+    PropertyOwner* propertyOwner = dynamic_cast< PropertyOwner* >( &attachment );
+    if( propertyOwner != NULL )
+    {
+      ConstrainPropertyOwner( *propertyOwner, updateBufferIndex );
+    }
+  }
+
   /**
    *  Constrain the children next
    */
index 37f0827..d564481 100644 (file)
@@ -698,7 +698,7 @@ void UpdateManager::ResetNodeProperty( Node& node )
   node.ResetToBaseValues( bufferIndex );
 
   // @todo MESH_REWORK Only perform this step for RendererAttachments - consider
-  // storing them again? Split out to separate scene graph object owned by UpdateManager
+  // storing them again? Split out to separate scene graph object (called e.g. RendererPropertyOwner) owned by UpdateManager
   // It is after all, a property owner, and always requires resetting...
   // The depth index should not be an animatable property... and probably not even
   // a constraint input? (Double buffering will slow down the sort algorithm slightly)