Move mItemsDirtyRects from Scene to SceneGraph::Scene
[platform/core/uifw/dali-core.git] / dali / internal / update / common / scene-graph-scene.h
index e580490..f1f0f5a 100644 (file)
@@ -30,11 +30,54 @@ namespace Dali
 {
 namespace Internal
 {
-class Context;
+namespace Render
+{
+class Renderer;
+}
 
 namespace SceneGraph
 {
 class RenderInstructionContainer;
+class Node;
+
+struct DirtyRect
+{
+  DirtyRect(Node* node, Render::Renderer* renderer, int32_t frame, Rect<int>& rect)
+  : node(node),
+    renderer(renderer),
+    frame(frame),
+    rect(rect),
+    visited(true)
+  {
+  }
+
+  DirtyRect() = default;
+
+  bool operator<(const DirtyRect& rhs) const
+  {
+    if(node == rhs.node)
+    {
+      if(renderer == rhs.renderer)
+      {
+        return frame > rhs.frame; // Most recent rects come first
+      }
+      else
+      {
+        return renderer < rhs.renderer;
+      }
+    }
+    else
+    {
+      return node < rhs.node;
+    }
+  }
+
+  Node*             node{nullptr};
+  Render::Renderer* renderer{nullptr};
+  int32_t           frame{0};
+  Rect<int32_t>     rect{};
+  bool              visited{true};
+};
 
 class Scene
 {
@@ -52,18 +95,11 @@ public:
 
   /**
    * Creates a scene object in the GPU.
-   * @param[in] context The GL context
    * @param[in] graphicsController The graphics controller
    * @param[in] depthBufferAvailable True if there is a depth buffer
    * @param[in] stencilBufferAvailable True if there is a stencil buffer
    */
-  void Initialize(Context& context, Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable);
-
-  /**
-   * Gets the context holding the GL state of rendering for the scene
-   * @return the context
-   */
-  Context* GetContext();
+  void Initialize(Graphics::Controller& graphicsController, Integration::DepthBufferAvailable depthBufferAvailable, Integration::StencilBufferAvailable stencilBufferAvailable);
 
   /**
    * Gets the render instructions for the scene
@@ -147,7 +183,6 @@ public:
   /**
    * Set the surface orientation when surface is rotated.
    *
-   * @param[in] scene The rotated scene.
    * @param[in] orientation The orientation value representing the surface.
    */
   void SetSurfaceOrientation(int32_t orientation);
@@ -166,6 +201,17 @@ public:
   bool IsSurfaceRectChanged();
 
   /**
+   * @brief Set the internal flag to acknowledge surface rotation.
+   */
+  void SetRotationCompletedAcknowledgement();
+
+  /**
+   * @brief Query wheter is set to acknowledge for completing surface rotation.
+   * @return true it should be acknowledged.
+   */
+  bool IsRotationCompletedAcknowledgementSet();
+
+  /**
    * Set the render target of the surface
    *
    * @param[in] renderTarget The render target.
@@ -212,9 +258,14 @@ public:
     return mClearValues;
   }
 
-private:
-  Context* mContext; ///< The context holding the GL state of rendering for the scene, not owned
+  /**
+   * @brief Get ItemsDirtyRects
+   *
+   * @return the ItemsDirtyRects
+   */
+  std::vector<DirtyRect>& GetItemsDirtyRects();
 
+private:
   // Render instructions describe what should be rendered during RenderManager::RenderScene()
   // Update manager updates instructions for the next frame while we render the current one
 
@@ -225,9 +276,10 @@ private:
 
   bool mSkipRendering; ///< A flag to skip rendering
 
-  Rect<int32_t> mSurfaceRect;        ///< The rectangle of surface which is related ot this scene.
-  int32_t       mSurfaceOrientation; ///< The orientation of surface which is related of this scene
-  bool          mSurfaceRectChanged; ///< The flag of surface's rectangle is changed when is resized, moved or rotated.
+  Rect<int32_t> mSurfaceRect;                      ///< The rectangle of surface which is related ot this scene.
+  int32_t       mSurfaceOrientation;               ///< The orientation of surface which is related of this scene
+  bool          mSurfaceRectChanged;               ///< The flag of surface's rectangle is changed when is resized, moved or rotated.
+  bool          mRotationCompletedAcknowledgement; ///< The flag of sending the acknowledgement to complete window rotation.
 
   // Render pass and render target
 
@@ -240,8 +292,8 @@ private:
   Graphics::UniquePtr<Graphics::RenderPass> mRenderPassNoClear{nullptr}; ///< The render pass created to render the surface without clearing color
   Graphics::RenderTarget*                   mRenderTarget{nullptr};      ///< This is created in the event thread when surface is created/resized/replaced
 
-  // clear colors
-  std::vector<Graphics::ClearValue> mClearValues{};
+  std::vector<Graphics::ClearValue>                  mClearValues{};     ///< Clear colors
+  std::vector<Dali::Internal::SceneGraph::DirtyRect> mItemsDirtyRects{}; ///< Dirty rect list
 };
 
 /// Messages
@@ -289,6 +341,17 @@ inline void SetSurfaceOrientationMessage(EventThreadServices& eventThreadService
   new(slot) LocalType(&scene, &Scene::SetSurfaceOrientation, orientation);
 }
 
+inline void SetRotationCompletedAcknowledgementMessage(EventThreadServices& eventThreadServices, const Scene& scene)
+{
+  using LocalType = Message<Scene>;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new(slot) LocalType(&scene, &Scene::SetRotationCompletedAcknowledgement);
+}
+
 inline void SetSurfaceRenderTargetMessage(EventThreadServices& eventThreadServices, const Scene& scene, Graphics::RenderTarget* renderTarget)
 {
   using LocalType = MessageValue1<Scene, Graphics::RenderTarget*>;