From: Eunki Hong Date: Thu, 30 Mar 2023 16:59:07 +0000 (+0900) Subject: Minor code cleans for render task X-Git-Tag: dali_2.2.21~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F83%2F290683%2F3;p=platform%2Fcore%2Fuifw%2Fdali-core.git Minor code cleans for render task 1. Ensure the overlayTask removal 2. Now SceneGraph::Camera is node. We can reduce useless duplicated codes. 3. mActive false if object destroyed when scene on Change-Id: I392acf79a22b5a1b68f382126e751575914529e8 Signed-off-by: Eunki Hong --- diff --git a/automated-tests/src/dali/utc-Dali-Scene.cpp b/automated-tests/src/dali/utc-Dali-Scene.cpp index 959e5ee..90d7d9e 100644 --- a/automated-tests/src/dali/utc-Dali-Scene.cpp +++ b/automated-tests/src/dali/utc-Dali-Scene.cpp @@ -2633,6 +2633,12 @@ int UtcDaliSceneGetOverlayLayer(void) DALI_TEST_EQUALS(tasks.GetTask(0u), defaultTask, TEST_LOCATION); DALI_TEST_EQUALS(tasks.GetTask(1u), newTask, TEST_LOCATION); + // Check overlay task removed well + DALI_TEST_EQUALS(nullptr, tasks.GetOverlayTask(), TEST_LOCATION); + + application.SendNotification(); + application.Render(); + END_TEST; } @@ -2662,7 +2668,7 @@ int UtcDaliSceneSurfaceResizedWithOverlayLayer(void) // There should be 2 task by default. DALI_TEST_EQUALS(tasks.GetTaskCount(), 2u, TEST_LOCATION); RenderTask overlayTask = tasks.GetTask(1u); - Viewport overlayViewport = defaultTask.GetViewport(); + Viewport overlayViewport = overlayTask.GetViewport(); DALI_TEST_EQUALS(defaultViewport, overlayViewport, TEST_LOCATION); // Resize the scene @@ -2671,7 +2677,7 @@ int UtcDaliSceneSurfaceResizedWithOverlayLayer(void) scene.SurfaceResized(newSize.width, newSize.height); Viewport newViewport(0, 0, newSize.x, newSize.y); DALI_TEST_EQUALS(newViewport, defaultTask.GetViewport(), TEST_LOCATION); - DALI_TEST_EQUALS(newViewport, defaultTask.GetViewport(), TEST_LOCATION); + DALI_TEST_EQUALS(newViewport, overlayTask.GetViewport(), TEST_LOCATION); END_TEST; } diff --git a/dali/internal/event/render-tasks/render-task-impl.cpp b/dali/internal/event/render-tasks/render-task-impl.cpp index cac0ab8..e991fa9 100644 --- a/dali/internal/event/render-tasks/render-task-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-impl.cpp @@ -152,11 +152,11 @@ void RenderTask::SetCameraActor(CameraActor* cameraActor) mCameraActor.SetActor(cameraActor); if(cameraActor) { - SetCameraMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), &cameraActor->GetNode(), &cameraActor->GetCameraSceneObject()); + SetCameraMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), &cameraActor->GetCameraSceneObject()); } else { - SetCameraMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr, nullptr); + SetCameraMessage(GetEventThreadServices(), GetRenderTaskSceneObject(), nullptr); } // set the actor on exclusive container for hit testing diff --git a/dali/internal/event/render-tasks/render-task-list-impl.cpp b/dali/internal/event/render-tasks/render-task-list-impl.cpp index 6f512d2..c2d6ffa 100644 --- a/dali/internal/event/render-tasks/render-task-list-impl.cpp +++ b/dali/internal/event/render-tasks/render-task-list-impl.cpp @@ -90,6 +90,11 @@ void RenderTaskList::RemoveTask(Internal::RenderTask& task) if(ptr == &task) { + if(mOverlayRenderTask == &task) + { + mOverlayRenderTask.Reset(); + } + const SceneGraph::RenderTask& sceneObject = task.GetRenderTaskSceneObject(); // delete the task diff --git a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp index 255b1b0..deb1795 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp +++ b/dali/internal/update/render-tasks/scene-graph-render-task-list.cpp @@ -94,6 +94,11 @@ void RenderTaskList::RemoveTask(RenderTask* task) { if(*iter == task) { + if(mOverlayRenderTask == task) + { + mOverlayRenderTask = nullptr; + } + // Destroy the task mRenderTasks.Erase(iter); diff --git a/dali/internal/update/render-tasks/scene-graph-render-task-messages.h b/dali/internal/update/render-tasks/scene-graph-render-task-messages.h index 8762f02..a65e27b 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task-messages.h +++ b/dali/internal/update/render-tasks/scene-graph-render-task-messages.h @@ -91,17 +91,16 @@ inline void SetSourceNodeMessage(EventThreadServices& eventThreadServices, const new(slot) LocalType(&task, &RenderTask::SetSourceNode, node); } -inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera) +inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Camera* constCamera) { - using LocalType = MessageValue2; + using LocalType = MessageValue1; - Node* node = const_cast(constNode); - Camera* camera = const_cast(constCamera); + Camera* cameraNode = const_cast(constCamera); // Reserve memory inside the message queue uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType)); // Construct message in the message queue memory; note that delete should not be called on the return value - new(slot) LocalType(&task, &RenderTask::SetCamera, node, camera); + new(slot) LocalType(&task, &RenderTask::SetCamera, cameraNode); } inline void SetViewportGuideNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode) diff --git a/dali/internal/update/render-tasks/scene-graph-render-task.cpp b/dali/internal/update/render-tasks/scene-graph-render-task.cpp index 1d1027e..1d8fe49 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task.cpp +++ b/dali/internal/update/render-tasks/scene-graph-render-task.cpp @@ -129,7 +129,7 @@ bool RenderTask::IsExclusive() const return mExclusive; } -void RenderTask::SetCamera(Node* cameraNode, Camera* camera) +void RenderTask::SetCamera(Camera* cameraNode) { if(mCameraNode) { @@ -137,7 +137,6 @@ void RenderTask::SetCamera(Node* cameraNode, Camera* camera) } mCameraNode = cameraNode; - mCamera = camera; if(mCameraNode) { @@ -345,34 +344,34 @@ uint32_t RenderTask::GetRenderedOnceCounter() const const Matrix& RenderTask::GetViewMatrix(BufferIndex bufferIndex) const { - DALI_ASSERT_DEBUG(nullptr != mCamera); + DALI_ASSERT_DEBUG(nullptr != mCameraNode); - return mCamera->GetViewMatrix(bufferIndex); + return mCameraNode->GetViewMatrix(bufferIndex); } const SceneGraph::Camera& RenderTask::GetCamera() const { - DALI_ASSERT_DEBUG(nullptr != mCamera); - return *mCamera; + DALI_ASSERT_DEBUG(nullptr != mCameraNode); + return *mCameraNode; } const Matrix& RenderTask::GetProjectionMatrix(BufferIndex bufferIndex) const { - DALI_ASSERT_DEBUG(nullptr != mCamera); + DALI_ASSERT_DEBUG(nullptr != mCameraNode); - return mCamera->GetProjectionMatrix(bufferIndex); + return mCameraNode->GetProjectionMatrix(bufferIndex); } RenderInstruction& RenderTask::PrepareRenderInstruction(BufferIndex updateBufferIndex) { - DALI_ASSERT_DEBUG(nullptr != mCamera); + DALI_ASSERT_DEBUG(nullptr != mCameraNode); TASK_LOG(Debug::General); Viewport viewport; bool viewportSet = QueryViewport(updateBufferIndex, viewport); - mRenderInstruction[updateBufferIndex].Reset(mCamera, + mRenderInstruction[updateBufferIndex].Reset(mCameraNode, GetFrameBuffer(), viewportSet ? &viewport : nullptr, mClearEnabled ? &GetClearColor(updateBufferIndex) : nullptr); @@ -400,9 +399,9 @@ RenderInstruction& RenderTask::PrepareRenderInstruction(BufferIndex updateBuffer bool RenderTask::ViewMatrixUpdated() { bool retval = false; - if(mCamera) + if(mCameraNode) { - retval = mCamera->ViewMatrixUpdated(); + retval = mCameraNode->ViewMatrixUpdated(); } return retval; } @@ -477,6 +476,8 @@ void RenderTask::PropertyOwnerDestroyed(PropertyOwner& owner) { mCameraNode = nullptr; } + + mActive = false; // if either source or camera destroyed, we're no longer active } void RenderTask::AddInitializeResetter(ResetterManager& manager) const @@ -499,7 +500,6 @@ RenderTask::RenderTask() mSourceNode(nullptr), mCameraNode(nullptr), mViewportGuideNode(nullptr), - mCamera(nullptr), mFrameBuffer(nullptr), mRefreshRate(Dali::RenderTask::DEFAULT_REFRESH_RATE), mFrameCounter(0u), @@ -523,7 +523,7 @@ void RenderTask::SetActiveStatus() // must have a source and camera both connected to scene mActive = (mSourceNode && mSourceNode->ConnectedToScene() && - mCameraNode && mCameraNode->ConnectedToScene() && mCamera); + mCameraNode && mCameraNode->ConnectedToScene()); TASK_LOG_FMT(Debug::General, " Source node(%x) active %d. Frame counter: %d\n", mSourceNode, mSourceNode && mSourceNode->ConnectedToScene(), mFrameCounter); TASK_LOG_FMT(Debug::General, " Camera node(%x) active %d\n", mCameraNode, mCameraNode && mCameraNode->ConnectedToScene()); diff --git a/dali/internal/update/render-tasks/scene-graph-render-task.h b/dali/internal/update/render-tasks/scene-graph-render-task.h index d244882..60b03ae 100644 --- a/dali/internal/update/render-tasks/scene-graph-render-task.h +++ b/dali/internal/update/render-tasks/scene-graph-render-task.h @@ -113,9 +113,8 @@ public: /** * Set the camera from which the scene is viewed. * @param[in] cameraNode that camera is connected with - * @param[in] camera to use. */ - void SetCamera(Node* cameraNode, Camera* camera); + void SetCamera(Camera* cameraNode); /** * Set the frame-buffer used as a render target. @@ -397,9 +396,8 @@ private: RenderMessageDispatcher* mRenderMessageDispatcher; Render::RenderTracker* mRenderSyncTracker; Node* mSourceNode; - Node* mCameraNode; + SceneGraph::Camera* mCameraNode; Node* mViewportGuideNode; - SceneGraph::Camera* mCamera; Render::FrameBuffer* mFrameBuffer; RenderInstruction mRenderInstruction[2]; ///< Owned double buffered render instruction. (Double buffered because this owns render commands for the currently drawn frame)