From 79d988164ee246eef2039aaa855898dd140bbb66 Mon Sep 17 00:00:00 2001 From: seungho baek Date: Tue, 20 Dec 2022 22:26:41 +0900 Subject: [PATCH] Modify ColorMode Policy for SceneView and Model - 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 --- .../src/dali-scene3d/utc-Dali-Model.cpp | 23 ++++++++++++++++++++++ .../src/dali-scene3d/utc-Dali-SceneView.cpp | 20 +++++++++++++++++++ .../internal/controls/model/model-impl.cpp | 1 + .../controls/scene-view/scene-view-impl.cpp | 2 ++ dali-scene3d/public-api/loader/node-definition.cpp | 2 ++ 5 files changed, 48 insertions(+) diff --git a/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp b/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp index 7d92024..02393e3 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-Model.cpp @@ -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 { diff --git a/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp b/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp index bf9e015..f1b6bd7 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp @@ -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(Dali::Actor::Property::COLOR_MODE), static_cast(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION); + + view.UseFramebuffer(true); + + DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty(Dali::Actor::Property::COLOR_MODE), static_cast(ColorMode::USE_OWN_COLOR), TEST_LOCATION); + + view.UseFramebuffer(false); + + DALI_TEST_EQUALS(view.GetChildAt(0u).GetProperty(Dali::Actor::Property::COLOR_MODE), static_cast(ColorMode::USE_OWN_MULTIPLY_PARENT_ALPHA), TEST_LOCATION); + + END_TEST; +} diff --git a/dali-scene3d/internal/controls/model/model-impl.cpp b/dali-scene3d/internal/controls/model/model-impl.cpp index bdbbf3b..b552489 100644 --- a/dali-scene3d/internal/controls/model/model-impl.cpp +++ b/dali-scene3d/internal/controls/model/model-impl.cpp @@ -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()) diff --git a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp index 940bf87..28d0933 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp @@ -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); diff --git a/dali-scene3d/public-api/loader/node-definition.cpp b/dali-scene3d/public-api/loader/node-definition.cpp index df4e0c4..b47c203 100644 --- a/dali-scene3d/public-api/loader/node-definition.cpp +++ b/dali-scene3d/public-api/loader/node-definition.cpp @@ -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); -- 2.7.4