Remove uniform mapping. 52/40852/2
authorFrancisco Santos <f1.santos@samsung.com>
Tue, 9 Jun 2015 17:55:11 +0000 (18:55 +0100)
committerFrancisco Santos <f1.santos@samsung.com>
Wed, 10 Jun 2015 16:57:26 +0000 (17:57 +0100)
Change-Id: If347a572c3bb51192234317831509f1ada66e595

automated-tests/src/dali-toolkit/utc-Dali-BubbleEmitter.cpp
dali-toolkit/internal/controls/bubble-effect/bubble-actor.cpp
dali-toolkit/internal/controls/bubble-effect/bubble-effect.h
dali-toolkit/internal/controls/scrollable/bouncing-effect-actor.cpp
dali-toolkit/public-api/controls/control-impl.cpp

index db8a9df..bd4ae02 100644 (file)
@@ -325,8 +325,8 @@ int UtcDaliBubbleEmitterEmitBubble(void)
   Stage::GetCurrent().Add( root );
   DALI_TEST_CHECK( bubbleMesh );
 
   Stage::GetCurrent().Add( root );
   DALI_TEST_CHECK( bubbleMesh );
 
-  Property::Index propertyIndex0 = bubbleMesh.GetPropertyIndex( "percentage-0" );
-  Property::Index propertyIndex1 = bubbleMesh.GetPropertyIndex( "percentage-1" );
+  Property::Index propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" );
+  Property::Index propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" );
   float value0, value1;
 
   Animation animation = Animation::New( 0.5f );
   float value0, value1;
 
   Animation animation = Animation::New( 0.5f );
@@ -340,8 +340,8 @@ int UtcDaliBubbleEmitterEmitBubble(void)
   animation.Play();
 
   Wait(application, 300);
   animation.Play();
 
   Wait(application, 300);
-  propertyIndex0 = bubbleMesh.GetPropertyIndex( "percentage-0" );
-  propertyIndex1 = bubbleMesh.GetPropertyIndex( "percentage-1" );
+  propertyIndex0 = bubbleMesh.GetPropertyIndex( "uPercentage[0]" );
+  propertyIndex1 = bubbleMesh.GetPropertyIndex( "uPercentage[1]" );
   (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 );
   (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 );
   DALI_TEST_CHECK( value0 >= 0.6f );
   (bubbleMesh.GetProperty(propertyIndex0)).Get( value0 );
   (bubbleMesh.GetProperty(propertyIndex1)).Get( value1 );
   DALI_TEST_CHECK( value0 >= 0.6f );
@@ -382,7 +382,7 @@ int UtcDaliBubbleEmitterRestore(void)
   DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
   DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
 
   DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
   DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
 
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartAndEndPos[0]", startEndPosValue ) );
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
   DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
   DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
 
   DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
   DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
 
@@ -393,7 +393,7 @@ int UtcDaliBubbleEmitterRestore(void)
   DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
   DALI_TEST_CHECK( percentageValue < 0.5f && percentageValue >= 0.4);
 
   DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
   DALI_TEST_CHECK( percentageValue < 0.5f && percentageValue >= 0.4);
 
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartAndEndPos[0]", startEndPosValue ) );
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
   DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
   DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
 
   DALI_TEST_EQUALS( startEndPosValue.x, 40.f, TEST_LOCATION );
   DALI_TEST_EQUALS( startEndPosValue.y, 40.f, TEST_LOCATION );
 
@@ -404,7 +404,7 @@ int UtcDaliBubbleEmitterRestore(void)
   DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
   DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
 
   DALI_TEST_CHECK( gl.GetUniformValue<float>( "uPercentage[0]", percentageValue ) );
   DALI_TEST_EQUALS( percentageValue, 0.f, TEST_LOCATION );
 
