[Tizen](Partial Update) Fix window rotation issue
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-scene.cpp
index e6f7fa1..36b4049 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2021 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 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.
@@ -18,7 +18,7 @@
 #include <dali/internal/update/common/scene-graph-scene.h>
 
 // INTERNAL INCLUDES
-#include <dali/internal/render/gl-resources/context.h>
+#include <dali/integration-api/core-enumerations.h>
 #include <dali/internal/update/render-tasks/scene-graph-render-task-list.h>
 
 namespace Dali
@@ -28,13 +28,13 @@ namespace Internal
 namespace SceneGraph
 {
 Scene::Scene()
-: mContext(nullptr),
-  mFrameRenderedCallbacks(),
+: mFrameRenderedCallbacks(),
   mFramePresentedCallbacks(),
   mSkipRendering(false),
   mSurfaceRect(),
   mSurfaceOrientation(0),
-  mSurfaceRectChanged(false)
+  mSurfaceRectChanged(false),
+  mRotationCompletedAcknowledgement(false)
 {
 }
 
@@ -44,35 +44,54 @@ Scene::~Scene()
   mFramePresentedCallbacks.clear();
 }
 
-void Scene::Initialize(Context& context, Graphics::Controller& graphicsController)
+void Scene::Initialize(Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable)
 {
-  mContext = &context;
-
   // Create the render pass for the surface
   std::vector<Graphics::AttachmentDescription> attachmentDescriptions;
 
   // Default behaviour for color attachments is to CLEAR and STORE
   mClearValues.clear();
+  mClearValues.emplace_back();
+
+  // Assume single color attachment
   Graphics::AttachmentDescription desc{};
   desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
   desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
   attachmentDescriptions.push_back(desc);
-  mClearValues.emplace_back();
+
+  if(depthBufferAvailable == Integration::DepthBufferAvailable::TRUE ||
+     stencilBufferAvailable == Integration::StencilBufferAvailable::TRUE)
+  {
+    // Depth
+    desc.SetLoadOp(Graphics::AttachmentLoadOp::CLEAR);
+    desc.SetStoreOp(Graphics::AttachmentStoreOp::STORE);
+
+    // Stencil
+    desc.SetStencilLoadOp(Graphics::AttachmentLoadOp::CLEAR);
+    desc.SetStencilStoreOp(Graphics::AttachmentStoreOp::STORE);
+    attachmentDescriptions.push_back(desc);
+
+    mClearValues.emplace_back();
+    mClearValues.back().depthStencil.depth   = 0;
+    mClearValues.back().depthStencil.stencil = 0;
+  }
 
   Graphics::RenderPassCreateInfo rpInfo{};
   rpInfo.SetAttachments(attachmentDescriptions);
 
   // Add default render pass (loadOp = clear)
-  mRenderPass = graphicsController.CreateRenderPass(rpInfo, nullptr);
+  mRenderPass = graphicsController.CreateRenderPass(rpInfo, nullptr); // Warning: Shallow ptr
 
-  desc.SetLoadOp( Graphics::AttachmentLoadOp::LOAD );
+  desc.SetLoadOp(Graphics::AttachmentLoadOp::LOAD);
   attachmentDescriptions[0] = desc;
-  mRenderPassNoClear = graphicsController.CreateRenderPass(rpInfo, nullptr);
-}
+  if(attachmentDescriptions.size() > 1)
+  {
+    desc.SetLoadOp(Graphics::AttachmentLoadOp::LOAD);
+    desc.SetStencilLoadOp(Graphics::AttachmentLoadOp::LOAD);
+    attachmentDescriptions.back() = desc;
+  }
 
-Context* Scene::GetContext()
-{
-  return mContext;
+  mRenderPassNoClear = graphicsController.CreateRenderPass(rpInfo, nullptr); // Warning: Shallow ptr
 }
 
 RenderInstructionContainer& Scene::GetRenderInstructions()
@@ -126,6 +145,11 @@ void Scene::SetSurfaceRect(const Rect<int32_t>& rect)
 {
   mSurfaceRect        = rect;
   mSurfaceRectChanged = true;
+
+  if(mRoot)
+  {
+    mRoot->SetUpdated(true);
+  }
 }
 
 const Rect<int32_t>& Scene::GetSurfaceRect() const
@@ -136,6 +160,11 @@ const Rect<int32_t>& Scene::GetSurfaceRect() const
 void Scene::SetSurfaceOrientation(int32_t orientation)
 {
   mSurfaceOrientation = orientation;
+
+  if(mRoot)
+  {
+    mRoot->SetUpdated(true);
+  }
 }
 
 int32_t Scene::GetSurfaceOrientation() const
@@ -151,6 +180,23 @@ bool Scene::IsSurfaceRectChanged()
   return surfaceRectChanged;
 }
 
+void Scene::SetRotationCompletedAcknowledgement()
+{
+  mRotationCompletedAcknowledgement = true;
+}
+
+bool Scene::IsRotationCompletedAcknowledgementSet()
+{
+  bool setRotationCompletedAcknowledgement = mRotationCompletedAcknowledgement;
+  mRotationCompletedAcknowledgement        = false;
+  return setRotationCompletedAcknowledgement;
+}
+
+std::vector<DirtyRect>& Scene::GetItemsDirtyRects()
+{
+  return mItemsDirtyRects;
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal