[Tizen] Get the id of animation and render task 16/308916/1
authorEunki Hong <eunkiki.hong@samsung.com>
Tue, 6 Feb 2024 15:35:48 +0000 (00:35 +0900)
committerEunki Hong <eunkiki.hong@samsung.com>
Tue, 2 Apr 2024 16:23:27 +0000 (01:23 +0900)
Let we support to get the id of Animation and RenderTask, follow by NotifyInterface notify id.

Change-Id: I56b6a0d27ceae4024fb52255062ebd00b87332eb
Signed-off-by: Eunki Hong <eunkiki.hong@samsung.com>
automated-tests/src/dali/utc-Dali-Animation.cpp
automated-tests/src/dali/utc-Dali-RenderTask.cpp
dali/internal/event/animation/animation-impl.cpp
dali/internal/event/animation/animation-impl.h
dali/internal/event/render-tasks/render-task-impl.cpp
dali/internal/event/render-tasks/render-task-impl.h
dali/public-api/animation/animation.cpp
dali/public-api/animation/animation.h
dali/public-api/render-tasks/render-task.cpp
dali/public-api/render-tasks/render-task.h

index f360cbd..c2705c1 100644 (file)
@@ -15947,3 +15947,23 @@ int UtcDaliAnimationPlayBlendQuaternion(void)
 
   END_TEST;
 }
+
+int UtcDaliAnimationGetAnimationId(void)
+{
+  TestApplication application;
+
+  Animation animation = Animation::New(1.0f);
+
+  // Let we check id is not zero
+  DALI_TEST_CHECK(animation.GetAnimationId() != 0u);
+
+  auto previousId = animation.GetAnimationId();
+
+  animation.Clear();
+
+  // Let we check id is same even after we call Clear()
+  DALI_TEST_CHECK(animation.GetAnimationId() != 0u);
+  DALI_TEST_CHECK(animation.GetAnimationId() == previousId);
+
+  END_TEST;
+}
\ No newline at end of file
index 1d08d66..cf7bd97 100644 (file)
@@ -4384,3 +4384,28 @@ int UtcDaliRenderTaskOrderIndex02(void)
 
   END_TEST;
 }
+
+int UtcDaliRenderTaskGetRenderTaskId(void)
+{
+  TestApplication application;
+  tet_infoline("Testing RenderTask Id get");
+
+  Stage   stage = Stage::GetCurrent();
+  Vector2 stageSize(stage.GetSize());
+
+  RenderTaskList renderTaskList = stage.GetRenderTaskList();
+
+  RenderTask renderTask1 = renderTaskList.CreateTask();
+  RenderTask renderTask2 = renderTaskList.CreateTask();
+  RenderTask renderTask3 = renderTaskList.CreateTask();
+
+  DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != 0u);
+  DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != 0u);
+  DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != 0u);
+  
+  DALI_TEST_CHECK(renderTask1.GetRenderTaskId() != renderTask2.GetRenderTaskId());
+  DALI_TEST_CHECK(renderTask2.GetRenderTaskId() != renderTask3.GetRenderTaskId());
+  DALI_TEST_CHECK(renderTask3.GetRenderTaskId() != renderTask1.GetRenderTaskId());
+
+  END_TEST;
+}
index ba2b1ab..5ef758c 100644 (file)
@@ -192,6 +192,10 @@ void Animation::CreateSceneObject()
 
   // Create a new animation, Keep a const pointer to the animation.
   mAnimation = SceneGraph::Animation::New(mDurationSeconds, mSpeedFactor, mPlayRange, mLoopCount, mEndAction, mDisconnectAction);
+
+  // Set id of scene graph animation
+  mAnimationId = mAnimation->GetNotifyId();
+
   OwnerPointer<SceneGraph::Animation> transferOwnership(const_cast<SceneGraph::Animation*>(mAnimation));
   AddAnimationMessage(mEventThreadServices.GetUpdateManager(), transferOwnership);
 
@@ -209,6 +213,9 @@ void Animation::DestroySceneObject()
     // Remove animation using a message to the update manager
     RemoveAnimationMessage(mEventThreadServices.GetUpdateManager(), *mAnimation);
     mAnimation = nullptr;
+
+    // Reset id
+    mAnimationId = 0u;
   }
 }
 
@@ -1095,6 +1102,11 @@ Dali::Animation::LoopingMode Animation::GetLoopingMode() const
   return mAutoReverseEnabled ? Dali::Animation::AUTO_REVERSE : Dali::Animation::RESTART;
 }
 
