Remove RenderSurface from Core
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.h
index 7e89944..ae691e3 100644 (file)
@@ -2,7 +2,7 @@
 #define DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H
 
 /*
- * Copyright (c) 2018 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.
@@ -32,6 +32,7 @@
 #include <dali/internal/update/common/property-resetter.h>
 #include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/internal/update/common/scene-graph-property-notification.h>
+#include <dali/internal/update/common/scene-graph-scene.h>
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
 #include <dali/internal/update/manager/scene-graph-frame-callback.h> // for OwnerPointer< FrameCallback >
@@ -151,7 +152,6 @@ public:
 
   /**
    * Installs a new layer as the root node.
-   * @pre The UpdateManager does not already have an installed root node.
    * @pre The layer is of derived Node type Layer.
    * @pre The layer does not have a parent.
    * @param[in] layer The new root node.
@@ -160,6 +160,15 @@ public:
   void InstallRoot( OwnerPointer<Layer>& layer );
 
   /**
+   * Uninstalls the root node.
+   * @pre The layer is of derived Node type Layer.
+   * @pre The layer does not have a parent.
+   * @param[in] layer The root node.
+   * @post The node is owned by UpdateManager.
+   */
+  void UninstallRoot( Layer* layer );
+
+  /**
    * Add a Node; UpdateManager takes ownership.
    * @pre The node does not have a parent.
    * @note even though nodes are pool allocated, they also contain other heap allocated data, thus using OwnerPointer when transferring the data
@@ -230,6 +239,19 @@ public:
    */
   void RemoveRenderTaskList( RenderTaskList* taskList );
 
+  /**
+   * Add a newly created scene.
+   * @param[in] scene The scene to add.
+   * @post The scene is owned by UpdateManager.
+   */
+  void AddScene( OwnerPointer<Scene>& scene );
+
+  /**
+   * Remove a scene.
+   * @param[in] scene The scene to remove.
+   */
+  void RemoveScene( Scene* scene );
+
   // Animations
 
   /**
@@ -550,7 +572,7 @@ public:
    * @param[in] frameBuffer The framebuffer to add
    * The framebuffer will be owned by RenderManager
    */
-  void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
+  void AddFrameBuffer( OwnerPointer< Render::FrameBuffer >& frameBuffer );
 
   /**
    * Removes a FrameBuffer from the render manager
@@ -568,6 +590,12 @@ public:
    */
   void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::Texture* texture, uint32_t mipmapLevel, uint32_t face );
 
+  /**
+   * This is called when the surface of the scene has been replaced.
+   * @param[in] scene The scene.
+   */
+  void SurfaceReplaced( Scene* scene );
+
 public:
 
   /**
@@ -586,12 +614,6 @@ public:
                    bool isRenderingToFbo );
 
   /**
-   * Set the background color i.e. the glClear color used at the beginning of each frame.
-   * @param[in] color The new background color.
-   */
-  void SetBackgroundColor(const Vector4& color);
-
-  /**
    * Set the default surface rect.
    * @param[in] rect The rect value representing the surface.
    */
@@ -741,6 +763,20 @@ inline void InstallRootMessage( UpdateManager& manager, OwnerPointer<Layer>& roo
   new (slot) LocalType( &manager, &UpdateManager::InstallRoot, root );
 }
 
+inline void UninstallRootMessage( UpdateManager& manager, const Layer* constRoot )
+{
+  // Scene graph thread can destroy this object.
+  Layer* root = const_cast< Layer* >( constRoot );
+
+  typedef MessageValue1< UpdateManager, Layer* > LocalType;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::UninstallRoot, root );
+}
+
 inline void AddNodeMessage( UpdateManager& manager, OwnerPointer<Node>& node )
 {
   // Message has ownership of Node while in transit from event -> update
@@ -906,6 +942,31 @@ inline void RemoveRenderTaskListMessage( UpdateManager& manager, const RenderTas
   new (slot) LocalType( &manager, &UpdateManager::RemoveRenderTaskList, &taskList );
 }
 
+inline void AddSceneMessage( UpdateManager& manager, OwnerPointer< SceneGraph::Scene >& scene )
+{
+  typedef MessageValue1< UpdateManager, OwnerPointer< SceneGraph::Scene > > LocalType;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::AddScene, scene );
+}
+
+inline void RemoveSceneMessage( UpdateManager& manager, const SceneGraph::Scene& constScene )
+{
+  // The scene-graph thread owns this object so it can safely edit it.
+  Scene& scene = const_cast< Scene& >( constScene );
+
+  typedef MessageValue1< UpdateManager, Scene* > LocalType;
+
+  // Reserve some memory inside the message queue
+  uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &manager, &UpdateManager::RemoveScene, &scene );
+}
+
 inline void AddPropertyNotificationMessage( UpdateManager& manager, OwnerPointer< PropertyNotification >& propertyNotification )
 {
   // Message has ownership of PropertyNotification while in transit from event -> update
@@ -986,26 +1047,29 @@ inline void SetShaderProgramMessage( UpdateManager& manager,
   new (slot) LocalType( &manager, &UpdateManager::SetShaderProgram, const_cast<Shader*>( &shader ), shaderData, modifiesGeometry );
 }
 
-inline void SetBackgroundColorMessage( UpdateManager& manager, const Vector4& color )
+inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int32_t>& rect  )
 {
-  typedef MessageValue1< UpdateManager, Vector4 > LocalType;
+  typedef MessageValue1< UpdateManager, Rect<int32_t> > LocalType;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::SetBackgroundColor, color );
+  new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
 }
 
-inline void SetDefaultSurfaceRectMessage( UpdateManager& manager, const Rect<int32_t>& rect  )
+inline void SurfaceReplacedMessage( UpdateManager& manager, const SceneGraph::Scene& constScene )
 {
-  typedef MessageValue1< UpdateManager, Rect<int32_t> > LocalType;
+  // The scene-graph thread owns this object so it can safely edit it.
+  Scene& scene = const_cast< Scene& >( constScene );
+
+  typedef MessageValue1< UpdateManager, Scene* > LocalType;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::SetDefaultSurfaceRect, rect );
+  new (slot) LocalType( &manager, &UpdateManager::SurfaceReplaced, &scene );
 }
 
 inline void KeepRenderingMessage( UpdateManager& manager, float durationSeconds )
@@ -1034,7 +1098,7 @@ inline void SetRenderingBehaviorMessage( UpdateManager& manager, DevelStage::Ren
  * Create a message for setting the depth of a layer
  * @param[in] manager The update manager
  * @param[in] layers list of layers
- * @param[in] rootLayer True if the layers are added via the SystemOverlay API
+ * @param[in] rootLayer The rool layer
  */
 inline void SetLayerDepthsMessage( UpdateManager& manager, const std::vector< Layer* >& layers, const Layer* rootLayer )
 {
@@ -1336,15 +1400,15 @@ inline void GenerateMipmapsMessage( UpdateManager& manager, Render::Texture& tex
 }
 
 
-inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
+inline void AddFrameBuffer( UpdateManager& manager, OwnerPointer< Render::FrameBuffer >& frameBuffer )
 {
-  typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
+  typedef MessageValue1< UpdateManager, OwnerPointer< Render::FrameBuffer > > LocalType;
 
   // Reserve some memory inside the message queue
   uint32_t* slot = manager.ReserveMessageSlot( sizeof( LocalType ) );
 
   // Construct message in the message queue memory; note that delete should not be called on the return value
-  new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, &frameBuffer );
+  new (slot) LocalType( &manager, &UpdateManager::AddFrameBuffer, frameBuffer );
 }
 
 inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )