From 0ff5139db4c9a0603e1d17ccc862a2ca1ca2b42b Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Wed, 22 Feb 2023 17:37:31 +0900 Subject: [PATCH] [Tizen] Fix surface deletion order issue Change-Id: I1fb3a2934ed6a36553421f002d6cc7821abc45dc --- dali/integration-api/scene.cpp | 7 +++- dali/integration-api/scene.h | 7 +++- dali/internal/event/common/scene-impl.cpp | 45 +++++++++++++++---------- dali/internal/event/common/scene-impl.h | 7 +++- dali/internal/render/common/render-manager.cpp | 14 ++++++-- dali/internal/update/common/scene-graph-scene.h | 8 +++++ dali/internal/update/manager/update-manager.cpp | 4 ++- 7 files changed, 68 insertions(+), 24 deletions(-) diff --git a/dali/integration-api/scene.cpp b/dali/integration-api/scene.cpp index 26d72ac..b1781a9 100644 --- a/dali/integration-api/scene.cpp +++ b/dali/integration-api/scene.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -124,6 +124,11 @@ void Scene::SurfaceReplaced() GetImplementation(*this).SurfaceReplaced(); } +void Scene::RemoveSceneObject() +{ + GetImplementation(*this).RemoveSceneObject(); +} + void Scene::Discard() { GetImplementation(*this).Discard(); diff --git a/dali/integration-api/scene.h b/dali/integration-api/scene.h index 4a851a2..5e4a3e4 100644 --- a/dali/integration-api/scene.h +++ b/dali/integration-api/scene.h @@ -2,7 +2,7 @@ #define DALI_SCENE_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -230,6 +230,11 @@ public: void SurfaceReplaced(); /** + * @brief Removes the scene graph object. + */ + void RemoveSceneObject(); + + /** * @brief Discards this Scene from the Core. */ void Discard(); diff --git a/dali/internal/event/common/scene-impl.cpp b/dali/internal/event/common/scene-impl.cpp index 56ed507..d60e48b 100644 --- a/dali/internal/event/common/scene-impl.cpp +++ b/dali/internal/event/common/scene-impl.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -65,12 +65,6 @@ Scene::Scene() Scene::~Scene() { - if(EventThreadServices::IsCoreRunning() && mSceneObject) - { - ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal(); - RemoveSceneMessage(tls->GetUpdateManager(), *mSceneObject); - } - if(mDefaultCamera) { // its enough to release the handle so the object is released @@ -241,9 +235,19 @@ void Scene::SurfaceReplaced() } } +void Scene::RemoveSceneObject() +{ + if(EventThreadServices::IsCoreRunning() && mSceneObject) + { + ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal(); + RemoveSceneMessage(tls->GetUpdateManager(), *mSceneObject); + mSceneObject = nullptr; + } +} + void Scene::Discard() { - if(ThreadLocalStorage::Created()) + if(EventThreadServices::IsCoreRunning()) { ThreadLocalStorage* tls = ThreadLocalStorage::GetInternal(); tls->RemoveScene(this); @@ -310,22 +314,23 @@ void Scene::SurfaceRotated(float width, float height, int32_t windowOrientation, int32_t Scene::GetCurrentSurfaceOrientation() const { - return mSceneObject->GetSurfaceOrientation(); + return mSceneObject ? mSceneObject->GetSurfaceOrientation() : 0; } int32_t Scene::GetCurrentScreenOrientation() const { - return mSceneObject->GetScreenOrientation(); + return mSceneObject ? mSceneObject->GetScreenOrientation() : 0; } const Rect& Scene::GetCurrentSurfaceRect() const { - return mSceneObject->GetSurfaceRect(); + static Rect emptyRect{}; + return mSceneObject ? mSceneObject->GetSurfaceRect() : emptyRect; } void Scene::ChangedSurface(float width, float height, int32_t windowOrientation, int32_t screenOrientation) { - bool changedOrientation = false; + bool changedOrientation = false; Rect newSize(0, 0, static_cast(width), static_cast(height)); // truncated mSize.width = width; mSize.height = height; @@ -336,7 +341,7 @@ void Scene::ChangedSurface(float width, float height, int32_t windowOrientation, } mSurfaceOrientation = windowOrientation; - mScreenOrientation = screenOrientation; + mScreenOrientation = screenOrientation; // Calculates the aspect ratio, near and far clipping planes, field of view and camera Z position. mDefaultCamera->SetPerspectiveProjection(mSize); @@ -372,12 +377,12 @@ void Scene::ChangedSurface(float width, float height, int32_t windowOrientation, bool Scene::IsSurfaceRectChanged() const { - return mSceneObject->IsSurfaceRectChanged(); + return mSceneObject ? mSceneObject->IsSurfaceRectChanged() : false; } bool Scene::IsRotationCompletedAcknowledgementSet() const { - return mSceneObject->IsRotationCompletedAcknowledgementSet(); + return mSceneObject ? mSceneObject->IsRotationCompletedAcknowledgementSet() : false; } void Scene::SetRotationCompletedAcknowledgement() @@ -455,12 +460,18 @@ void Scene::AddFramePresentedCallback(std::unique_ptr callback, in void Scene::GetFrameRenderedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks) { - mSceneObject->GetFrameRenderedCallback(callbacks); + if(mSceneObject) + { + mSceneObject->GetFrameRenderedCallback(callbacks); + } } void Scene::GetFramePresentedCallback(Dali::Integration::Scene::FrameCallbackContainer& callbacks) { - mSceneObject->GetFramePresentedCallback(callbacks); + if(mSceneObject) + { + mSceneObject->GetFramePresentedCallback(callbacks); + } } Integration::Scene::KeyEventSignalType& Scene::KeyEventSignal() diff --git a/dali/internal/event/common/scene-impl.h b/dali/internal/event/common/scene-impl.h index cda29a2..c431fee 100644 --- a/dali/internal/event/common/scene-impl.h +++ b/dali/internal/event/common/scene-impl.h @@ -2,7 +2,7 @@ #define DALI_INTERNAL_SCENE_H /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -133,6 +133,11 @@ public: void SurfaceReplaced(); /** + * @copydoc Dali::Integration::Scene::RemoveSceneObject + */ + void RemoveSceneObject(); + + /** * @copydoc Dali::Integration::Scene::Discard */ void Discard(); diff --git a/dali/internal/render/common/render-manager.cpp b/dali/internal/render/common/render-manager.cpp index 961830f..2bd20b7 100644 --- a/dali/internal/render/common/render-manager.cpp +++ b/dali/internal/render/common/render-manager.cpp @@ -486,7 +486,7 @@ void RenderManager::PreRender(Integration::Scene& scene, std::vector>& Internal::Scene& sceneInternal = GetImplementation(scene); SceneGraph::Scene* sceneObject = sceneInternal.GetSceneObject(); - if(sceneObject->IsRenderingSkipped()) + if(!sceneObject || sceneObject->IsRenderingSkipped()) { // We don't need to calculate dirty rects return; @@ -729,9 +729,13 @@ void RenderManager::PreRender(Integration::Scene& scene, std::vector>& void RenderManager::RenderScene(Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo) { - SceneGraph::Scene* sceneObject = GetImplementation(scene).GetSceneObject(); - Rect clippingRect = sceneObject->GetSurfaceRect(); + SceneGraph::Scene* sceneObject = GetImplementation(scene).GetSceneObject(); + if(!sceneObject) + { + return; + } + Rect clippingRect = sceneObject->GetSurfaceRect(); RenderScene(status, scene, renderToFbo, clippingRect); } @@ -750,6 +754,10 @@ void RenderManager::RenderScene(Integration::RenderStatus& status, Integration:: Internal::Scene& sceneInternal = GetImplementation(scene); SceneGraph::Scene* sceneObject = sceneInternal.GetSceneObject(); + if(!sceneObject) + { + return; + } uint32_t count = sceneObject->GetRenderInstructions().Count(mImpl->renderBufferIndex); diff --git a/dali/internal/update/common/scene-graph-scene.h b/dali/internal/update/common/scene-graph-scene.h index 8d5339e..278d3f8 100644 --- a/dali/internal/update/common/scene-graph-scene.h +++ b/dali/internal/update/common/scene-graph-scene.h @@ -229,6 +229,14 @@ public: } /** + * Remove the render target of the surface + */ + void RemoveSurfaceRenderTarget() + { + mRenderTarget.reset(); + } + + /** * Get the graphics render pass created for the scene * * @return the graphics render pass diff --git a/dali/internal/update/manager/update-manager.cpp b/dali/internal/update/manager/update-manager.cpp index 1574b5d..c89ecbd 100644 --- a/dali/internal/update/manager/update-manager.cpp +++ b/dali/internal/update/manager/update-manager.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022 Samsung Electronics Co., Ltd. + * Copyright (c) 2023 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. @@ -538,6 +538,8 @@ void UpdateManager::RemoveScene(Scene* scene) // Construct message in the render queue memory; note that delete should not be called on the return value new(slot) DerivedType(&mImpl->renderManager, &RenderManager::UninitializeScene, scene); + scene->RemoveSurfaceRenderTarget(); + for(auto&& sceneInfo : mImpl->scenes) { if(sceneInfo && sceneInfo->scene && sceneInfo->scene.Get() == scene) -- 2.7.4