+uint32_t Animation::GetAnimationId() const
+{
+  return mAnimationId;
+}
+
 bool Animation::CompareConnectorEndTimes(const Animation::ConnectorTargetValues& lhs, const Animation::ConnectorTargetValues& rhs)
 {
   return ((lhs.timePeriod.delaySeconds + lhs.timePeriod.durationSeconds) < (rhs.timePeriod.delaySeconds + rhs.timePeriod.durationSeconds));
index dd91ff8..ab23d10 100644 (file)
@@ -401,6 +401,11 @@ public:
    */
   Dali::Animation::LoopingMode GetLoopingMode() const;
 
+  /**
+   * @copydoc Dali::Animation::GetAnimationId()
+   */
+  uint32_t GetAnimationId() const;
+
 public: // For connecting animators to animations
   /**
    * Add an animator connector.
@@ -562,6 +567,8 @@ private:
   AnimatorConnectorContainer     mConnectors{};            ///< Owned by the Animation
   ConnectorTargetValuesContainer mConnectorTargetValues{}; //< Used to store animating property target value information
 
+  uint32_t mAnimationId{0u};
+
   AlphaFunction          mDefaultAlpha;
   Vector2                mPlayRange{0.0f, 1.0f};
   float                  mBlendPoint{0.0f};
index 72c65b6..7ceaeb3 100644 (file)
@@ -20,6 +20,7 @@
 
 // EXTERNAL INCLUDES
 #include <cstring> // for strcmp
+#include "render-task-impl.h"
 
 // INTERNAL INCLUDES
 #include <dali/internal/event/actors/actor-impl.h>
@@ -617,7 +618,12 @@ void RenderTask::SetOrderIndex(int32_t orderIndex)
   if(mOrderIndex != orderIndex)
   {
     mOrderIndex = orderIndex;
-    mRenderTaskList.RequestToSort();
+
+    // We only need to sort render task list if it is valid.
+    if(GetRenderTaskSceneObject())
+    {
+      mRenderTaskList.RequestToSort();
+    }
   }
 }
 
@@ -626,6 +632,11 @@ int32_t RenderTask::GetOrderIndex() const
   return mOrderIndex;
 }
 
+uint32_t RenderTask::GetRenderTaskId() const
+{
+  return mRenderTaskId;
+}
+
 const SceneGraph::RenderTask* RenderTask::GetRenderTaskSceneObject() const
 {
   return static_cast<const SceneGraph::RenderTask*>(mUpdateObject);
@@ -939,6 +950,9 @@ RenderTask::RenderTask(const SceneGraph::RenderTask* sceneObject, RenderTaskList
   mCullMode(Dali::RenderTask::DEFAULT_CULL_MODE),
   mRequiresSync(false)
 {
+  // Set id of render task
+  mRenderTaskId = sceneObject->GetNotifyId();
+
   DALI_LOG_INFO(gLogRender, Debug::General, "RenderTask::RenderTask(this:%p)\n", this);
   // scene object handles observation of source and camera
 }
index 62ddd86..f8897b0 100644 (file)
@@ -279,6 +279,11 @@ public:
    */
   int32_t GetOrderIndex() const;
 
+  /**
+   * @copydoc Dali::RenderTask::GetRenderTaskId()
+   */
+  uint32_t GetRenderTaskId() const;
+
 public: // Used by RenderTaskList, which owns the SceneGraph::RenderTasks
   /**
    * Retrieve the scene-graph RenderTask object.
@@ -402,6 +407,8 @@ private:
   uint32_t mRenderPassTag{0u};
   int32_t mOrderIndex{0u};
 
+  uint32_t mRenderTaskId{0u};
+
   bool mExclusive : 1;    ///< True if the render-task has exclusive access to the source Nodes.
   bool mInputEnabled : 1; ///< True if the render-task should be considered for input handling.
   bool mClearEnabled : 1; ///< True if the render-task should be clear the color buffer.
index 53e8ee0..ba93d6f 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -166,6 +166,11 @@ Animation::LoopingMode Animation::GetLoopingMode() const
   return GetImplementation(*this).GetLoopingMode();
 }
 
+uint32_t Animation::GetAnimationId() const
+{
+  return GetImplementation(*this).GetAnimationId();
+}
+
 Animation::AnimationSignalType& Animation::FinishedSignal()
 {
   return GetImplementation(*this).FinishedSignal();
index 639bfb6..fafc1f0 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_ANIMATION_H
 
 /*
- * Copyright (c) 2023 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2024 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -523,6 +523,14 @@ public:
   LoopingMode GetLoopingMode() const;
 
   /**
+   * @brief Get the unique id of Animation. It could be 0 given animation is invalid.
+   *
+   * @SINCE_2_3.14
+   * @return The unique id of Animation, or 0 if invalid.
+   */
+  uint32_t GetAnimationId() const;
+
+  /**
    * @brief Connects to this signal to be notified when an Animation's animations have finished.
    *
    * @SINCE_1_0.0
index aaa1328..4521f44 100644 (file)
@@ -302,6 +302,11 @@ int32_t RenderTask::GetOrderIndex() const
   return GetImplementation(*this).GetOrderIndex();
 }
 
+uint32_t RenderTask::GetRenderTaskId() const
+{
+  return GetImplementation(*this).GetRenderTaskId();
+}
+
 RenderTask::RenderTask(Internal::RenderTask* internal)
 : Handle(internal)
 {
index ea4265f..6eab3d4 100644 (file)
@@ -571,6 +571,14 @@ public:
    */
   int32_t GetOrderIndex() const;
 
+  /**
+   * @brief Get the unique id of RenderTask. It could be 0 given render task is invalid.
+   *
+   * @SINCE_2_3.10
+   * @return The unique id of RenderTask, or 0 if invalid.
+   */
+  uint32_t GetRenderTaskId() const;
+
 public: // Signals
   /**
    * @brief If the refresh rate is REFRESH_ONCE, connect to this signal to be notified when a RenderTask has finished.