-  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartAndEndPos[0]", startEndPosValue ) );
+  DALI_TEST_CHECK( gl.GetUniformValue<Vector4>( "uStartEndPosition[0]", startEndPosValue ) );
   DALI_TEST_EQUALS( startEndPosValue,  Vector4::ZERO, TEST_LOCATION );
   END_TEST;
 }
   DALI_TEST_EQUALS( startEndPosValue,  Vector4::ZERO, TEST_LOCATION );
   END_TEST;
 }
index d3b0563..50df6af 100644 (file)
 
 // INTERNAL INCLUDES
 
 
 // INTERNAL INCLUDES
 
-namespace
-{
-
-/**
- * Register a property and map it as uniform.
- * @param[in] handle The handle to register new property.
- * @param[in] propertyName The name of the property.
- * @param[in] unifoemName The name of the uniform.
- * @param[in] value The initial value of the property.
- * @return The index of theproperty
- */
-Dali::Property::Index RegisterUniform( Dali::Handle& handle,
-                                       const std::string& propertyName,
-                                       const std::string& uniformName,
-                                       Dali::Property::Value value)
-{
-  Dali::Property::Index propertyIndex = handle.RegisterProperty( propertyName, value );
-  handle.AddUniformMapping( propertyIndex, uniformName );
-
-  return propertyIndex;
-}
-
-}// end LOCAL_STUFF
-
 namespace Dali
 {
 
 namespace Dali
 {
 
@@ -80,23 +56,23 @@ void BubbleActor::MakeRenderable( Geometry geometry, Material material  )
   mActor.SetParentOrigin(ParentOrigin::TOP_LEFT);
 
   // register uniforms
   mActor.SetParentOrigin(ParentOrigin::TOP_LEFT);
 
   // register uniforms
-  mIndexGravity = RegisterUniform( mActor, "gravity", "uGravity", 50.f );
-  mIndexDynamicScale = RegisterUniform( mActor, "dynamic-scale", "uDynamicScale", 1.f );
+  mIndexGravity = mActor.RegisterProperty( "uGravity", 50.f );
+  mIndexDynamicScale = mActor.RegisterProperty( "uDynamicScale", 1.f );
 
 
-  mIndexInvertedMovementArea = RegisterUniform( mActor, "inverted-movement-area", "uInvertedMovementArea", Vector2(1.f,1.f) / mMovementArea );
+  mIndexInvertedMovementArea = mActor.RegisterProperty( "uInvertedMovementArea", Vector2(1.f,1.f) / mMovementArea );
 
   srand(time(NULL));
   mIndicesOffset.resize(9);
   int offset = mMovementArea.Length() / 10.f;
 
   srand(time(NULL));
   mIndicesOffset.resize(9);
   int offset = mMovementArea.Length() / 10.f;
-  mIndicesOffset[0] = RegisterUniform(mActor, "offset-0", "offset[0]", Vector2(0.f,0.f));
-  mIndicesOffset[1] = RegisterUniform(mActor, "offset-1", "offset[1]", Vector2(rand()%offset,rand()%offset) );
-  mIndicesOffset[2] = RegisterUniform(mActor, "offset-2", "offset[2]", Vector2(rand()%offset,-rand()%offset) );
-  mIndicesOffset[3] = RegisterUniform(mActor, "offset-3", "offset[3]", Vector2(-rand()%offset,rand()%offset) );
-  mIndicesOffset[4] = RegisterUniform(mActor, "offset-4", "offset[4]", Vector2(-rand()%offset,-rand()%offset) );
-  mIndicesOffset[5] = RegisterUniform(mActor, "offset-5", "offset[5]", Vector2(rand()%offset,0.f));
-  mIndicesOffset[6] = RegisterUniform(mActor, "offset-6", "offset[6]", Vector2(-rand()%offset,0.f));
-  mIndicesOffset[7] = RegisterUniform(mActor, "offset-7", "offset[7]", Vector2(0.f,rand()%offset));
-  mIndicesOffset[8] = RegisterUniform(mActor, "offset-8", "offset[8]", Vector2(0.f,-rand()%offset));
+  mIndicesOffset[0] = mActor.RegisterProperty( "uOffset[0]", Vector2(0.f,0.f));
+  mIndicesOffset[1] = mActor.RegisterProperty( "uOffset[1]", Vector2(rand()%offset,rand()%offset) );
+  mIndicesOffset[2] = mActor.RegisterProperty( "uOffset[2]", Vector2(rand()%offset,-rand()%offset) );
+  mIndicesOffset[3] = mActor.RegisterProperty( "uOffset[3]", Vector2(-rand()%offset,rand()%offset) );
+  mIndicesOffset[4] = mActor.RegisterProperty( "uOffset[4]", Vector2(-rand()%offset,-rand()%offset) );
+  mIndicesOffset[5] = mActor.RegisterProperty( "uOffset[5]", Vector2(rand()%offset,0.f));
+  mIndicesOffset[6] = mActor.RegisterProperty( "uOffset[6]", Vector2(-rand()%offset,0.f));
+  mIndicesOffset[7] = mActor.RegisterProperty( "uOffset[7]", Vector2(0.f,rand()%offset));
+  mIndicesOffset[8] = mActor.RegisterProperty( "uOffset[8]", Vector2(0.f,-rand()%offset));
 
   Vector4 zeroVector;
   mIndiceStartEndPos.resize( mNumBubble );
 
   Vector4 zeroVector;
   mIndiceStartEndPos.resize( mNumBubble );
@@ -104,18 +80,12 @@ void BubbleActor::MakeRenderable( Geometry geometry, Material material  )
   for( unsigned int i=0; i<mNumBubble; i++ )
   {
     std::ostringstream ossProperty;
   for( unsigned int i=0; i<mNumBubble; i++ )
   {
     std::ostringstream ossProperty;
-    ossProperty<< "start-end-position-"<< i;
-
-    std::ostringstream ossUniform;
-    ossUniform<< "uStartAndEndPos["<< i << "]";
-    mIndiceStartEndPos[i] = RegisterUniform( mActor, ossProperty.str(), ossUniform.str(), zeroVector );
+    ossProperty<< "uStartEndPosition["<< i << "]";
+    mIndiceStartEndPos[i] = mActor.RegisterProperty( ossProperty.str(), zeroVector );
 
     ossProperty.str("");
 
     ossProperty.str("");
-    ossProperty<< "percentage-"<< i;
-
-    ossUniform.str("");
-    ossUniform<< "uPercentage["<< i << "]";
-    mIndicesPercentage[i] = RegisterUniform( mActor, ossProperty.str(), ossUniform.str(), 0.f );
+    ossProperty<< "uPercentage["<< i << "]";
+    mIndicesPercentage[i] = mActor.RegisterProperty( ossProperty.str(), 0.f );
   }
 }
 
   }
 }
 
