[3.0] Add function to set top margin of the stage
[platform/core/uifw/dali-core.git] / dali / internal / update / render-tasks / scene-graph-render-task.h
index d7abf26..4ac9c28 100644 (file)
@@ -2,7 +2,7 @@
 #define __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_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.
@@ -26,6 +26,7 @@
 #include <dali/internal/event/common/event-thread-services.h>
 #include <dali/internal/update/common/property-owner.h>
 #include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/render/renderers/render-frame-buffer.h>
 
 namespace Dali
 {
@@ -43,7 +44,7 @@ class RenderTracker;
 namespace SceneGraph
 {
 class Node;
-class CameraAttachment;
+class Camera;
 class RenderInstruction;
 class RenderMessageDispatcher;
 
@@ -104,10 +105,11 @@ public:
   bool IsExclusive() const;
 
   /**
-   * Set the node from which the scene is viewed.
-   * @param[in] node The scene is viewed from the perspective of this node.
+   * Set the camera from which the scene is viewed.
+   * @param[in] cameraNode that camera is connected with
+   * @param[in] camera to use.
    */
-  void SetCameraNode( Node* node );
+  void SetCamera( Node* cameraNode, Camera* camera );
 
   /**
    * Set the frame-buffer used as a render target.
@@ -123,6 +125,18 @@ public:
   unsigned int GetFrameBufferId() const;
 
   /**
+   * Set the frame-buffer used as a render target.
+   * @param[in] frameBuffer The framebuffer
+   */
+  void SetFrameBuffer( Render::FrameBuffer* frameBuffer );
+
+  /**
+   * Retrieve the resource ID of the frame-buffer.
+   * @return The resource ID, or zero if not rendering off-screen.
+   */
+  Render::FrameBuffer* GetFrameBuffer();
+
+  /**
    * Set the value of property viewportPosition
    * This value will persist only for the current frame.
    * @param[in] updateBufferIndex The current update buffer index.
@@ -289,23 +303,23 @@ public:
 
   /**
    * Retrieve the view-matrix; this is double buffered for input handling.
-   * @pre GetCameraNode() returns a node with valid CameraAttachment.
+   * @pre GetCameraNode() returns a node with valid Camera.
    * @param[in] bufferIndex The buffer to read from.
    * @return The view-matrix.
    */
   const Matrix& GetViewMatrix( BufferIndex bufferIndex ) const;
 
   /**
-   * @brief Retrieve the camera attachment.
-   * @pre GetCameraNode() returns a node with valid CameraAttachment.
+   * @brief Retrieve the camera.
+   * @pre GetCameraNode() returns a node with valid Camera.
    *
-   * @return The camera attachment.
+   * @return The camera.
    */
-  SceneGraph::CameraAttachment& GetCameraAttachment() const;
+  SceneGraph::Camera& GetCamera() const;
 
   /**
    * Retrieve the projection-matrix; this is double buffered for input handling.
-   * @pre GetCameraNode() returns a node with valid CameraAttachment.
+   * @pre GetCameraNode() returns a node with valid Camera.
    * @param[in] bufferIndex The buffer to read from.
    * @return The projection-matrix.
    */
@@ -329,13 +343,8 @@ public:
   bool ViewMatrixUpdated();
 
   /**
-   * @return A pointer to the camera used by the RenderTask
-   */
-  Node* GetCamera() const;
-
-  /**
-   * Set whether GL sync is required for native render target.
-   * @param[in] whether GL sync is required for native render target
+   * Indicate whether GL sync is required for native render target.
+   * @param[in] requiresSync whether GL sync is required for native render target
    */
   void SetSyncRequired( bool requiresSync );
 
@@ -367,8 +376,9 @@ private:
   Render::RenderTracker* mRenderSyncTracker;
   Node* mSourceNode;
   Node* mCameraNode;
-  CameraAttachment* mCameraAttachment;
+  SceneGraph::Camera* mCamera;
   unsigned int mFrameBufferResourceId;
+  Render::FrameBuffer* mFrameBuffer;
 
   bool mResourcesFinished:1; ///< True if all resources were available when the render-task was processed
   bool mWaitingToRender:1; ///< True when an render once to FBO is waiting
@@ -378,7 +388,6 @@ private:
   bool mCullMode: 1; ///< Whether renderers should be frustum culled
 
   FrameBufferTexture* mRenderTarget;
-  Viewport mViewport;
 
   State mState;                     ///< Render state.
   unsigned int mRefreshRate;        ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames
@@ -403,6 +412,17 @@ inline void SetFrameBufferIdMessage( EventThreadServices& eventThreadServices, R
   new (slot) LocalType( &task, &RenderTask::SetFrameBufferId, resourceId, isNativeFBO );
 }
 
+inline void SetFrameBufferMessage( EventThreadServices& eventThreadServices, RenderTask& task, Render::FrameBuffer* frameBuffer )
+{
+  typedef MessageValue1< RenderTask, Render::FrameBuffer*> LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* 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( &task, &RenderTask::SetFrameBuffer, frameBuffer );
+}
+
 inline void SetClearColorMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Vector4& value )
 {
   typedef MessageDoubleBuffered1< RenderTask, Vector4 > LocalType;
@@ -472,18 +492,17 @@ inline void SetSourceNodeMessage( EventThreadServices& eventThreadServices, Rend
   new (slot) LocalType( &task, &RenderTask::SetSourceNode, node );
 }
 
-inline void SetCameraNodeMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Node* constNode )
+inline void SetCameraMessage( EventThreadServices& eventThreadServices, RenderTask& task, const Node* constNode, const Camera* constCamera )
 {
-  // Scene graph thread can destroy this object.
-  Node* node = const_cast< Node* >( constNode );
-
-  typedef MessageValue1< RenderTask, Node* > LocalType;
+  typedef MessageValue2< RenderTask, Node*, Camera* > LocalType;
 
-  // Reserve some memory inside the message queue
+  Node* node = const_cast< Node* >( constNode );
+  Camera* camera = const_cast< Camera* >( constCamera );
+  // Reserve memory inside the message queue
   unsigned int* 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( &task, &RenderTask::SetCameraNode, node );
+  new (slot) LocalType( &task, &RenderTask::SetCamera, node, camera );
 }
 
 inline void SetExclusiveMessage( EventThreadServices& eventThreadServices, RenderTask& task, bool exclusive )