[Tizen] Fix surface deletion order
[platform/core/uifw/dali-adaptor.git] / dali / internal / graphics / gles-impl / gles-graphics-render-target.cpp
index 090bb71..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.
 
 // CLASS HEADER
 #include "gles-graphics-render-target.h"
+
+// INTERNAL INCLUDES
+#include <dali/integration-api/adaptor-framework/render-surface-interface.h>
+#include "egl-graphics-controller.h"
+#include "gles-graphics-framebuffer.h"
+
+namespace Dali::Graphics::GLES
+{
+RenderTarget::RenderTarget(const Graphics::RenderTargetCreateInfo& createInfo, Graphics::EglGraphicsController& controller)
+: RenderTargetResource(createInfo, controller)
+{
+  if(createInfo.surface)
+  {
+    controller.CreateSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(createInfo.surface));
+  }
+}
+
+RenderTarget::~RenderTarget() = default;
+
+void RenderTarget::DestroyResource()
+{
+}
+
+void RenderTarget::DiscardResource()
+{
+  mController.DiscardResource(this);
+
+  // The surface context should be deleted now
+  if(mCreateInfo.surface)
+  {
+    mController.DeleteSurfaceContext(static_cast<Dali::RenderSurfaceInterface*>(mCreateInfo.surface));
+    mCreateInfo.surface = nullptr;
+  }
+}
+
+GLES::Framebuffer* RenderTarget::GetFramebuffer() const
+{
+  return static_cast<GLES::Framebuffer*>(mCreateInfo.framebuffer);
+}
+
+Surface* RenderTarget::GetSurface() const
+{
+  return mCreateInfo.surface;
+}
+
+} // namespace Dali::Graphics::GLES