[Tizen] Fix surface deletion order
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / gles-graphics-render-target.cpp
index efdaeb2..b8171ae 100644 (file)
@@ -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.
 
 namespace Dali::Graphics::GLES
 {
-struct RenderTarget::Impl
-{
-  Impl(EglGraphicsController& controller)
-  : controller(controller){};
-
-  ~Impl() = default;
-
-  EglGraphicsController& controller;
-};
-
 RenderTarget::RenderTarget(const Graphics::RenderTargetCreateInfo& createInfo, Graphics::EglGraphicsController& controller)
 : RenderTargetResource(createInfo, controller)
 {
-  mImpl = std::make_unique<Impl>(controller);
-
   if(createInfo.surface)
   {
     controller.CreateSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(createInfo.surface));
   }
 }
 
-RenderTarget::~RenderTarget()
+RenderTarget::~RenderTarget() = default;
+
+void RenderTarget::DestroyResource()
 {
+}
+
+void RenderTarget::DiscardResource()
+{
+  mController.DiscardResource(this);
+
+  // The surface context should be deleted now
   if(mCreateInfo.surface)
   {
-    mImpl->controller.DeleteSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(mCreateInfo.surface));
+    mController.DeleteSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(mCreateInfo.surface));
+    mCreateInfo.surface = nullptr;
   }
 }
 
@@ -64,4 +62,4 @@ Surface* RenderTarget::GetSurface() const
   return mCreateInfo.surface;
 }
 
-} // namespace Dali::Graphics::GLES
\ No newline at end of file
+} // namespace Dali::Graphics::GLES