index 5f35d20..c1cc9ae 100644 (file)
@@ -48,14 +48,14 @@ inline Shader CreateBubbleShader( unsigned int numBubble )
   uniform mediump float uGravity;\n
   // xy: the emit position of the bubble; zw: the destination of the bubble.
   // The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
   uniform mediump float uGravity;\n
   // xy: the emit position of the bubble; zw: the destination of the bubble.
   // The bubble is moving from (xy) to (zw plus the y drop influenced by gravity).
-  uniform vec4 uStartAndEndPos[NUMBER_OF_BUBBLE];\n
+  uniform vec4 uStartEndPosition[NUMBER_OF_BUBBLE];\n
   // The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
   uniform float uPercentage[NUMBER_OF_BUBBLE];\n
   uniform vec2 uInvertedMovementArea;\n
   // The bubble number is restricted by the available uniform num.
   // The undergoing percentage of the bubble movement. 0.0: start from emit position, 1.0: reach the destination
   uniform float uPercentage[NUMBER_OF_BUBBLE];\n
   uniform vec2 uInvertedMovementArea;\n
   // The bubble number is restricted by the available uniform num.
-  // To increase the displayed bubble, every uStartAndEndPos and uPercentage uniform is applied to a small bunch of bubbles (9 here)
+  // To increase the displayed bubble, every uStartEndPosition and uPercentage uniform is applied to a small bunch of bubbles (9 here)
   // The offset defines the random offset between bubbles within the bunch.
   // The offset defines the random offset between bubbles within the bunch.
-  uniform vec2 offset[9];\n
+  uniform vec2 uOffset[9];\n
   // This uniform is used to change the bubble size during running time
   uniform float uDynamicScale;\n
   varying float vPercentage;\n
   // This uniform is used to change the bubble size during running time
   uniform float uDynamicScale;\n
   varying float vPercentage;\n
@@ -67,7 +67,7 @@ inline Shader CreateBubbleShader( unsigned int numBubble )
     int index = int(aIndex); \n
     //for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
     int groupIdx = index / NUMBER_OF_BUBBLE;\n
     int index = int(aIndex); \n
     //for some i between 0 ~ NUMBER_OF_BUBBLE-1: i,i+NUMBER_OF_BUBBLE, i+NUMBER_OF_BUBBLE*2, ... (up to i+NUMBER_OF_BUBBLE*8) belongs to the same bunch.
     int groupIdx = index / NUMBER_OF_BUBBLE;\n
-    // The bubbles within the same bunch applies the same uniforms uStartAndEndPos[idx] & uPercentage[idx]
+    // The bubbles within the same bunch applies the same uniforms uStartEndPosition[idx] & uPercentage[idx]
     int idx = index - groupIdx*NUMBER_OF_BUBBLE;\n
     float percentage = uPercentage[idx];
     // early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
     int idx = index - groupIdx*NUMBER_OF_BUBBLE;\n
     float percentage = uPercentage[idx];
     // early out if uPercentage is (zero || one) setting position to zero (zero sized triangles)
@@ -76,9 +76,9 @@ inline Shader CreateBubbleShader( unsigned int numBubble )
       gl_Position = vec4(0.0);\n
       return;\n
     }\n
       gl_Position = vec4(0.0);\n
       return;\n
     }\n
-    vec4 startAndEnd = uStartAndEndPos[idx];\n
+    vec4 startAndEnd = uStartEndPosition[idx];\n
     // The final position is added up different offset for bubbles
     // The final position is added up different offset for bubbles
-    startAndEnd.zw += offset[groupIdx];\n
+    startAndEnd.zw += uOffset[groupIdx];\n
     \n
     // increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
     // the new xy value containes both the new scale and new bubble position
     \n
     // increase the bubble size from 0% to 100% during the first 1/5 of movement & apply the dynamic scale
     // the new xy value containes both the new scale and new bubble position
index 2583616..fcaaac3 100644 (file)
@@ -122,8 +122,7 @@ Actor CreateBouncingEffectActor( Property::Index& bouncePropertyIndex )
   meshActor.AddRenderer( renderer );
 
   // Register property
   meshActor.AddRenderer( renderer );
 
   // Register property
-  bouncePropertyIndex = meshActor.RegisterProperty("bounce-coefficient", 0.f);
-  meshActor.AddUniformMapping( bouncePropertyIndex, "uBounceCoefficient" );
+  bouncePropertyIndex = meshActor.RegisterProperty("uBounceCoefficient", 0.f);
 
   return meshActor;
 }
 
   return meshActor;
 }
index 07d7f02..1d1e5b0 100644 (file)
@@ -302,8 +302,7 @@ Actor CreateBackground( Actor parent, const Vector4& color, Image image = Image(
   mesh.SetIndexBuffer( indexBuffer );
 
   //Add uniforms to the shader
   mesh.SetIndexBuffer( indexBuffer );
 
   //Add uniforms to the shader
-  Property::Index backgroundColorIndex = shader.RegisterProperty( "uBackgroundColor", color );
-  shader.AddUniformMapping( backgroundColorIndex, "uBackgroundColor" );
+  shader.RegisterProperty( "uBackgroundColor", color );
 
   //Create the renderer
   Renderer renderer = Renderer::New( mesh, material );
 
   //Create the renderer
   Renderer renderer = Renderer::New( mesh, material );