Modify ColorMode Policy for SceneView and Model 11/285811/3
authorseungho baek <sbsh.baek@samsung.com>
Tue, 20 Dec 2022 13:26:41 +0000 (22:26 +0900)
committerseungho baek <sbsh.baek@samsung.com>
Tue, 20 Dec 2022 15:26:54 +0000 (00:26 +0900)
 - For Model, Use ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA for ColorMode
 - Actor::Property::COLOR will affect its children Actors.
 - For SceneView, Use ColorMode::USE_OWN_COLOR when mUseFrameBuffer is true.
 - When Opacity of SceneView is animated, it looks natural.
 - But, use ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA when mUseFrameBuffer is false.
 - Then, Opacity animation is works (but slightly looks unnatural.)

Change-Id: Iaa993f5857f5bd9e2cf3b79b463f2fc5e5db3249
Signed-off-by: seungho baek <sbsh.baek@samsung.com>
automated-tests/src/dali-scene3d/utc-Dali-Model.cpp
automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp
dali-scene3d/internal/controls/model/model-impl.cpp
dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp
dali-scene3d/public-api/loader/node-definition.cpp

index 7d92024a91925a72c0b981c107df69d7a01c495d..02393e39347b807d6fcd08f3e107b9a1bd42ed24 100644 (file)
@@ -849,6 +849,29 @@ int UtcDaliModelMultiplePrimitives(void)
   END_TEST;
 }
 
+int UtcDaliModelColorMode(void)
+{
+  ToolkitTestApplication application;
+
+  Scene3D::Model model = Scene3D::Model::New(TEST_GLTF_FILE_NAME);
+  model.SetProperty(Dali::Actor::Property::SIZE, Vector2(50, 50));
+  model.SetProperty(Dali::Actor::Property::COLOR, Color::RED);
+
+  application.GetScene().Add(model);
+
+  application.SendNotification();
+  application.Render();
+
+  Actor actor = model.FindChildByName("AnimatedCube");
+  Vector4 childColor = actor[Dali::Actor::Property::COLOR];
+  Vector4 childWorldColor = actor[Dali::Actor::Property::WORLD_COLOR];
+
+  DALI_TEST_EQUALS(childColor, Color::WHITE, TEST_LOCATION);
+  DALI_TEST_EQUALS(childWorldColor, Color::RED, TEST_LOCATION);
+
+  END_TEST;
+}
+
 // For ResourceReady
 namespace
 {
index bf9e015c2f4d9371f2a245e4ae6708003fa02aed..f1b6bd76c4f2803a673e21226fe723b9aa795eb7 100644 (file)
@@ -751,3 +751,23 @@ int UtcDaliSceneViewCreateAndRemoveRenderTask(void)
 
   END_TEST;
 }
+
+int UtcDaliSceneViewColorMode(void)
+{
+  ToolkitTestApplication application;
+
+  Scene3D::SceneView view = Scene3D::SceneView::New();
+  application.GetScene().Add(view);
+
+  DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION);
+
+  view.UseFramebuffer(true);
+
+  DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_COLOR), TEST_LOCATION);
+
+  view.UseFramebuffer(false);
+
+  DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty<int>(Dali::Actor::Property::COLOR_MODE), static_cast<int>(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION);
+
+  END_TEST;
+}
index bdbbf3bfd5d9ddd79d8487d5d7f21499334fd0a9..b552489848ab8622f9b130f3c3a123a1cb0e182a 100644 (file)
@@ -469,6 +469,7 @@ void Model::LoadModel()
   Dali::Scene3D::Loader::Customization::Choices       choices;
 
   mModelRoot = Actor::New();
+  mModelRoot.SetProperty(Actor::Property::COLOR_MODE, ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR);
 
   BoundingVolume AABB;
   for(auto iRoot : scene.GetRoots())
index 940bf87a64e2301fe81f3934342d897f53e0d3f0..28d093368bdd2fb1cdcf4fdcc458abebc43d3c66 100644 (file)
@@ -556,6 +556,7 @@ void SceneView::UpdateRenderTask()
          !Dali::Equals(currentFrameBuffer.GetColorTexture().GetWidth(), size.width) ||
          !Dali::Equals(currentFrameBuffer.GetColorTexture().GetHeight(), size.height))
       {
+        mRootLayer.SetProperty(Dali::Actor::Property::COLOR_MODE, ColorMode::USE_OWN_COLOR);
         mRenderTask.ResetViewportGuideActor();
         mRenderTask.SetViewport(Dali::Viewport(Vector4::ZERO));
 
@@ -594,6 +595,7 @@ void SceneView::UpdateRenderTask()
       mRenderTask.SetViewportGuideActor(Self());
       if(mRenderTask.GetFrameBuffer())
       {
+        mRootLayer.SetProperty(Dali::Actor::Property::COLOR_MODE, ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA);
         FrameBuffer framebuffer;
         mRenderTask.SetFrameBuffer(framebuffer);
         mRenderTask.SetClearEnabled(false);
index df4e0c44ff9a89ad2444059a4d191792a2970679..b47c20388900e4fdee7d7677a758517d75c721d6 100644 (file)
@@ -79,6 +79,8 @@ Actor NodeDefinition::CreateActor(CreateParams& params)
 
   actor.RegisterProperty(ORIGINAL_MATRIX_PROPERTY_NAME, GetLocalSpace(), Property::AccessMode::READ_ONLY);
 
+  actor.SetProperty(Actor::Property::COLOR_MODE, ColorMode::USE_OWN_MULTIPLY_PARENT_COLOR);
+
   for(auto& renderable : mRenderables)
   {
     renderable->OnCreate(*this, params, actor);