Revert "[3.0] Clipping API feature in Actor"
[platform/core/uifw/dali-core.git] / dali / internal / update / manager / update-manager.h
index 8ccae95..e90ab9d 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_UPDATE_MANAGER_H__
 
 /*
- * Copyright (c) 2014 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2016 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.
 #include <dali/internal/update/common/scene-graph-buffers.h>
 #include <dali/internal/update/common/scene-graph-property-notification.h>
 #include <dali/internal/update/manager/object-owner-container.h>
-#include <dali/internal/update/node-attachments/node-attachment.h>
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/nodes/scene-graph-layer.h>
 #include <dali/internal/update/rendering/scene-graph-renderer.h>
 #include <dali/internal/render/shaders/scene-graph-shader.h>
 #include <dali/internal/render/renderers/render-property-buffer.h>
+#include <dali/internal/event/rendering/texture-impl.h>
 
 namespace Dali
 {
@@ -60,7 +60,8 @@ class TouchResampler;
 
 namespace Render
 {
-class Sampler;
+struct Sampler;
+class FrameBuffer;
 }
 // value types used by messages
 template <> struct ParameterType< PropertyNotification::NotifyMode >
@@ -75,13 +76,14 @@ class PanGesture;
 class RenderManager;
 class RenderTaskList;
 class RenderQueue;
-class TextureCache;
+class TextureCacheDispatcher;
 class PropertyBuffer;
 class TextureSet;
+class Camera;
 
 /**
- * UpdateManager maintains a scene graph i.e. a tree of nodes and attachments and
- * other property owner objects.
+ * UpdateManager maintains a scene graph i.e. a tree of nodes as well as
+ * other scene graph property owning objects.
  * It controls the Update traversal, in which nodes are repositioned/animated,
  * and organizes the the culling and rendering of the scene.
  * It also maintains the lifecycle of nodes and other property owners that are
@@ -101,8 +103,7 @@ public:
    * @param[in] controller After messages are flushed, we request a render from the RenderController.
    * @param[in] renderManager This is responsible for rendering the results of each "update".
    * @param[in] renderQueue Used to queue messages for the next render.
-   * @param[in] textureCache Used for caching textures.
-   * @param[in] touchResampler Used for re-sampling touch events.
+   * @param[in] textureCacheDispatcher Used for sending messages to texture cache.
    */
   UpdateManager( NotificationManager& notificationManager,
                  CompleteNotificationInterface& animationFinishedNotifier,
@@ -112,8 +113,7 @@ public:
                  Integration::RenderController& controller,
                  RenderManager& renderManager,
                  RenderQueue& renderQueue,
-                 TextureCache& textureCache,
-                 TouchResampler& touchResampler );
+                 TextureCacheDispatcher& textureCacheDispatcher );
 
   /**
    * Destructor.
@@ -173,12 +173,16 @@ public:
   void DestroyNode( Node* node );
 
   /**
-   * Attach an object to a Node.
-   * The UpdateManager is responsible for calling NodeAttachment::Initialize().
-   * @param[in] node The node which will own the attachment.
-   * @param[in] attachment The object to attach.
+   * Add a camera on scene
+   * @param[in] camera to add
    */
-  void AttachToNode( Node* node, NodeAttachment* attachment );
+  void AddCamera( Camera* camera );
+
+  /**
+   * Remove a camera from scene
+   * @param[in] camera to remove
+   */
+  void RemoveCamera( const Camera* camera );
 
   /**
    * Add a newly created object.
@@ -389,10 +393,11 @@ public:
   /**
    * Sets the wrap mode for an existing sampler
    * @param[in] sampler The sampler
-   * @param[in] uWrapMode Wrapping mode in x direction
-   * @param[in] vWrapMode Wrapping mode in y direction
+   * @param[in] rWrapMode Wrapping mode in z direction
+   * @param[in] sWrapMode Wrapping mode in x direction
+   * @param[in] tWrapMode Wrapping mode in y direction
    */
-  void SetWrapMode( Render::Sampler* sampler, unsigned int uWrapMode, unsigned int vWrapMode );
+  void SetWrapMode( Render::Sampler* sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode );
 
   /**
    * Add a new property buffer to RenderManager
@@ -469,6 +474,56 @@ public:
    */
   void RemoveVertexBuffer( Render::Geometry* geometry, Render::PropertyBuffer* propertyBuffer );
 
+  /**
+   * Adds a texture to the render manager
+   * @param[in] texture The texture to add
+   * The texture will be owned by RenderManager
+   */
+  void AddTexture( Render::NewTexture* texture );
+
+  /**
+   * Removes a texture from the render manager
+   * @param[in] texture The texture to remove
+   * @post The texture will be destroyed in the render thread
+   */
+  void RemoveTexture( Render::NewTexture* texture );
+
+  /**
+   * Uploads data to a texture owned by the RenderManager
+   * @param[in] texture The texture
+   * @param[in] pixelData The pixel data object
+   * @param[in] params The parameters for the upload
+   */
+  void UploadTexture( Render::NewTexture* texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params );
+
+  /**
+   * Generates mipmaps for a texture owned by the RenderManager
+   * @param[in] texture The texture
+   */
+  void GenerateMipmaps( Render::NewTexture* texture );
+
+  /**
+   * Adds a framebuffer to the render manager
+   * @param[in] frameBuffer The framebuffer to add
+   * The framebuffer will be owned by RenderManager
+   */
+  void AddFrameBuffer( Render::FrameBuffer* frameBuffer );
+
+  /**
+   * Removes a FrameBuffer from the render manager
+   * @param[in] frameBuffer The FrameBuffer to remove
+   * @post The FrameBuffer will be destroyed in the render thread
+   */
+  void RemoveFrameBuffer( Render::FrameBuffer* frameBuffer );
+
+  /**
+   * Attach a texture as color output to an existing FrameBuffer
+   * @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
+   * @param[in] layer Indicates which layer of a cube map or array texture to attach. Unused for 2D textures
+   */
+  void AttachColorTextureToFrameBuffer( Render::FrameBuffer* frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int face );
 
 public:
 
@@ -521,12 +576,6 @@ private:
   unsigned int KeepUpdatingCheck( float elapsedSeconds ) const;
 
   /**
-   * Helper to calculate new camera setup when root node resizes.
-   * @param[in] updateBuffer The buffer to read the root node size from.
-   */
-  void UpdateProjectionAndViewMatrices(int updateBuffer);
-
-  /**
    * Post process resources that have been updated by renderer
    */
   void PostProcessResources();
@@ -588,13 +637,6 @@ private:
   void ForwardCompiledShadersToEventThread();
 
   /**
-   * Update the default camera.
-   * This must be altered to match the root Node for 2D layouting.
-   * @param[in] updateBuffer The buffer to read the root node size from.
-   */
-  void UpdateDefaultCamera( int updateBuffer );
-
-  /**
    * Update node shaders, opacity, geometry etc.
    * @param[in] bufferIndex to use
    */
@@ -683,18 +725,27 @@ inline void DestroyNodeMessage( UpdateManager& manager, const Node& constNode )
   new (slot) LocalType( &manager, &UpdateManager::DestroyNode, &node );
 }
 
-inline void AttachToNodeMessage( UpdateManager& manager, const Node& constParent, NodeAttachment* attachment )
+inline void AddCameraMessage( UpdateManager& manager, const Camera* constCamera )
 {
-  // Scene graph thread can modify this object.
-  Node& parent = const_cast< Node& >( constParent );
+  typedef MessageValue1< UpdateManager, Camera* > LocalType;
+
+  Camera* camera = const_cast<Camera*>( constCamera );
+  // Reserve some memory inside the message queue
+  unsigned int* 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::AddCamera, camera );
+}
 
-  typedef MessageValue2< UpdateManager, Node*, NodeAttachmentOwner > LocalType;
+inline void RemoveCameraMessage( UpdateManager& manager, const Camera* camera )
+{
+  typedef MessageValue1< UpdateManager, const Camera* > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* 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::AttachToNode, &parent, attachment );
+  new (slot) LocalType( &manager, &UpdateManager::RemoveCamera, camera );
 }
 
 inline void AddObjectMessage( UpdateManager& manager, PropertyOwner* object )
@@ -988,15 +1039,15 @@ inline void SetFilterModeMessage( UpdateManager& manager, Render::Sampler& sampl
   new (slot) LocalType( &manager, &UpdateManager::SetFilterMode, &sampler, minFilterMode, magFilterMode );
 }
 
-inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int uWrapMode, unsigned int vWrapMode )
+inline void SetWrapModeMessage( UpdateManager& manager, Render::Sampler& sampler, unsigned int rWrapMode, unsigned int sWrapMode, unsigned int tWrapMode )
 {
-  typedef MessageValue3< UpdateManager, Render::Sampler*, unsigned int, unsigned int  > LocalType;
+  typedef MessageValue4< UpdateManager, Render::Sampler*, unsigned int, unsigned int, unsigned int > LocalType;
 
   // Reserve some memory inside the message queue
   unsigned int* 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::SetWrapMode, &sampler, uWrapMode, vWrapMode );
+  new (slot) LocalType( &manager, &UpdateManager::SetWrapMode, &sampler, rWrapMode, sWrapMode, tWrapMode );
 }
 
 inline void AddPropertyBuffer( UpdateManager& manager, Render::PropertyBuffer& propertyBuffer )
@@ -1149,6 +1200,84 @@ inline void SetGeometryTypeMessage( UpdateManager& manager, Render::Geometry& ge
   new (slot) LocalType( &manager, &UpdateManager::SetGeometryType, &geometry, geometryType );
 }
 
+inline void AddTexture( UpdateManager& manager, Render::NewTexture& texture )
+{
+  typedef MessageValue1< UpdateManager, Render::NewTexture*  > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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::AddTexture, &texture );
+}
+
+inline void RemoveTexture( UpdateManager& manager, Render::NewTexture& texture )
+{
+  typedef MessageValue1< UpdateManager, Render::NewTexture*  > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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::RemoveTexture, &texture );
+}
+
+inline void UploadTextureMessage( UpdateManager& manager, Render::NewTexture& texture, PixelDataPtr pixelData, const NewTexture::UploadParams& params )
+{
+  typedef MessageValue3< UpdateManager, Render::NewTexture*, PixelDataPtr, NewTexture::UploadParams > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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::UploadTexture, &texture, pixelData, params );
+}
+
+inline void GenerateMipmapsMessage( UpdateManager& manager, Render::NewTexture& texture )
+{
+  typedef MessageValue1< UpdateManager, Render::NewTexture*  > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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::GenerateMipmaps, &texture );
+}
+
+
+inline void AddFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
+{
+  typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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 );
+}
+
+inline void RemoveFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer )
+{
+  typedef MessageValue1< UpdateManager, Render::FrameBuffer*  > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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::RemoveFrameBuffer, &frameBuffer );
+}
+
+inline void AttachColorTextureToFrameBuffer( UpdateManager& manager, Render::FrameBuffer& frameBuffer, Render::NewTexture* texture, unsigned int mipmapLevel, unsigned int layer )
+{
+  typedef MessageValue4< UpdateManager, Render::FrameBuffer*, Render::NewTexture*, unsigned int, unsigned int  > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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::AttachColorTextureToFrameBuffer, &frameBuffer, texture, mipmapLevel, layer );
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal