Remove dali-any from Property::Value - reimplement multivalue using more efficient...
[platform/core/uifw/dali-core.git] / automated-tests / src / dali / utc-Dali-ShaderEffect.cpp
index dfc372c..dd3c774 100644 (file)
@@ -58,9 +58,9 @@ struct TestConstraintToVector3
   {
   }
 
-  Vector3 operator()(const Vector3& current)
+  void operator()( Vector3& current, const PropertyInputContainer& /* inputs */ )
   {
-    return mTarget;
+    current = mTarget;
   }
 
   Vector3 mTarget;
@@ -72,10 +72,9 @@ struct TestConstraintFromPositionToVector3
   {
   }
 
-  Vector3 operator()(const Vector3& current, const PropertyInput& position)
+  void operator()( Vector3& current, const PropertyInputContainer& inputs )
   {
-
-    return position.GetVector3();
+    current = inputs[0]->GetVector3();
   }
 };
 
@@ -86,9 +85,9 @@ struct TestConstraintToVector3Double
   {
   }
 
-  Vector3 operator()(const Vector3& current)
+  void operator()( Vector3& current, const PropertyInputContainer& /* inputs */ )
   {
-    return mTarget * 2.0f;
+    current = mTarget * 2.0f;
   }
 
   Vector3 mTarget;
@@ -618,10 +617,8 @@ int UtcDaliShaderEffectMethodApplyConstraint(void)
       application.GetGlAbstraction().CheckUniformValue(
           "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
+  constraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -657,11 +654,9 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor(void)
 
   Property::Index uVecProperty = effect.GetPropertyIndex("uVec3");
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    Source(actor, Actor::Property::POSITION),
-                                                    TestConstraintFromPositionToVector3() );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintFromPositionToVector3() );
+  constraint.AddSource( Source( actor, Actor::Property::POSITION ) );
+  constraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -697,16 +692,12 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor2(void)
 
   Property::Index uVecProperty = effect.GetPropertyIndex("uVec3");
 
-  Constraint shaderConstraint = Constraint::New<Vector3>( uVecProperty,
-                                                    Source(actor, Actor::Property::POSITION),
-                                                    TestConstraintFromPositionToVector3() );
-
-  effect.ApplyConstraint(shaderConstraint);
+  Constraint shaderConstraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintFromPositionToVector3() );
+  shaderConstraint.AddSource( Source(actor, Actor::Property::POSITION) );
+  shaderConstraint.Apply();
 
-  Constraint actorConstraint = Constraint::New<Vector3>( Actor::Property::POSITION,
-                                                         TestConstraintToVector3Double(targetPosition) );
-
-  actor.ApplyConstraint(actorConstraint);
+  Constraint actorConstraint = Constraint::New<Vector3>( actor, Actor::Property::POSITION, TestConstraintToVector3Double(targetPosition) );
+  actorConstraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -718,78 +709,6 @@ int UtcDaliShaderEffectMethodApplyConstraintFromActor2(void)
   END_TEST;
 }
 
-int UtcDaliShaderEffectMethodApplyConstraintCallback(void)
-{
-  // Test whether Shader's uniform can be constrained to a stationary constraint.
-  TestApplication application;
-
-  ShaderEffect effect = ShaderEffect::New( VertexSource, FragmentSource );
-  DALI_TEST_CHECK( effect );
-
-  BufferImage image = CreateBufferImage();
-
-  effect.SetUniform( "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) );
-
-  ImageActor actor = ImageActor::New( image );
-  actor.SetSize( 100.0f, 100.0f );
-  actor.SetName("TestImageFilenameActor");
-  actor.SetShaderEffect(effect);
-  Stage::GetCurrent().Add(actor);
-
-  Property::Index uVecProperty = effect.GetPropertyIndex("uVec3");
-
-  application.SendNotification();
-  application.Render();
-
-  // Test effects of SetUniform...
-  DALI_TEST_CHECK(
-      application.GetGlAbstraction().CheckUniformValue(
-          "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
-
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  constraint.SetApplyTime( 10.0f );
-
-  bool constraintCheck( false );
-  ConstraintAppliedCheck appliedCheck( constraintCheck );
-
-  // We should receive the "Applied" signal after 10 seconds
-  ActiveConstraint active = effect.ApplyConstraint(constraint);
-  active.AppliedSignal().Connect( &application, appliedCheck );
-
-  application.SendNotification();
-  application.Render(static_cast<unsigned int>(1000.0f)); // 1 elapsed second
-
-  // Check signal has not fired
-  application.SendNotification();
-  appliedCheck.CheckSignalNotReceived();
-
-  application.Render(static_cast<unsigned int>(4000.0f)); // 5 elapsed seconds
-
-  // Check signal has not fired
-  application.SendNotification();
-  appliedCheck.CheckSignalNotReceived();
-
-  application.Render(static_cast<unsigned int>(5000.0f - 1.0f)); // <10 elapsed seconds
-
-  // Check signal has not fired
-  application.SendNotification();
-  appliedCheck.CheckSignalNotReceived();
-
-  application.Render(static_cast<unsigned int>(2.0f)); // >10 elapsed seconds
-
-  // Signal should have fired
-  application.SendNotification();
-  appliedCheck.CheckSignalReceived();
-
-  // Test effects of Constraint.
-  DALI_TEST_CHECK(
-      application.GetGlAbstraction().CheckUniformValue(
-          "uVec3", Vector3( 4.0f, 9.0f, 16.0f ) ) );
-  END_TEST;
-}
-
 int UtcDaliShaderEffectMethodRemoveConstraints(void)
 {
   // Test if constrains can be removed before they are ever applyed.
@@ -818,10 +737,8 @@ int UtcDaliShaderEffectMethodRemoveConstraints(void)
       application.GetGlAbstraction().CheckUniformValue(
           "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
+  constraint.Apply();
 
   // Remove the constraints
   effect.RemoveConstraints();
@@ -864,10 +781,8 @@ int UtcDaliShaderEffectMethodRemoveConstraints2(void)
       application.GetGlAbstraction().CheckUniformValue(
           "uVec3", Vector3( 1.0f, 2.0f, 3.0f ) ) );
 
-  Constraint constraint = Constraint::New<Vector3>( uVecProperty,
-                                                    TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
-
-  effect.ApplyConstraint(constraint);
+  Constraint constraint = Constraint::New<Vector3>( effect, uVecProperty, TestConstraintToVector3(Vector3(4.0f, 9.0f, 16.0f)) );
+  constraint.Apply();
 
   application.SendNotification();
   application.Render();
@@ -978,8 +893,8 @@ int UtcDaliShaderEffectPropertyIndices(void)
 
   Property::IndexContainer indices;
   effect.GetPropertyIndices( indices );
-  DALI_TEST_CHECK( ! indices.empty() );
-  DALI_TEST_EQUALS( indices.size(), effect.GetPropertyCount(), TEST_LOCATION );
+  DALI_TEST_CHECK( indices.Size() );
+  DALI_TEST_EQUALS( indices.Size(), effect.GetPropertyCount(), TEST_LOCATION );
   END_TEST;
 }
 
@@ -1031,7 +946,7 @@ int UtcDaliShaderBinaries(void)
   END_TEST;
 }
 
-int UtcDaliShaderEffectFromProperties01(void)
+int UtcDaliShaderEffectFromPropertiesP(void)
 {
   TestApplication application;
   tet_infoline("UtcDaliShaderEffectFromProperties01()");
@@ -1054,21 +969,25 @@ int UtcDaliShaderEffectFromProperties01(void)
   ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() );
   DALI_TEST_CHECK( effect );
 
-  Property::Value programMap = Property::Value(Property::MAP);
+  Property::Value programValue = Property::Value(Property::MAP);
+  Property::Map* programMap = programValue.GetMap();
+  DALI_TEST_CHECK( programMap );
 
-  programMap.SetValue("vertex", vertexShader);
-  programMap.SetValue("fragment", fragmentShader);
+  programMap->Insert("vertex", vertexShader);
+  programMap->Insert("fragment", fragmentShader);
 
-  programMap.SetValue("vertex-prefix", vertexShaderPrefix);
-  programMap.SetValue("fragment-prefix", fragmentShaderPrefix);
+  programMap->Insert("vertex-prefix", vertexShaderPrefix);
+  programMap->Insert("fragment-prefix", fragmentShaderPrefix);
 
-  programMap.SetValue("geometry-type", "GEOMETRY_TYPE_IMAGE");
+  programMap->Insert("geometry-type", "GEOMETRY_TYPE_IMAGE");
 
-  effect.SetProperty(effect.GetPropertyIndex("program"), programMap);
+  effect.SetProperty(effect.GetPropertyIndex("program"), programValue);
 
-  Property::Value imageMap = Property::Value(Property::MAP);
-  imageMap.SetValue("filename", Property::Value(TestImageFilename));
-  effect.SetProperty(effect.GetPropertyIndex("image"), imageMap);
+  Property::Value imageValue = Property::Value(Property::MAP);
+  Property::Map* imageMap = imageValue.GetMap();
+  DALI_TEST_CHECK( imageMap );
+  imageMap->Insert("filename", Property::Value(TestImageFilename));
+  effect.SetProperty(effect.GetPropertyIndex("image"), imageValue);
 
   // do a update & render to get the image request
   application.SendNotification();
@@ -1106,7 +1025,7 @@ int UtcDaliShaderEffectFromProperties01(void)
   END_TEST;
 }
 
-int UtcDaliShaderEffectFromProperties02(void)
+int UtcDaliShaderEffectFromPropertiesN(void)
 {
   try
   {
@@ -1116,8 +1035,6 @@ int UtcDaliShaderEffectFromProperties02(void)
     // Call render to compile default shaders.
     application.SendNotification();
     application.Render();
-    application.Render();
-    application.Render();
 
     // create from type registry (currently only way to get ShaderEffect with no shader setup in constructor
     TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" );
@@ -1125,16 +1042,15 @@ int UtcDaliShaderEffectFromProperties02(void)
     ShaderEffect effect = ShaderEffect::DownCast( typeInfo.CreateInstance() );
     DALI_TEST_CHECK( effect );
 
-    Property::Value programMap = Property::Value(Property::MAP);
+    Property::Value programValue = Property::Value(Property::MAP);
+    Property::Map* programMap = programValue.GetMap();
+    DALI_TEST_CHECK( programMap );
 
-    programMap.SetValue("vertex",   std::string(VertexSource));
-    programMap.SetValue("fragment", std::string(FragmentSource));
+    programMap->Insert("vertex",   std::string(VertexSource));
+    programMap->Insert("fragment", std::string(FragmentSource));
 
-    // programMap.SetValue("geometry-type", "GEOMETRY_TYPE_IMAGE");
-    // dont set by value
-    programMap.SetValue("geometry-type", GeometryType( GEOMETRY_TYPE_IMAGE ));
-
-    effect.SetProperty(effect.GetPropertyIndex("program"), programMap);
+    // use wrong index on purpose
+    effect.SetProperty(effect.GetPropertyIndex("program") + 1, programValue );
 
     tet_result( TET_FAIL );
   }
@@ -1145,7 +1061,7 @@ int UtcDaliShaderEffectFromProperties02(void)
   END_TEST;
 }
 
-int UtcDaliShaderEffectFromProperties03(void)
+int UtcDaliShaderEffectFromProperties2N(void)
 {
   try
   {
@@ -1155,8 +1071,6 @@ int UtcDaliShaderEffectFromProperties03(void)
     // Call render to compile default shaders.
     application.SendNotification();
     application.Render();
-    application.Render();
-    application.Render();
 
     // create from type registry (currently only way to get ShaderEffect with no shader setup in constructor
     TypeInfo typeInfo = TypeRegistry::Get().GetTypeInfo( "ShaderEffect" );