From 49cb323918bf75774320717df2a9a933a02e896c Mon Sep 17 00:00:00 2001 From: Seungho Baek Date: Tue, 16 Jul 2024 19:01:42 +0900 Subject: [PATCH] Automatic RenderTask Ordering Change-Id: I508caebefe9de0098dd5f0eda76a6f7d6abf0053 Signed-off-by: Seungho Baek --- .../src/dali-scene3d/utc-Dali-Light.cpp | 23 +-- .../src/dali-scene3d/utc-Dali-Panel.cpp | 78 +++++++++- .../src/dali-scene3d/utc-Dali-SceneView.cpp | 64 ++++++++ .../utc-Dali-RenderEffect-internal.cpp | 8 + .../dali-toolkit/utc-Dali-RenderEffect.cpp | 143 ++++++++++++++++++ .../internal/controls/panel/panel-impl.cpp | 24 ++- .../internal/controls/panel/panel-impl.h | 15 ++ .../controls/scene-view/scene-view-impl.cpp | 40 ++++- .../controls/scene-view/scene-view-impl.h | 15 ++ .../render-effects/blur-effect-impl.cpp | 49 +++++- .../render-effects/blur-effect-impl.h | 10 ++ .../render-effects/render-effect-impl.h | 23 +++ .../public-api/controls/control-impl.cpp | 23 +++ .../public-api/controls/control-impl.h | 23 +++ 14 files changed, 519 insertions(+), 19 deletions(-) diff --git a/automated-tests/src/dali-scene3d/utc-Dali-Light.cpp b/automated-tests/src/dali-scene3d/utc-Dali-Light.cpp index 88b0f56887..02741869e9 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-Light.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-Light.cpp @@ -1219,7 +1219,7 @@ int UtcDaliLightShadowRenderTask(void) sceneView.UseFramebuffer(true); DALI_TEST_EQUALS(baseRenderTaskCount + 1u, taskList.GetTaskCount(), TEST_LOCATION); - DALI_TEST_EQUALS(0, taskList.GetTask(baseRenderTaskCount - 1u).GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN, taskList.GetTask(baseRenderTaskCount - 1u).GetOrderIndex(), TEST_LOCATION); DALI_TEST_EQUALS(SCENE_ORDER_INDEX, taskList.GetTask(baseRenderTaskCount).GetOrderIndex(), TEST_LOCATION); Scene3D::Light light = Scene3D::Light::New(); @@ -1227,29 +1227,30 @@ int UtcDaliLightShadowRenderTask(void) Dali::DevelActor::LookAt(light, Vector3(1.0f, 0.0f, 0.0f)); light.EnableShadow(true); - tet_printf("Do not create rendertask until light is scene on"); + tet_printf("Do not create rendertask until light is scene on\n"); DALI_TEST_EQUALS(baseRenderTaskCount + 1u, taskList.GetTaskCount(), TEST_LOCATION); sceneView.Add(light); - tet_printf("Create shadowmap rendertask after light is scene on"); + tet_printf("Create shadowmap rendertask after light is scene on\n"); DALI_TEST_EQUALS(baseRenderTaskCount + 2u, taskList.GetTaskCount(), TEST_LOCATION); - DALI_TEST_EQUALS(0, taskList.GetTask(baseRenderTaskCount - 1u).GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN, taskList.GetTask(baseRenderTaskCount - 1u).GetOrderIndex(), TEST_LOCATION); DALI_TEST_EQUALS(SCENE_ORDER_INDEX, taskList.GetTask(baseRenderTaskCount).GetOrderIndex(), TEST_LOCATION); - DALI_TEST_EQUALS(SHADOW_ORDER_INDEX, taskList.GetTask(baseRenderTaskCount + 1u).GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, taskList.GetTask(baseRenderTaskCount + 1u).GetOrderIndex(), TEST_LOCATION); application.SendNotification(); - tet_printf("Check render task list sorted"); - DALI_TEST_EQUALS(SHADOW_ORDER_INDEX, taskList.GetTask(baseRenderTaskCount).GetOrderIndex(), TEST_LOCATION); - DALI_TEST_EQUALS(SCENE_ORDER_INDEX, taskList.GetTask(baseRenderTaskCount + 1u).GetOrderIndex(), TEST_LOCATION); + tet_printf("Check render task list sorted\n"); + DALI_TEST_EQUALS(INT32_MIN, taskList.GetTask(baseRenderTaskCount).GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 1, taskList.GetTask(baseRenderTaskCount + 1u).GetOrderIndex(), TEST_LOCATION); light.EnableShadow(false); - tet_printf("Check shadowmap rendertask removed"); + tet_printf("Check shadowmap rendertask removed\n"); + DALI_TEST_EQUALS(baseRenderTaskCount + 1u, taskList.GetTaskCount(), TEST_LOCATION); - DALI_TEST_EQUALS(0, taskList.GetTask(baseRenderTaskCount - 1u).GetOrderIndex(), TEST_LOCATION); - DALI_TEST_EQUALS(SCENE_ORDER_INDEX, taskList.GetTask(baseRenderTaskCount).GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN, taskList.GetTask(baseRenderTaskCount - 1u).GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 1, taskList.GetTask(baseRenderTaskCount).GetOrderIndex(), TEST_LOCATION); END_TEST; } \ No newline at end of file diff --git a/automated-tests/src/dali-scene3d/utc-Dali-Panel.cpp b/automated-tests/src/dali-scene3d/utc-Dali-Panel.cpp index 197c1e82df..f7b035cefd 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-Panel.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-Panel.cpp @@ -746,4 +746,80 @@ int UtcDaliPanelSetGetShadow(void) DALI_TEST_EQUALS(panel.IsShadowReceiving(), false, TEST_LOCATION); END_TEST; -} \ No newline at end of file +} + +int UtcDaliPanelRenderTaskOrdering(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliPanelRenderTaskOrdering"); + + Integration::Scene scene = application.GetScene(); + RenderTaskList taskList = scene.GetRenderTaskList(); + + uint32_t defaultTaskCount = taskList.GetTaskCount(); + RenderTask defaultRenderTask = taskList.GetTask(defaultTaskCount - 1); + tet_printf("default Task Cnt : %d\n", defaultTaskCount); + + Scene3D::SceneView sceneView = Scene3D::SceneView::New(); + sceneView.UseFramebuffer(true); + scene.Add(sceneView); + + uint32_t afterSceneViewTaskCount = taskList.GetTaskCount(); + RenderTask sceneViewRenderTask = taskList.GetTask(afterSceneViewTaskCount - 1); + tet_printf("after SceneView Task cnt : %d\n", afterSceneViewTaskCount); + DALI_TEST_CHECK(afterSceneViewTaskCount == defaultTaskCount + 1); + + Scene3D::Panel panel = Scene3D::Panel::New(); + sceneView.Add(panel); + + uint32_t afterPanelTaskCount = taskList.GetTaskCount(); + RenderTask panelRenderTask = taskList.GetTask(afterPanelTaskCount - 1); + tet_printf("after Panel Task cnt : %d\n", afterPanelTaskCount); + DALI_TEST_CHECK(afterPanelTaskCount == afterSceneViewTaskCount + 1); + + Control control1 = Control::New(); + control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + control1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f)); + control1.SetRenderEffect(BackgroundBlurEffect::New()); + + panel.Add(control1); + + uint32_t afterBlurEffectTaskCount = taskList.GetTaskCount(); + RenderTask blurSourceRenderTask = taskList.GetTask(afterBlurEffectTaskCount - 3); + RenderTask blurHorizontalRenderTask = taskList.GetTask(afterBlurEffectTaskCount - 2); + RenderTask blurVerticalRenderTask = taskList.GetTask(afterBlurEffectTaskCount - 1); + tet_printf("after blurEffect Task cnt : %d\n", afterBlurEffectTaskCount); + DALI_TEST_CHECK(afterBlurEffectTaskCount == afterPanelTaskCount + 3); + + tet_printf("defaultRenderTask order : %d\n", defaultRenderTask.GetOrderIndex()); + tet_printf("sceneViewRenderTask order : %d\n", sceneViewRenderTask.GetOrderIndex()); + tet_printf("panelRenderTask order : %d\n", panelRenderTask.GetOrderIndex()); + tet_printf("blurSourceRenderTask order : %d\n", blurSourceRenderTask.GetOrderIndex()); + tet_printf("blurHorizontalRenderTask order : %d\n", blurHorizontalRenderTask.GetOrderIndex()); + tet_printf("blurVerticalRenderTask order : %d\n", blurVerticalRenderTask.GetOrderIndex()); + + DALI_TEST_EQUALS(INT32_MIN, defaultRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, sceneViewRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(90, panelRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, blurSourceRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, blurHorizontalRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, blurVerticalRenderTask.GetOrderIndex(), TEST_LOCATION); + + application.SendNotification(); + + tet_printf("defaultRenderTask order : %d\n", defaultRenderTask.GetOrderIndex()); + tet_printf("sceneViewRenderTask order : %d\n", sceneViewRenderTask.GetOrderIndex()); + tet_printf("panelRenderTask order : %d\n", panelRenderTask.GetOrderIndex()); + tet_printf("blurSourceRenderTask order : %d\n", blurSourceRenderTask.GetOrderIndex()); + tet_printf("blurHorizontalRenderTask order : %d\n", blurHorizontalRenderTask.GetOrderIndex()); + tet_printf("blurVerticalRenderTask order : %d\n", blurVerticalRenderTask.GetOrderIndex()); + + DALI_TEST_EQUALS(INT32_MIN, defaultRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 4, sceneViewRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 3, panelRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN, blurSourceRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 1, blurHorizontalRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 2, blurVerticalRenderTask.GetOrderIndex(), TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp b/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp index 4e77816043..63d533fc53 100644 --- a/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp +++ b/automated-tests/src/dali-scene3d/utc-Dali-SceneView.cpp @@ -1571,3 +1571,67 @@ int UtcDaliSceneViewSelectCamera(void) END_TEST; } + +int UtcDaliSceneViewRenderTaskOrdering(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliPanelRenderTaskOrdering"); + + Integration::Scene scene = application.GetScene(); + RenderTaskList taskList = scene.GetRenderTaskList(); + + uint32_t defaultTaskCount = taskList.GetTaskCount(); + RenderTask defaultRenderTask = taskList.GetTask(defaultTaskCount - 1); + tet_printf("default Task Cnt : %d\n", defaultTaskCount); + + Scene3D::SceneView sceneView = Scene3D::SceneView::New(); + sceneView.UseFramebuffer(true); + scene.Add(sceneView); + + uint32_t afterSceneViewTaskCount = taskList.GetTaskCount(); + RenderTask sceneViewRenderTask = taskList.GetTask(afterSceneViewTaskCount - 1); + tet_printf("after SceneView Task cnt : %d\n", afterSceneViewTaskCount); + DALI_TEST_CHECK(afterSceneViewTaskCount == defaultTaskCount + 1); + + Control control1 = Control::New(); + control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + control1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f)); + control1.SetRenderEffect(BackgroundBlurEffect::New()); + + sceneView.Add(control1); + + uint32_t afterBlurEffectTaskCount = taskList.GetTaskCount(); + RenderTask blurSourceRenderTask = taskList.GetTask(afterBlurEffectTaskCount - 3); + RenderTask blurHorizontalRenderTask = taskList.GetTask(afterBlurEffectTaskCount - 2); + RenderTask blurVerticalRenderTask = taskList.GetTask(afterBlurEffectTaskCount - 1); + tet_printf("after blurEffect Task cnt : %d\n", afterBlurEffectTaskCount); + DALI_TEST_CHECK(afterBlurEffectTaskCount == afterSceneViewTaskCount + 3); + + tet_printf("defaultRenderTask order : %d\n", defaultRenderTask.GetOrderIndex()); + tet_printf("sceneViewRenderTask order : %d\n", sceneViewRenderTask.GetOrderIndex()); + tet_printf("blurSourceRenderTask order : %d\n", blurSourceRenderTask.GetOrderIndex()); + tet_printf("blurHorizontalRenderTask order : %d\n", blurHorizontalRenderTask.GetOrderIndex()); + tet_printf("blurVerticalRenderTask order : %d\n", blurVerticalRenderTask.GetOrderIndex()); + + DALI_TEST_EQUALS(INT32_MIN, defaultRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, sceneViewRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, blurSourceRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, blurHorizontalRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, blurVerticalRenderTask.GetOrderIndex(), TEST_LOCATION); + + application.SendNotification(); + + tet_printf("defaultRenderTask order : %d\n", defaultRenderTask.GetOrderIndex()); + tet_printf("sceneViewRenderTask order : %d\n", sceneViewRenderTask.GetOrderIndex()); + tet_printf("blurSourceRenderTask order : %d\n", blurSourceRenderTask.GetOrderIndex()); + tet_printf("blurHorizontalRenderTask order : %d\n", blurHorizontalRenderTask.GetOrderIndex()); + tet_printf("blurVerticalRenderTask order : %d\n", blurVerticalRenderTask.GetOrderIndex()); + + DALI_TEST_EQUALS(INT32_MIN, defaultRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 3, sceneViewRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN, blurSourceRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 1, blurHorizontalRenderTask.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 2, blurVerticalRenderTask.GetOrderIndex(), TEST_LOCATION); + + END_TEST; +} diff --git a/automated-tests/src/dali-toolkit-internal/utc-Dali-RenderEffect-internal.cpp b/automated-tests/src/dali-toolkit-internal/utc-Dali-RenderEffect-internal.cpp index 9a3bbc6e06..d468ac765e 100644 --- a/automated-tests/src/dali-toolkit-internal/utc-Dali-RenderEffect-internal.cpp +++ b/automated-tests/src/dali-toolkit-internal/utc-Dali-RenderEffect-internal.cpp @@ -62,6 +62,14 @@ public: return handle; } + OffScreenRenderable::Type GetOffScreenRenderableType() override + { + return OffScreenRenderable::Type::NONE; + } + + void GetOffScreenRenderTasks(std::vector& tasks, bool isForward) override + {} + protected: TestRenderEffectImpl() : mOnActivated(false) diff --git a/automated-tests/src/dali-toolkit/utc-Dali-RenderEffect.cpp b/automated-tests/src/dali-toolkit/utc-Dali-RenderEffect.cpp index 8e95732a10..f283741f25 100644 --- a/automated-tests/src/dali-toolkit/utc-Dali-RenderEffect.cpp +++ b/automated-tests/src/dali-toolkit/utc-Dali-RenderEffect.cpp @@ -525,3 +525,146 @@ int UtcDaliRenderEffectControlVisiblityChanged02(void) END_TEST; } + +int UtcDaliRenderEffectRenderTaskOrdering(void) +{ + ToolkitTestApplication application; + tet_infoline("UtcDaliRenderEffectRenderTaskOrdering"); + + Integration::Scene scene = application.GetScene(); + RenderTaskList taskList = scene.GetRenderTaskList(); + + Control control1 = Control::New(); + control1.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + control1.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f)); + + tet_printf("render task cnt : %d\n", taskList.GetTaskCount()); + + // Add render effect during scene on. + control1.SetRenderEffect(BackgroundBlurEffect::New()); + + tet_printf("render task cnt after set : %d\n", taskList.GetTaskCount()); + DALI_TEST_EQUALS(1, taskList.GetTaskCount(), TEST_LOCATION); + + scene.Add(control1); + + tet_printf("render task cnt after add : %d\n", taskList.GetTaskCount()); + DALI_TEST_EQUALS(4, taskList.GetTaskCount(), TEST_LOCATION); + + Dali::RenderTask sourceTaskControl1 = taskList.GetTask(taskList.GetTaskCount() - 3); + Dali::RenderTask horizontalBlurTaskControl1 = taskList.GetTask(taskList.GetTaskCount() - 2); + Dali::RenderTask verticalBlurTaskControl1 = taskList.GetTask(taskList.GetTaskCount() - 1); + + tet_printf("order : %d\n", sourceTaskControl1.GetOrderIndex()); + tet_printf("order : %d\n", horizontalBlurTaskControl1.GetOrderIndex()); + tet_printf("order : %d\n", verticalBlurTaskControl1.GetOrderIndex()); + + DALI_TEST_EQUALS(0, sourceTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, horizontalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, verticalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + + application.SendNotification(); + + tet_printf("order af : %d\n", sourceTaskControl1.GetOrderIndex()); + tet_printf("order af : %d\n", horizontalBlurTaskControl1.GetOrderIndex()); + tet_printf("order af : %d\n", verticalBlurTaskControl1.GetOrderIndex()); + + DALI_TEST_EQUALS(INT32_MIN, sourceTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 1, horizontalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 2, verticalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + + Control control2 = Control::New(); + control2.SetProperty(Actor::Property::PARENT_ORIGIN, ParentOrigin::CENTER); + control2.SetProperty(Actor::Property::SIZE, Vector2(1.0f, 1.0f)); + + tet_printf("render task cnt : %d\n", taskList.GetTaskCount()); + + // Add render effect during scene on. + control2.SetRenderEffect(BackgroundBlurEffect::New()); + + tet_printf("render task cnt after set : %d\n", taskList.GetTaskCount()); + + scene.Add(control2); + + DALI_TEST_EQUALS(7, taskList.GetTaskCount(), TEST_LOCATION); + + tet_printf("render task cnt after add : %d\n", taskList.GetTaskCount()); + + Dali::RenderTask sourceTaskControl2 = taskList.GetTask(taskList.GetTaskCount() - 3); + Dali::RenderTask horizontalBlurTaskControl2 = taskList.GetTask(taskList.GetTaskCount() - 2); + Dali::RenderTask verticalBlurTaskControl2 = taskList.GetTask(taskList.GetTaskCount() - 1); + + + tet_printf("order after1 : %d\n", sourceTaskControl1.GetOrderIndex()); + tet_printf("order after1 : %d\n", horizontalBlurTaskControl1.GetOrderIndex()); + tet_printf("order after1 : %d\n", verticalBlurTaskControl1.GetOrderIndex()); + + tet_printf("order after1 : %d\n", sourceTaskControl2.GetOrderIndex()); + tet_printf("order after1 : %d\n", horizontalBlurTaskControl2.GetOrderIndex()); + tet_printf("order after1 : %d\n", verticalBlurTaskControl2.GetOrderIndex()); + + DALI_TEST_EQUALS(0, sourceTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, horizontalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, verticalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + + application.SendNotification(); + + tet_printf("order after2 : %d\n", sourceTaskControl1.GetOrderIndex()); + tet_printf("order after2 : %d\n", horizontalBlurTaskControl1.GetOrderIndex()); + tet_printf("order after2 : %d\n", verticalBlurTaskControl1.GetOrderIndex()); + + tet_printf("order after2 : %d\n", sourceTaskControl2.GetOrderIndex()); + tet_printf("order after2 : %d\n", horizontalBlurTaskControl2.GetOrderIndex()); + tet_printf("order after2 : %d\n", verticalBlurTaskControl2.GetOrderIndex()); + + DALI_TEST_EQUALS(INT32_MIN, sourceTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 1, horizontalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 2, verticalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + + DALI_TEST_EQUALS(INT32_MIN + 3, sourceTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 4, horizontalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 5, verticalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + + control2.Add(control1); + + sourceTaskControl1 = taskList.GetTask(taskList.GetTaskCount() - 3); + horizontalBlurTaskControl1 = taskList.GetTask(taskList.GetTaskCount() - 2); + verticalBlurTaskControl1 = taskList.GetTask(taskList.GetTaskCount() - 1); + + tet_printf("order after3 : %d\n", sourceTaskControl1.GetOrderIndex()); + tet_printf("order after3 : %d\n", horizontalBlurTaskControl1.GetOrderIndex()); + tet_printf("order after3 : %d\n", verticalBlurTaskControl1.GetOrderIndex()); + + tet_printf("order after3 : %d\n", sourceTaskControl2.GetOrderIndex()); + tet_printf("order after3 : %d\n", horizontalBlurTaskControl2.GetOrderIndex()); + tet_printf("order after3 : %d\n", verticalBlurTaskControl2.GetOrderIndex()); + + DALI_TEST_EQUALS(0, sourceTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, horizontalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(0, verticalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + + DALI_TEST_EQUALS(INT32_MIN + 3, sourceTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 4, horizontalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 5, verticalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + + application.SendNotification(); + + tet_printf("order after4 : %d\n", sourceTaskControl1.GetOrderIndex()); + tet_printf("order after4 : %d\n", horizontalBlurTaskControl1.GetOrderIndex()); + tet_printf("order after4 : %d\n", verticalBlurTaskControl1.GetOrderIndex()); + + tet_printf("order after4 : %d\n", sourceTaskControl2.GetOrderIndex()); + tet_printf("order after4 : %d\n", horizontalBlurTaskControl2.GetOrderIndex()); + tet_printf("order after4 : %d\n", verticalBlurTaskControl2.GetOrderIndex()); + + DALI_TEST_EQUALS(INT32_MIN + 3, sourceTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 4, horizontalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 5, verticalBlurTaskControl1.GetOrderIndex(), TEST_LOCATION); + + DALI_TEST_EQUALS(INT32_MIN, sourceTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 1, horizontalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + DALI_TEST_EQUALS(INT32_MIN + 2, verticalBlurTaskControl2.GetOrderIndex(), TEST_LOCATION); + + END_TEST; +} + diff --git a/dali-scene3d/internal/controls/panel/panel-impl.cpp b/dali-scene3d/internal/controls/panel/panel-impl.cpp index c84fd499d5..bdb66c8fdc 100644 --- a/dali-scene3d/internal/controls/panel/panel-impl.cpp +++ b/dali-scene3d/internal/controls/panel/panel-impl.cpp @@ -24,7 +24,6 @@ #include #include #include -#include #include #include #include @@ -276,6 +275,16 @@ Property::Value Panel::GetProperty(BaseObject* object, Property::Index index) return value; } +Dali::Actor Panel::GetOffScreenRenderableSourceActor() +{ + return (mRootLayer) ? mRootLayer : Dali::Actor(); +} + +bool Panel::IsOffScreenRenderTaskExclusive() +{ + return (mRenderTask) ? mRenderTask.IsExclusive() : false; +} + /////////////////////////////////////////////////////////// // // Private methods @@ -385,6 +394,7 @@ void Panel::OnInitialize() scaleConstraint.Apply(); UpdateProperties(); + SetOffScreenRenderableType(OffScreenRenderable::Type::FORWARD); } void Panel::OnSceneConnection(int depth) @@ -457,6 +467,18 @@ void Panel::OnSceneDisconnection() Control::OnSceneDisconnection(); } +void Panel::GetOffScreenRenderTasks(std::vector& tasks, bool isForward) +{ + tasks.clear(); + if(isForward) + { + if(mRenderTask) + { + tasks.push_back(mRenderTask); + } + } +} + void Panel::SetTransparent(bool transparent) { if(mIsTransparent != transparent) diff --git a/dali-scene3d/internal/controls/panel/panel-impl.h b/dali-scene3d/internal/controls/panel/panel-impl.h index 769d866096..5147bdeca4 100644 --- a/dali-scene3d/internal/controls/panel/panel-impl.h +++ b/dali-scene3d/internal/controls/panel/panel-impl.h @@ -121,6 +121,16 @@ public: */ static Property::Value GetProperty(BaseObject* object, Property::Index index); + /** + * @copydoc Toolkit::Internal::Control::GetOffScreenRenderableSourceActor + */ + Dali::Actor GetOffScreenRenderableSourceActor() override; + + /** + * @copydoc Toolkit::Internal::Control::IsOffScreenRenderTaskExclusive + */ + bool IsOffScreenRenderTaskExclusive() override; + protected: /** * @brief Constructs a new Panel. @@ -148,6 +158,11 @@ private: */ void OnSceneDisconnection() override; + /** + * @copydoc CustomActorImpl::SetFirstOrderIndex() + */ + void GetOffScreenRenderTasks(std::vector& tasks, bool isForward) override; + private: /** * @brief Sets whether the plane is transparent or not. 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 f570010e69..52aee16d3a 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.cpp @@ -796,7 +796,9 @@ void SceneView::UseFramebuffer(bool useFramebuffer) if(mUseFrameBuffer != useFramebuffer) { mUseFrameBuffer = useFramebuffer; + SetOffScreenRenderableType((mUseFrameBuffer) ? OffScreenRenderable::Type::FORWARD : OffScreenRenderable::Type::NONE); UpdateRenderTask(); + RequestRenderTaskReorder(); } } @@ -1157,6 +1159,16 @@ Property::Value SceneView::GetProperty(BaseObject* object, Property::Index index return value; } +Dali::Actor SceneView::GetOffScreenRenderableSourceActor() +{ + return (mRootLayer) ? mRootLayer : Dali::Actor(); +} + +bool SceneView::IsOffScreenRenderTaskExclusive() +{ + return (mRenderTask) ? mRenderTask.IsExclusive() : false; +} + /////////////////////////////////////////////////////////// // // Private methods @@ -1195,7 +1207,6 @@ void SceneView::OnSceneConnection(int depth) mRenderTask.SetExclusive(true); mRenderTask.SetInputEnabled(true); mRenderTask.SetCullMode(false); - mRenderTask.SetOrderIndex(SCENE_ORDER_INDEX); mRenderTask.SetScreenToFrameBufferMappingActor(Self()); UpdateRenderTask(); @@ -1269,6 +1280,22 @@ void SceneView::OnSceneDisconnection() Control::OnSceneDisconnection(); } +void SceneView::GetOffScreenRenderTasks(std::vector& tasks, bool isForward) +{ + tasks.clear(); + if(isForward) + { + if(mShadowMapRenderTask) + { + tasks.push_back(mShadowMapRenderTask); + } + if(mRenderTask) + { + tasks.push_back(mRenderTask); + } + } +} + void SceneView::OnInitialize() { Actor self = Self(); @@ -1286,6 +1313,11 @@ void SceneView::OnInitialize() mDefaultCamera.SetProperty(Dali::Actor::Property::ANCHOR_POINT, AnchorPoint::CENTER); AddCamera(mDefaultCamera); UpdateCamera(mDefaultCamera); + + if(mUseFrameBuffer) + { + SetOffScreenRenderableType(OffScreenRenderable::Type::FORWARD); + } } void SceneView::OnChildAdd(Actor& child) @@ -1420,6 +1452,8 @@ void SceneView::UpdateRenderTask() } else { + mRenderTask.SetOrderIndex(SCENE_ORDER_INDEX); + mRenderTask.SetViewportGuideActor(Self()); if(mRenderTask.GetFrameBuffer()) { @@ -1625,6 +1659,10 @@ void SceneView::UpdateShadowMapBuffer(uint32_t shadowMapSize) mShadowMapRenderTask.SetClearColor(Color::WHITE); mShadowMapRenderTask.SetRenderPassTag(10); mShadowMapRenderTask.SetCameraActor(GetImplementation(mShadowLight).GetCamera()); + } + + if(!mUseFrameBuffer) + { mShadowMapRenderTask.SetOrderIndex(SHADOW_ORDER_INDEX); } diff --git a/dali-scene3d/internal/controls/scene-view/scene-view-impl.h b/dali-scene3d/internal/controls/scene-view/scene-view-impl.h index 694594d93d..86d3f9e038 100644 --- a/dali-scene3d/internal/controls/scene-view/scene-view-impl.h +++ b/dali-scene3d/internal/controls/scene-view/scene-view-impl.h @@ -361,6 +361,16 @@ public: */ static Property::Value GetProperty(BaseObject* object, Property::Index index); + /** + * @copydoc Toolkit::Internal::Control::GetOffScreenRenderableSourceActor + */ + Dali::Actor GetOffScreenRenderableSourceActor() override; + + /** + * @copydoc Toolkit::Internal::Control::IsOffScreenRenderTaskExclusive + */ + bool IsOffScreenRenderTaskExclusive() override; + protected: /** * @brief Constructs a new SceneView. @@ -383,6 +393,11 @@ private: */ void OnSceneDisconnection() override; + /** + * @copydoc CustomActorImpl::GetOffScreenRenderTasks() + */ + void GetOffScreenRenderTasks(std::vector& tasks, bool isForward) override; + /** * @copydoc Toolkit::Control::OnInitialize() */ diff --git a/dali-toolkit/internal/controls/render-effects/blur-effect-impl.cpp b/dali-toolkit/internal/controls/render-effects/blur-effect-impl.cpp index 987c582d16..fa64963d37 100644 --- a/dali-toolkit/internal/controls/render-effects/blur-effect-impl.cpp +++ b/dali-toolkit/internal/controls/render-effects/blur-effect-impl.cpp @@ -26,19 +26,20 @@ #include #include #include +#include -//INTERNAL INCLUDES +// INTERNAL INCLUDES #include #include #include #include +#include namespace { // Default values static constexpr float BLUR_EFFECT_DOWNSCALE_FACTOR = 0.4f; static constexpr uint32_t BLUR_EFFECT_PIXEL_RADIUS = 10u; -static constexpr int32_t BLUR_EFFECT_ORDER_INDEX = 101; static constexpr float MINIMUM_DOWNSCALE_FACTOR = 0.1f; static constexpr float MAXIMUM_DOWNSCALE_FACTOR = 1.0f; @@ -141,6 +142,47 @@ BlurEffectImplPtr BlurEffectImpl::New(float downscaleFactor, uint32_t blurRadius return handle; } +OffScreenRenderable::Type BlurEffectImpl::GetOffScreenRenderableType() +{ + return mSkipBlur ? OffScreenRenderable::NONE : OffScreenRenderable::BACKWARD; +} + +void BlurEffectImpl::GetOffScreenRenderTasks(std::vector& tasks, bool isForward) +{ + tasks.clear(); + if(!isForward && mIsBackground) + { + bool isExclusiveRequired = false; + Dali::Actor sourceActor = GetOwnerControl(); + while(sourceActor.GetParent()) + { + sourceActor = sourceActor.GetParent(); + Toolkit::Control control = Toolkit::Control::DownCast(sourceActor); + if(control && GetImplementation(control).GetOffScreenRenderableType() == OffScreenRenderable::Type::FORWARD) + { + sourceActor = GetImplementation(control).GetOffScreenRenderableSourceActor(); + isExclusiveRequired = GetImplementation(control).IsOffScreenRenderTaskExclusive(); + break; + } + } + mSourceRenderTask.SetSourceActor(sourceActor); + mSourceRenderTask.SetExclusive(isExclusiveRequired); + + if(mSourceRenderTask) + { + tasks.push_back(mSourceRenderTask); + } + if(mHorizontalBlurTask) + { + tasks.push_back(mHorizontalBlurTask); + } + if(mVerticalBlurTask) + { + tasks.push_back(mVerticalBlurTask); + } + } +} + void BlurEffectImpl::OnInitialize() { if(DALI_UNLIKELY(mSkipBlur)) @@ -348,7 +390,6 @@ void BlurEffectImpl::CreateRenderTasks(Integration::SceneHolder sceneHolder, con { mSourceRenderTask.SetSourceActor(sourceControl); } - mSourceRenderTask.SetOrderIndex(BLUR_EFFECT_ORDER_INDEX); mSourceRenderTask.SetCameraActor(mRenderFullSizeCamera); mSourceRenderTask.SetFrameBuffer(mInputBackgroundFrameBuffer); mSourceRenderTask.SetInputEnabled(false); @@ -362,7 +403,6 @@ void BlurEffectImpl::CreateRenderTasks(Integration::SceneHolder sceneHolder, con SetRendererTexture(mHorizontalBlurActor.GetRendererAt(0), mInputBackgroundFrameBuffer); mHorizontalBlurTask = taskList.CreateTask(); mHorizontalBlurTask.SetSourceActor(mHorizontalBlurActor); - mHorizontalBlurTask.SetOrderIndex(BLUR_EFFECT_ORDER_INDEX + 1); mHorizontalBlurTask.SetExclusive(true); mHorizontalBlurTask.SetInputEnabled(false); mHorizontalBlurTask.SetCameraActor(mRenderDownsampledCamera); @@ -376,7 +416,6 @@ void BlurEffectImpl::CreateRenderTasks(Integration::SceneHolder sceneHolder, con SetRendererTexture(mVerticalBlurActor.GetRendererAt(0), mTemporaryFrameBuffer); mVerticalBlurTask = taskList.CreateTask(); mVerticalBlurTask.SetSourceActor(mVerticalBlurActor); - mVerticalBlurTask.SetOrderIndex(BLUR_EFFECT_ORDER_INDEX + 2); mVerticalBlurTask.SetExclusive(true); mVerticalBlurTask.SetInputEnabled(false); mVerticalBlurTask.SetCameraActor(mRenderDownsampledCamera); diff --git a/dali-toolkit/internal/controls/render-effects/blur-effect-impl.h b/dali-toolkit/internal/controls/render-effects/blur-effect-impl.h index 6147398d53..def332405b 100644 --- a/dali-toolkit/internal/controls/render-effects/blur-effect-impl.h +++ b/dali-toolkit/internal/controls/render-effects/blur-effect-impl.h @@ -69,6 +69,16 @@ public: */ static BlurEffectImplPtr New(float downscaleFactor, uint32_t blurRadius, bool isBackground); + /** + * @copydoc Toolkit::Internal::RenderEffectImpl::GetOffScreenRenderableType + */ + OffScreenRenderable::Type GetOffScreenRenderableType() override; + + /** + * @copydoc Toolkit::Internal::RenderEffectImpl::GetOffScreenRenderTasks + */ + void GetOffScreenRenderTasks(std::vector& tasks, bool isForward) override; + protected: /** * @brief Creates an uninitialized blur effect implementation diff --git a/dali-toolkit/internal/controls/render-effects/render-effect-impl.h b/dali-toolkit/internal/controls/render-effects/render-effect-impl.h index 3913bcbdcd..39a7abde00 100644 --- a/dali-toolkit/internal/controls/render-effects/render-effect-impl.h +++ b/dali-toolkit/internal/controls/render-effects/render-effect-impl.h @@ -60,6 +60,29 @@ public: */ bool IsActivated() const; + /** + * @brief Retrieves OffScreenRenderableType of this RenderEffect. + * + * @return OffScreenRenderableType for this RenderEffect. + */ + virtual OffScreenRenderable::Type GetOffScreenRenderableType() = 0; + + /** + * @brief Retrieves the off-screen RenderTasks associated with the RenderEffect. + * This method returns the internal RenderTasks held by the RenderEffect. This tasks are + * used for off-screen rendering, and the system will assign order index to each + * tasks based on the render order. + * + * RenderEffect with a non-NONE OffScreenRenderableType should override this method to + * provide their render tasks. + * + * @param[out] tasks A list of RenderTasks to be populated with the RenderEffect's forward + * or backward off-screen RenderTask. + * @param[in] isForward Indicates whether to retrieve forward (true) or backward (false) + * RenderTasks. + */ + virtual void GetOffScreenRenderTasks(std::vector& tasks, bool isForward) = 0; + protected: /** * @copydoc Dali::Toolkit::RenderEffect::RenderEffect diff --git a/dali-toolkit/public-api/controls/control-impl.cpp b/dali-toolkit/public-api/controls/control-impl.cpp index 068fb03503..03e4b94506 100644 --- a/dali-toolkit/public-api/controls/control-impl.cpp +++ b/dali-toolkit/public-api/controls/control-impl.cpp @@ -181,6 +181,8 @@ void Control::SetRenderEffect(Toolkit::RenderEffect effect) Dali::Toolkit::Control ownerControl(GetOwner()); object->SetOwnerControl(ownerControl); + + SetOffScreenRenderableType(object->GetOffScreenRenderableType()); } } } @@ -197,6 +199,7 @@ void Control::ClearRenderEffect() } mImpl->mRenderEffect.Reset(); } + SetOffScreenRenderableType(OffScreenRenderable::NONE); } void Control::SetResourceReady() @@ -205,6 +208,17 @@ void Control::SetResourceReady() controlDataImpl.ResourceReady(); } +Dali::Actor Control::GetOffScreenRenderableSourceActor() +{ + // Need to override this in FORWARD OffScreenRenderable + return Dali::Actor(); +} + +bool Control::IsOffScreenRenderTaskExclusive() +{ + return false; +} + std::shared_ptr Control::GetAccessibleObject() { return mImpl->GetAccessibleObject(); @@ -655,6 +669,15 @@ void Control::OnSizeAnimation(Animation& animation, const Vector3& targetSize) // @todo size negotiate background to new size, animate as well? } +void Control::GetOffScreenRenderTasks(std::vector& tasks, bool isForward) +{ + if(mImpl->mRenderEffect) + { + Toolkit::Internal::RenderEffectImpl* object = dynamic_cast(mImpl->mRenderEffect.GetObjectPtr()); + object->GetOffScreenRenderTasks(tasks, isForward); + } +} + bool Control::OnKeyEvent(const KeyEvent& event) { return false; // Do not consume diff --git a/dali-toolkit/public-api/controls/control-impl.h b/dali-toolkit/public-api/controls/control-impl.h index 76991aa0a0..616aa4897d 100644 --- a/dali-toolkit/public-api/controls/control-impl.h +++ b/dali-toolkit/public-api/controls/control-impl.h @@ -129,6 +129,24 @@ public: */ void SetResourceReady(); + /** + * @brief Retrieves SourceActor of the OffScreenRenderable. + * + * @SINCE_2_3.43 + * @return SourceActor of the OffScreenRenderable. + */ + virtual Dali::Actor GetOffScreenRenderableSourceActor(); + + /** + * @brief Retrieves whether the OffScreen RenderTasks is exclusive or not. + * The SourceActor of an OffScreen RenderTask can also become the SourceActor of another Actor's OffScreen RenderTask. + * To draw the SourceActor multitimes, the exclusive information is required. + * + * @SINCE_2_3.43 + * @return True if the RenderTask is exclusive. + */ + virtual bool IsOffScreenRenderTaskExclusive(); + // Accessibility /** @@ -362,6 +380,11 @@ protected: // From CustomActorImpl */ void OnSizeAnimation(Animation& animation, const Vector3& targetSize) override; + /** + * @copydoc CustomActorImpl::GetOffScreenRenderTasks() + */ + void GetOffScreenRenderTasks(std::vector& tasks, bool isForward) override; + /** * @copydoc CustomActorImpl::OnRelayout() */ -- 2.34.1