Support OffScreenRenderable Ordering when the sibling order is chaged. 17/320217/4
authorSeungho Baek <sbsh.baek@samsung.com>
Mon, 11 Nov 2024 05:33:34 +0000 (14:33 +0900)
committerSeungho Baek <sbsh.baek@samsung.com>
Tue, 12 Nov 2024 05:10:44 +0000 (14:10 +0900)
Change-Id: I65ef042f122a114778da87ffb44d2cb2dc9c63fc
Signed-off-by: Seungho Baek <sbsh.baek@samsung.com>
automated-tests/src/dali/utc-Dali-CustomActor.cpp
dali/internal/event/actors/actor-parent-impl.cpp
dali/internal/event/actors/actor-parent-impl.h
dali/internal/event/render-tasks/render-task-list-impl.h

index 43ffeac65bd6fce7ce782323ca111c4a3bd5288d..6398dcfc189752137aaa0f4df47f25dad3978bf4 100644 (file)
@@ -1722,7 +1722,6 @@ class OffScreenCustomActor : public UnregisteredCustomActor
 public:
   void OnSceneConnection(int depth) override
   {
-    tet_printf("tyty : %d\n", GetOffScreenRenderableType());
     Dali::Integration::Scene scene = Dali::Integration::Scene::Get(Self());
     if(scene)
     {
@@ -1892,5 +1891,85 @@ int UtcDaliCustomActorReordering(void)
   DALI_TEST_CHECK(J_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() < B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
   DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() < E_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
 
+  END_TEST;
+}
+
+int UtcDaliCustomActorReordering2(void)
+{
+  TestApplication application; // Need the type registry
+
+  DALI_TEST_EQUALS(application.GetScene().GetRenderTaskList().GetTaskCount(), 1, TEST_LOCATION);
+
+  /**
+   *          Al
+   *       /     \
+   *      Bb      Cb
+   * 
+   * A is Layer. 
+   * B and C are BACKWARD OffScreenRenderable
+   *
+   * At the initial status, the OrderIndex of each RenderTask is
+   * B(Backward) - C(Backward)
+   *
+   * if we change sibling order to call RaiseToTop of B, the OrderIndex of each RenderTask becomes
+   * C(Backward) - B(Backward)
+   */
+
+  Layer A_layer = Layer::New();
+  OffScreenCustomActor B_offScreenCustomActor = OffScreenCustomActor::New(OffScreenRenderable::Type::BACKWARD);
+  OffScreenCustomActor C_offScreenCustomActor = OffScreenCustomActor::New(OffScreenRenderable::Type::BACKWARD);
+
+  application.GetScene().Add(A_layer);
+
+  DALI_TEST_EQUALS(application.GetScene().GetRenderTaskList().GetTaskCount(), 1, TEST_LOCATION);
+  tet_printf("task cnt before : %d\n", application.GetScene().GetRenderTaskList().GetTaskCount());
+
+  A_layer.Add(B_offScreenCustomActor);
+  DALI_TEST_EQUALS(application.GetScene().GetRenderTaskList().GetTaskCount(), 3, TEST_LOCATION);
+
+  A_layer.Add(C_offScreenCustomActor);
+  DALI_TEST_EQUALS(application.GetScene().GetRenderTaskList().GetTaskCount(), 5, TEST_LOCATION);
+
+  application.SendNotification();
+
+  tet_printf("B OrderIndex : %d, C OrderIndex : %d\n", B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex(), C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+  DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() < C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+
+  B_offScreenCustomActor.RaiseToTop();
+  application.SendNotification();
+
+  tet_printf("B OrderIndex : %d, C OrderIndex : %d\n", B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex(), C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+  DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() > C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+
+  B_offScreenCustomActor.LowerToBottom();
+  application.SendNotification();
+
+  tet_printf("B OrderIndex : %d, C OrderIndex : %d\n", B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex(), C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+  DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() < C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+
+  B_offScreenCustomActor.RaiseAbove(C_offScreenCustomActor);
+  application.SendNotification();
+
+  tet_printf("B OrderIndex : %d, C OrderIndex : %d\n", B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex(), C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+  DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() > C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+
+  B_offScreenCustomActor.LowerBelow(C_offScreenCustomActor);
+  application.SendNotification();
+
+  tet_printf("B OrderIndex : %d, C OrderIndex : %d\n", B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex(), C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+  DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() < C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+
+  B_offScreenCustomActor.Raise();
+  application.SendNotification();
+
+  tet_printf("B OrderIndex : %d, C OrderIndex : %d\n", B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex(), C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+  DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() > C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+
+  B_offScreenCustomActor.Lower();
+  application.SendNotification();
+
+  tet_printf("B OrderIndex : %d, C OrderIndex : %d\n", B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex(), C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+  DALI_TEST_CHECK(B_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex() < C_offScreenCustomActor.GetBackwardRenderTask().GetOrderIndex());
+
   END_TEST;
 }
\ No newline at end of file
index 31def8cabbc9ef7f3faafeebb50b936639817bad..253fc6183f49e361baf33a74e5503596210aec2f 100644 (file)
@@ -22,6 +22,7 @@
 #include <dali/internal/event/actors/actor-impl.h>
 #include <dali/internal/event/common/scene-impl.h>
 #include <dali/public-api/common/vector-wrapper.h>
+#include <dali/internal/event/render-tasks/render-task-list-impl.h>
 
 // EXTERNAL INCLUDES
 #include <algorithm>
@@ -294,6 +295,7 @@ void ActorParentImpl::RaiseChild(Actor& child)
   }
   if(changed)
   {
+    RequestRenderTaskReorderRecursively();
     EmitOrderChangedAndRebuild(child);
   }
 }
@@ -318,6 +320,7 @@ void ActorParentImpl::LowerChild(Actor& child)
   }
   if(changed)
   {
+    RequestRenderTaskReorderRecursively();
     EmitOrderChangedAndRebuild(child);
   }
 }
@@ -339,6 +342,7 @@ void ActorParentImpl::RaiseChildToTop(Actor& child)
   }
   if(changed)
   {
+    RequestRenderTaskReorderRecursively();
     EmitOrderChangedAndRebuild(child);
   }
 }
@@ -360,6 +364,7 @@ void ActorParentImpl::LowerChildToBottom(Actor& child)
   }
   if(changed)
   {
+    RequestRenderTaskReorderRecursively();
     EmitOrderChangedAndRebuild(child);
   }
 }
@@ -386,6 +391,7 @@ void ActorParentImpl::RaiseChildAbove(Actor& child, Actor& target)
   }
   if(raised)
   {
+    RequestRenderTaskReorderRecursively();
     EmitOrderChangedAndRebuild(child);
   }
 }
