[Tizen] Add screen and client rotation itself function
[platform/core/uifw/dali-core.git] / dali / internal / render / common / render-manager.h
index 0ef87f0..dd6ce7a 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_RENDER_MANAGER_H
 
 /*
- * Copyright (c) 2019 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2020 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.
@@ -22,9 +22,9 @@
 #include <dali/public-api/math/rect.h>
 #include <dali/integration-api/core-enumerations.h>
 #include <dali/internal/common/shader-saver.h>
-#include <dali/internal/render/gl-resources/gpu-buffer.h>
-#include <dali/internal/render/renderers/render-property-buffer.h>
 #include <dali/internal/event/rendering/texture-impl.h>
+#include <dali/internal/render/gl-resources/gpu-buffer.h>
+#include <dali/internal/render/renderers/render-vertex-buffer.h>
 
 namespace Dali
 {
@@ -35,6 +35,7 @@ class GlAbstraction;
 class GlSyncAbstraction;
 class GlContextHelperAbstraction;
 class RenderStatus;
+class Scene;
 }
 
 struct Vector4;
@@ -61,7 +62,7 @@ class RenderQueue;
 class RenderInstruction;
 class RenderInstructionContainer;
 class Shader;
-class PropertyBufferDataProvider;
+class Scene;
 
 /**
  * RenderManager is responsible for rendering the result of the previous "update", which
@@ -83,7 +84,8 @@ public:
                              Integration::GlSyncAbstraction& glSyncAbstraction,
                              Integration::GlContextHelperAbstraction& glContextHelperAbstraction,
                              Integration::DepthBufferAvailable depthBufferAvailable,
-                             Integration::StencilBufferAvailable stencilBufferAvailable );
+                             Integration::StencilBufferAvailable stencilBufferAvailable,
+                             Integration::PartialUpdateAvailable partialUpdateAvailable );
 
   /**
    * Non-virtual destructor; not intended as a base class
@@ -114,12 +116,6 @@ public:
    */
   void SetShaderSaver( ShaderSaver& upstream );
 
-  /**
-   * Retrieve the render instructions; these should be set during each "update" traversal.
-   * @return The render instruction container.
-   */
-  RenderInstructionContainer& GetRenderInstructionContainer();
-
   // The following methods should be called via RenderQueue messages
 
   /*
@@ -185,17 +181,17 @@ public:
 
   /**
    * Add a property buffer to the render manager.
-   * @param[in] propertyBuffer The property buffer to add.
+   * @param[in] vertexBuffer The property buffer to add.
    * @post propertBuffer is owned by RenderManager
    */
-  void AddPropertyBuffer( OwnerPointer< Render::PropertyBuffer >& propertyBuffer );
+  void AddVertexBuffer( OwnerPointer< Render::VertexBuffer >& vertexBuffer );
 
   /**
    * Remove a property buffer from the render manager.
-   * @param[in] propertyBuffer The property buffer to remove.
-   * @post propertyBuffer is destroyed.
+   * @param[in] vertexBuffer The property buffer to remove.
+   * @post vertexBuffer is destroyed.
    */
-  void RemovePropertyBuffer( Render::PropertyBuffer* propertyBuffer );
+  void RemoveVertexBuffer( Render::VertexBuffer* vertexBuffer );
 
   /**
    * Add a geometry to the render manager.
@@ -214,32 +210,32 @@ public:
   /**
    * Adds a property buffer to a geometry from the render manager.
    * @param[in] geometry The geometry
-   * @param[in] propertyBuffer The property buffer to remove.
+   * @param[in] vertexBuffer The property buffer to remove.
    */
-  void AttachVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
+  void AttachVertexBuffer( Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer );
 
   /**
    * Remove a property buffer from a Render::Geometry from the render manager.
    * @param[in] geometry The geometry
-   * @param[in] propertyBuffer The property buffer to remove.
+   * @param[in] vertexBuffer The property buffer to remove.
    * @post property buffer is destroyed.
    */
-  void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
+  void RemoveVertexBuffer( Render::Geometry* geometry, Render::VertexBuffer* vertexBuffer );
 
   /**
    * Sets the format of an existing property buffer
-   * @param[in] propertyBuffer The property buffer.
+   * @param[in] vertexBuffer The property buffer.
    * @param[in] format The new format of the buffer
    */
-  void SetPropertyBufferFormat( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Render::PropertyBuffer::Format>& format );
+  void SetVertexBufferFormat( Render::VertexBuffer* vertexBuffer, OwnerPointer< Render::VertexBuffer::Format>& format );
 
   /**
    * Sets the data of an existing property buffer
-   * @param[in] propertyBuffer The property buffer.
+   * @param[in] vertexBuffer The property buffer.
    * @param[in] data The new data of the buffer
    * @param[in] size The new size of the buffer
    */
-  void SetPropertyBufferData( Render::PropertyBuffer* propertyBuffer, OwnerPointer< Vector<uint8_t> >& data, uint32_t size );
+  void SetVertexBufferData( Render::VertexBuffer* vertexBuffer, OwnerPointer< Vector<uint8_t> >& data, uint32_t size );
 
   /**
    * Sets the data for the index buffer of an existing geometry
@@ -294,7 +290,7 @@ public:
   void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
 
   /**
-   * Attach a texture as color output to an existing FrameBuffer
+   * Attaches a texture as color output to the existing frame buffer
    * @param[in] frameBuffer The FrameBuffer
    * @param[in] texture The texture that will be used as output when rendering
    * @param[in] mipmapLevel The mipmap of the texture to be attached
@@ -303,6 +299,40 @@ public:
   void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t layer );
 
   /**
+   * Attaches a texture as depth output to the existing frame buffer
+   * @param[in] frameBuffer The FrameBuffer
+   * @param[in] texture The texture that will be used as output when rendering
+   * @param[in] mipmapLevel The mipmap of the texture to be attached
+   */
+  void AttachDepthTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel );
+
+  /**
+   * Attaches a texture as depth/stencil output to the existing frame buffer
+   * @param[in] frameBuffer The FrameBuffer
+   * @param[in] texture The texture that will be used as output when rendering
+   * @param[in] mipmapLevel The mipmap of the texture to be attached
+   */
+  void AttachDepthStencilTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel );
+
+  /**
+   * Initializes a Scene to the render manager
+   * @param[in] scene The Scene to initialize
+   */
+  void InitializeScene( SceneGraph::Scene* scene );
+
+  /**
+   * Uninitializes a Scene to the render manager
+   * @param[in] scene The Scene to uninitialize
+   */
+  void UninitializeScene( SceneGraph::Scene* scene );
+
+  /**
+   * This is called when the surface of the scene has been replaced.
+   * @param[in] scene The scene.
+   */
+  void SurfaceReplaced( SceneGraph::Scene* scene );
+
+  /**
    * Adds a render tracker to the RenderManager. RenderManager takes ownership of the
    * tracker. The lifetime of the tracker is related to the lifetime of the tracked
    * object, usually an offscreen render task.
@@ -322,23 +352,71 @@ public:
    */
   ProgramCache* GetProgramCache();
 
-  // This method should be called from Core::Render()
+  // This method should be called from Core::PreRender()
 
   /**
-   * Renders the results of the previous "update" traversal.
+   * This is called before rendering any scene in the next frame. This method should be preceded
+   * by a call up Update.
+   * Multi-threading note: this method should be called from a dedicated rendering thread.
+   * @pre The GL context must have been created, and made current.
+   * @param[out] status showing whether update is required to run.
+   * @param[in] forceClear force the Clear on the framebuffer even if nothing is rendered.
+   * @param[in] uploadOnly uploadOnly Upload the resource only without rendering.
+   */
+  void PreRender( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
+
+  // This method should be called from Core::PreRender()
+
+  /**
+   * This is called before rendering any scene in the next frame. This method should be preceded
+   * by a call up Update.
+   * Multi-threading note: this method should be called from a dedicated rendering thread.
+   * @pre The GL context must have been created, and made current.
+   * @param[in] scene The scene to be rendered.
+   * @param[out] damagedRects The list of damaged rects for the current render pass.
+   */
+  void PreRender( Integration::Scene& scene, std::vector<Rect<int>>& damagedRects );
+
+  // This method should be called from Core::RenderScene()
+
+  /**
+   * Render a scene in the next frame. This method should be preceded by a call up PreRender.
+   * This method should be called twice. The first pass to render off-screen frame buffers if any,
+   * and the second pass to render the surface.
+   * Multi-threading note: this method should be called from a dedicated rendering thread.
+   * @pre The GL context must have been created, and made current.
    * @param[out] status contains the rendering flags.
-   * @param[in] forceClear Force the Clear on the framebuffer even if nothing is rendered.
-   * @param[in] uploadOnly Upload the resource only without rendering.
+   * @param[in] scene The scene to be rendered.
+   * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only.
    */
-  void Render( Integration::RenderStatus& status, bool forceClear, bool uploadOnly );
+  void RenderScene( Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo );
 
-private:
+  /**
+   * Render a scene in the next frame. This method should be preceded by a call up PreRender.
+   * This method should be called twice. The first pass to render off-screen frame buffers if any,
+   * and the second pass to render the surface.
+   * Multi-threading note: this method should be called from a dedicated rendering thread.
+   * @pre The GL context must have been created, and made current.
+   * @param[out] status contains the rendering flags.
+   * @param[in] scene The scene to be rendered.
+   * @param[in] renderToFbo True to render off-screen frame buffers only if any, and False to render the surface only.
+   * @param[in] clippingRect The clipping rect for the rendered scene.
+   */
+  void RenderScene( Integration::RenderStatus& status, Integration::Scene& scene, bool renderToFbo, Rect<int>& clippingRect );
+
+  // This method should be called from Core::PostRender()
 
   /**
-   * Helper to process a single RenderInstruction.
-   * @param[in] instruction A description of the rendering operation.
+   * This is called after rendering all the scenes in the next frame. This method should be
+   * followed by a call up RenderScene.
+   * Multi-threading note: this method should be called from a dedicated rendering thread.
+   * @pre The GL context must have been created, and made current.
+   * @param[in] uploadOnly uploadOnly Upload the resource only without rendering.
    */
-  void DoRender( RenderInstruction& instruction );
+  void PostRender( bool uploadOnly );
+
+
+private:
 
 private: