From 19d96f26b8b671e97bd300b95a79f68a649fd96b Mon Sep 17 00:00:00 2001 From: Heeyong Song Date: Wed, 22 Feb 2023 17:50:01 +0900 Subject: [PATCH] Fix surface deletion order Change-Id: If4be038a1b47f19cef703aad0d1f48c59d0fe3d3 --- .../adaptor-framework/scene-holder-impl.cpp | 10 +++++++++- .../common/combined-update-render-controller.cpp | 7 +++---- .../graphics/gles-impl/gles-graphics-render-target.cpp | 17 +++++++++-------- 3 files changed, 21 insertions(+), 13 deletions(-) diff --git a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp b/dali/integration-api/adaptor-framework/scene-holder-impl.cpp index 7aa6f29..31f0c36 100644 --- a/dali/integration-api/adaptor-framework/scene-holder-impl.cpp +++ b/dali/integration-api/adaptor-framework/scene-holder-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. @@ -85,11 +85,18 @@ SceneHolder::SceneHolder() SceneHolder::~SceneHolder() { + if(mScene) + { + // The scene graph object should be removed first. + mScene.RemoveSceneObject(); + } + if(mAdaptor) { mAdaptor->RemoveObserver(*mLifeCycleObserver.get()); mAdaptor->RemoveWindow(this); + // The event queue is flushed and we wait for the completion of the surface removal mAdaptor->DeleteSurface(*mSurface.get()); mAdaptor = nullptr; @@ -97,6 +104,7 @@ SceneHolder::~SceneHolder() if(mScene) { + // We should remove the surface from the Core last mScene.Discard(); } } diff --git a/dali/internal/adaptor/common/combined-update-render-controller.cpp b/dali/internal/adaptor/common/combined-update-render-controller.cpp index 4cc78b6..70a278d 100644 --- a/dali/internal/adaptor/common/combined-update-render-controller.cpp +++ b/dali/internal/adaptor/common/combined-update-render-controller.cpp @@ -552,8 +552,9 @@ void CombinedUpdateRenderController::UpdateRenderThread() LOG_UPDATE_RENDER_TRACE; // For thread safe - bool uploadOnly = mUploadWithoutRendering; - unsigned int surfaceResized = mSurfaceResized; + bool uploadOnly = mUploadWithoutRendering; + unsigned int surfaceResized = mSurfaceResized; + Dali::RenderSurfaceInterface* deletedSurface = ShouldSurfaceBeDeleted(); // Performance statistics are logged upon a VSYNC tick so use this point for a VSync marker AddPerformanceMarker(PerformanceInterface::VSYNC); @@ -740,8 +741,6 @@ void CombinedUpdateRenderController::UpdateRenderThread() ////////////////////////////// // DELETE SURFACE ////////////////////////////// - - Dali::RenderSurfaceInterface* deletedSurface = ShouldSurfaceBeDeleted(); if(DALI_UNLIKELY(deletedSurface)) { LOG_UPDATE_RENDER_TRACE_FMT("Deleting Surface"); diff --git a/dali/internal/graphics/gles-impl/gles-graphics-render-target.cpp b/dali/internal/graphics/gles-impl/gles-graphics-render-target.cpp index 8cfd3f1..b8171ae 100644 --- a/dali/internal/graphics/gles-impl/gles-graphics-render-target.cpp +++ b/dali/internal/graphics/gles-impl/gles-graphics-render-target.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2021 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. @@ -25,7 +25,6 @@ namespace Dali::Graphics::GLES { - RenderTarget::RenderTarget(const Graphics::RenderTargetCreateInfo& createInfo, Graphics::EglGraphicsController& controller) : RenderTargetResource(createInfo, controller) { @@ -39,16 +38,18 @@ RenderTarget::~RenderTarget() = default; void RenderTarget::DestroyResource() { - // This is a proper destructor - if(mCreateInfo.surface) - { - mController.DeleteSurfaceContext(static_cast(mCreateInfo.surface)); - } } void RenderTarget::DiscardResource() { mController.DiscardResource(this); + + // The surface context should be deleted now + if(mCreateInfo.surface) + { + mController.DeleteSurfaceContext(static_cast(mCreateInfo.surface)); + mCreateInfo.surface = nullptr; + } } GLES::Framebuffer* RenderTarget::GetFramebuffer() const @@ -61,4 +62,4 @@ Surface* RenderTarget::GetSurface() const return mCreateInfo.surface; } -} // namespace Dali::Graphics::GLES \ No newline at end of file +} // namespace Dali::Graphics::GLES -- 2.7.4