@@ -411,6 +417,7 @@ void ActorParentImpl::LowerChildBelow(Actor& child, Actor& target)
   }
   if(lowered)
   {
+    RequestRenderTaskReorderRecursively();
     EmitOrderChangedAndRebuild(child);
   }
 }
@@ -566,6 +573,25 @@ void ActorParentImpl::InheritVisibilityRecursively(ActorContainer& inheritedVisi
   }
 }
 
+void ActorParentImpl::RequestRenderTaskReorderRecursively()
+{
+  if(mOwner.OnScene() && mOwner.GetScene().GetRenderTaskList().IsReorderRequested())
+  {
+    return;
+  }
+
+  mOwner.RequestRenderTaskReorder();
+
+  if(mChildren)
+  {
+    for(const auto& child : *mChildren)
+    {
+      child->mParentImpl.RequestRenderTaskReorderRecursively();
+    }
+  }
+}
+
+
 void ActorParentImpl::EmitChildAddedSignal(Actor& child)
 {
   EmitSignal(child, mChildAddedSignal);
index 9642b167e02bf72240b047ed4b33f5021deaa203..4df143a4bae8a2f6e937fec8b93003d25d25e0a1 100644 (file)
@@ -246,6 +246,12 @@ public:
    */
   void InheritVisibilityRecursively(ActorContainer& inheritedVisibilityChangedList);
 
+  /**
+   * @brief Propagates request of RenderTask reordering to its' children.
+   * Once the reorder is requested to the RenderTaskList, the traversal is finished.
+   */
+  void RequestRenderTaskReorderRecursively();
+
 private:
   /**
    * @brief Emits the ChildAdded signal for this actor
index 80ff62284953d4118b2ffd0afe92b1edd2a1bed8..957deb9241a28f2934946fec6e3dc968fb45d53a 100644 (file)
@@ -172,6 +172,14 @@ public:
     mIsRequestedToReorderTask = true;
   }
 
+  /**
+   * @brief Retrieve whether Reordering is required or not.
+   */
+  bool IsReorderRequested() const
+  {
+    return mIsRequestedToReorderTask;
+  }
+
   /**
    * @brief Reorder RenderTasks along the priority of OffScreenRenderableType of each Actor.
    *