Level up Dali::Internal::FreeList as Dali::FreeList
[platform/core/uifw/dali-core.git] / dali / internal / update / render-tasks / scene-graph-render-task.h
index 9d64c08..7a28016 100644 (file)
@@ -1,53 +1,57 @@
-#ifndef __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H__
-#define __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H__
-
-//
-// Copyright (c) 2014 Samsung Electronics Co., Ltd.
-//
-// Licensed under the Flora License, Version 1.0 (the License);
-// you may not use this file except in compliance with the License.
-// You may obtain a copy of the License at
-//
-//     http://floralicense.org/license/
-//
-// Unless required by applicable law or agreed to in writing, software
-// distributed under the License is distributed on an AS IS BASIS,
-// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-// See the License for the specific language governing permissions and
-// limitations under the License.
-//
+#ifndef DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H
+#define DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H
+
+/*
+ * Copyright (c) 2021 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.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/math/viewport.h>
-#include <dali/public-api/render-tasks/render-task.h>
 #include <dali/internal/common/buffer-index.h>
-#include <dali/internal/common/event-to-update.h>
 #include <dali/internal/common/message.h>
-#include <dali/internal/update/common/double-buffered.h>
-#include <dali/internal/update/common/property-owner.h>
+#include <dali/internal/event/common/event-thread-services.h>
+#include <dali/internal/render/common/render-instruction.h>
+#include <dali/internal/render/renderers/render-frame-buffer.h>
 #include <dali/internal/update/common/animatable-property.h>
+#include <dali/internal/update/common/property-owner.h>
+#include <dali/public-api/math/viewport.h>
+#include <dali/public-api/render-tasks/render-task.h>
 
 namespace Dali
 {
-
 namespace Internal
 {
-class FrameBufferTexture;
-class CompleteStatusManager;
+namespace Render
+{
+class RenderTracker;
+}
 
 namespace SceneGraph
 {
 class Node;
-class CameraAttachment;
+class Camera;
 class RenderInstruction;
+class RenderMessageDispatcher;
 
 /**
  * RenderTasks describe how the Dali scene should be rendered.
  */
-class RenderTask : public PropertyOwner
+class RenderTask : public PropertyOwner, public PropertyOwner::Observer
 {
 public:
-  enum State
+  enum State : uint8_t
   {
     RENDER_CONTINUOUSLY,               ///< mRefreshRate > 0
     RENDER_ONCE_WAITING_FOR_RESOURCES, ///< mRefreshRate = REFRESH_ONCE
@@ -63,13 +67,19 @@ public:
   /**
    * Virtual destructor
    */
-  virtual ~RenderTask();
+  ~RenderTask() override;
+
+  /**
+   * Initialize the render task. Called in update thread
+   * @param[in] renderMessageDispatcher to send messages to render thread
+   */
+  void Initialize(RenderMessageDispatcher& renderMessageDispatcher);
 
   /**
    * Set the nodes to be rendered.
    * @param[in] node This node and its children will be rendered.
    */
-  void SetSourceNode( Node* node );
+  void SetSourceNode(Node* node);
 
   /**
    * Retrieve the source node.
@@ -81,7 +91,7 @@ public:
    * Set whether the RenderTask has exclusive access to the source nodes.
    * @param[in] exclusive True if the source nodes will only be rendered by this render-task.
    */
-  void SetExclusive( bool exclusive );
+  void SetExclusive(bool exclusive);
 
   /**
    * Query whether the RenderTask has exclusive access to the source actors.
@@ -90,84 +100,79 @@ 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 );
-
-  /**
-   * Retrieve the camera node.
-   * @return The scene is viewed from the perspective of this node.
-   */
-  Node* GetCameraNode() const;
+  void SetCamera(Node* cameraNode, Camera* camera);
 
   /**
    * Set the frame-buffer used as a render target.
-   * @param[in] resourceId The resource ID of the frame-buffer, or zero if not rendering off-screen.
+   * @param[in] frameBuffer The framebuffer
    */
-  void SetFrameBufferId( unsigned int resourceId );
+  void SetFrameBuffer(Render::FrameBuffer* frameBuffer);
 
   /**
    * Retrieve the resource ID of the frame-buffer.
    * @return The resource ID, or zero if not rendering off-screen.
    */
-  unsigned int GetFrameBufferId() const;
+  Render::FrameBuffer* GetFrameBuffer();
 
   /**
-   * Set the value of property viewport-position
+   * Set the value of property viewportPosition
    * This value will persist only for the current frame.
    * @param[in] updateBufferIndex The current update buffer index.
    * @param[in] value The value of the property
    */
-  void SetViewportPosition( BufferIndex updateBufferIndex, const Vector2& value );
+  void SetViewportPosition(BufferIndex updateBufferIndex, const Vector2& value);
 
   /**
-   * Get the value of property viewport-position
+   * Get the value of property viewportPosition
    * @warning Should only be called from the Update thread
    * @param[in] bufferIndex The buffer to read from.
    * @return the value of the property.
    */
-  const Vector2& GetViewportPosition( BufferIndex bufferIndex ) const;
+  const Vector2& GetViewportPosition(BufferIndex bufferIndex) const;
 
   /**
-   * Bake the value of the property viewport-position
+   * Bake the value of the property viewportPosition
    * This will also set the base value
    * @param[in] updateBufferIndex The current update buffer index.
    * @param[in] value The new value for property.
    */
-  void BakeViewportPosition( BufferIndex updateBufferIndex, const Vector2& value );
+  void BakeViewportPosition(BufferIndex updateBufferIndex, const Vector2& value);
 
   /**
-   * Set the value of property viewport-size
+   * Set the value of property viewportSize
    * This value will persist only for the current frame.
    * @param[in] updateBufferIndex The current update buffer index.
    * @param[in] value The value of the property
    */
-  void SetViewportSize( BufferIndex updateBufferIndex, const Vector2& value );
+  void SetViewportSize(BufferIndex updateBufferIndex, const Vector2& value);
 
   /**
-   * Get the value of property viewport-size
+   * Get the value of property viewportSize
    * @warning Should only be called from the Update thread
    * @param[in] bufferIndex The buffer to read from.
    * @return the value of the property.
    */
-  const Vector2& GetViewportSize( BufferIndex bufferIndex ) const;
+  const Vector2& GetViewportSize(BufferIndex bufferIndex) const;
 
   /**
-   * Bake the value of the property viewport-size
+   * Bake the value of the property viewportSize
    * This will also set the base value
    * @param[in] updateBufferIndex The current update buffer index.
    * @param[in] value The new value for property.
    */
-  void BakeViewportSize( BufferIndex updateBufferIndex, const Vector2& value );
+  void BakeViewportSize(BufferIndex updateBufferIndex, const Vector2& value);
 
   /**
-   * Get the value of property viewport-enabled
+   * Get the value of property viewportEnabled
    * @warning Should only be called from the Update thread
    * @param[in] bufferIndex The buffer to read from.
    * @return the value of the property.
    */
-  bool GetViewportEnabled( BufferIndex bufferIndex ) const;
+  bool GetViewportEnabled(BufferIndex bufferIndex) const;
 
   /**
    * Query whether the optional viewport is set.
@@ -175,36 +180,36 @@ public:
    * @param[out] viewport The viewport position and size is populated.
    * @return true if the viewport has been set
    */
-  bool QueryViewport( BufferIndex bufferIndex, Viewport& viewport ) const;
+  bool QueryViewport(BufferIndex bufferIndex, Viewport& viewport) const;
 
   /**
-   * Set the value of property clear-color
+   * Set the value of property clearColor
    * This value will persist only for the current frame.
    * @param[in] updateBufferIndex The current update buffer index.
    * @param[in] value The value of the property
    */
-  void SetClearColor( BufferIndex updateBufferIndex, const Vector4& value );
+  void SetClearColor(BufferIndex updateBufferIndex, const Vector4& value);
 
   /**
-   * Get the value of property clear-color
+   * Get the value of property clearColor
    * @warning Should only be called from the Update thread
    * @param[in] bufferIndex The buffer to read from.
    * @return the value of the property.
    */
-  const Vector4& GetClearColor( BufferIndex bufferIndex ) const;
+  const Vector4& GetClearColor(BufferIndex bufferIndex) const;
 
   /**
-   * Bake the value of the property clear-color
+   * Bake the value of the property clearColor
    * This will also set the base value
    * @param[in] updateBufferIndex The current update buffer index.
    * @param[in] value The new value for property.
    */
-  void BakeClearColor( BufferIndex updateBufferIndex, const Vector4& value );
+  void BakeClearColor(BufferIndex updateBufferIndex, const Vector4& value);
 
   /**
    * @copydoc Dali::RenderTask::SetClearEnabled()
    */
-  void SetClearEnabled( bool enabled );
+  void SetClearEnabled(bool enabled);
 
   /**
    * @copydoc Dali::RenderTask::GetClearEnabled()
@@ -212,23 +217,33 @@ public:
   bool GetClearEnabled() const;
 
   /**
+   * @copydoc Dali::RenderTask::SetCullMode()
+   */
+  void SetCullMode(bool mode);
+
+  /**
+   * @copydoc Dali::RenderTask::GetCullMode()
+   */
+  bool GetCullMode() const;
+
+  /**
    * Set the refresh-rate of the RenderTask.
    * @param[in] refreshRate The new refresh rate.
    */
-  void SetRefreshRate( unsigned int refreshRate );
+  void SetRefreshRate(uint32_t refreshRate);
 
   /**
    * Retrieve the refresh-rate of the RenderTask.
    * @return The refresh rate.
    */
-  unsigned int GetRefreshRate() const;
+  uint32_t GetRefreshRate() const;
 
   /**
    * Check if the render task is ready for rendering.
    * @param[in] updateBufferIndex The current update buffer index.
    * @return True if the render-task is ready for rendering.
    */
-  bool ReadyToRender( BufferIndex updateBufferIndex );
+  bool ReadyToRender(BufferIndex updateBufferIndex);
 
   /**
    * True if a render is required. If the current state is RENDER_CONTINUOUSLY, then
@@ -240,9 +255,8 @@ public:
   /**
    * Process a frame. This method is called each frame for every ready render task, regardless
    * of whether it needs to render (so that the frame counter can be updated).
-   * @param[in] resourcesComplete true if the resources of the source tree are completely loaded.
    */
-  void UpdateState( bool resourcesComplete );
+  void UpdateState();
 
   /**
    * Return true only if currently waiting for the render task to
@@ -261,30 +275,43 @@ public:
   /**
    * @return The number of times we have transited from RENDERED_ONCE to RENDERED_ONCE_AND_NOTIFIED state.
    */
-  unsigned int GetRenderedOnceCounter() const;
+  uint32_t GetRenderedOnceCounter() const;
 
   /**
    * 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;
+  const Matrix& GetViewMatrix(BufferIndex bufferIndex) const;
+
+  /**
+   * @brief Retrieve the camera.
+   * @pre GetCameraNode() returns a node with valid Camera.
+   *
+   * @return The camera.
+   */
+  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.
    */
-  const Matrix& GetProjectionMatrix( BufferIndex bufferIndex ) const;
+  const Matrix& GetProjectionMatrix(BufferIndex bufferIndex) const;
 
   /**
    * Prepares the render-instruction buffer to be populated with instructions.
-   * @param[out] instruction to prepare
+   *
+   * If the render task is a render-once framebuffer backed by a native image,
+   * then this method will ensure that a GL sync object is created to track
+   * when the rendering has finished.
+   *
    * @param[in] updateBufferIndex The current update buffer index.
+   * @return instruction to prepare
    */
-  void PrepareRenderInstruction( RenderInstruction& instruction, BufferIndex updateBufferIndex );
+  RenderInstruction& PrepareRenderInstruction(BufferIndex updateBufferIndex);
 
   /**
    * @return true if the view matrix has been updated during this or last frame
@@ -292,172 +319,215 @@ public:
   bool ViewMatrixUpdated();
 
   /**
-   * Set the complete status tracker.
-   * @param[in] completeStatusManager The complete status Tracker (not owned)
+   * Indicate whether GL sync is required for native render target.
+   * @param[in] requiresSync whether GL sync is required for native render target
    */
-  void SetCompleteStatusManager( CompleteStatusManager* completeStatusManager );
-
-private:
+  void SetSyncRequired(bool requiresSync);
 
   /**
-   * Protected constructor.
+   * Retrieve the render instruction.
+   * @param[in] updateBufferIndex The current update buffer index.
+   * @return The render instruction
    */
-  RenderTask();
-
-  // Undefined
-  RenderTask(const RenderTask&);
-
-  // Undefined
-  RenderTask& operator=(const RenderTask&);
+  RenderInstruction& GetRenderInstruction(BufferIndex updateBufferIndex)
+  {
+    return mRenderInstruction[updateBufferIndex];
+  }
 
-private: // PropertyOwner
+private: // from PropertyOwner::Observer
+  /**
+   * @copydoc PropertyOwner::Observer::PropertyOwnerConnected( PropertyOwner& owner )
+   */
+  void PropertyOwnerConnected(PropertyOwner& owner) override;
 
-  virtual void ResetDefaultProperties( BufferIndex currentBufferIndex );
+  /**
+   * @copydoc PropertyOwner::Observer::PropertyOwnerDisconnected( BufferIndex updateBufferIndex, PropertyOwner& owner )
+   */
+  void PropertyOwnerDisconnected(BufferIndex updateBufferIndex, PropertyOwner& owner) override;
 
-public: // Animatable Properties
-  AnimatableProperty< Vector2 >   mViewportPosition;    ///< viewport-position
-  AnimatableProperty< Vector2 >   mViewportSize;        ///< viewport-size
-  AnimatableProperty< Vector4 >   mClearColor;          ///< clear-color
+  /**
+   * @copydoc PropertyOwner::Observer::PropertyOwnerDestroyed( PropertyOwner& owner )
+   */
+  void PropertyOwnerDestroyed(PropertyOwner& owner) override;
 
 private:
-  CompleteStatusManager* mCompleteStatusManager;
-  Node* mSourceNode;
-  Node* mCameraNode;
-  CameraAttachment* mCameraAttachment;
-  unsigned int mFrameBufferResourceId;
-
-  bool mWaitingToRender:1; ///< True when an render once to FBO is waiting
-  bool mNotifyTrigger:1; ///< True if a render once render task has finished renderering
-  bool mExclusive: 1; ///< Whether the render task has exclusive access to the source actor (node in the scene graph implementation).
-  bool mClearEnabled: 1; ///< Whether previous results are cleared.
+  void SetActiveStatus();
 
-  FrameBufferTexture* mRenderTarget;
-  Viewport mViewport;
+  /**
+   * Constructor.
+   */
+  RenderTask();
 
-  State mState;                     ///< Render state.
-  unsigned int mRefreshRate;        ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames
-  unsigned int mFrameCounter;       ///< counter for rendering every N frames
+  // Undefined
+  RenderTask(const RenderTask&) = delete;
+  RenderTask& operator=(const RenderTask&) = delete;
 
-  unsigned int mRenderedOnceCounter;  ///< Incremented whenever state changes to RENDERED_ONCE_AND_NOTIFIED
+public:                                          // Animatable Properties
+  AnimatableProperty<Vector2> mViewportPosition; ///< viewportPosition
+  AnimatableProperty<Vector2> mViewportSize;     ///< viewportSize
+  AnimatableProperty<Vector4> mClearColor;       ///< clearColor
 
+private:
+  RenderMessageDispatcher* mRenderMessageDispatcher;
+  Render::RenderTracker*   mRenderSyncTracker;
+  Node*                    mSourceNode;
+  Node*                    mCameraNode;
+  SceneGraph::Camera*      mCamera;
+  Render::FrameBuffer*     mFrameBuffer;
+
+  RenderInstruction mRenderInstruction[2]; ///< Owned double buffered render instruction. (Double buffered because this owns render commands for the currently drawn frame)
+
+  uint32_t mRefreshRate;         ///< REFRESH_ONCE, REFRESH_ALWAYS or render every N frames
+  uint32_t mFrameCounter;        ///< counter for rendering every N frames
+  uint32_t mRenderedOnceCounter; ///< Incremented whenever state changes to RENDERED_ONCE_AND_NOTIFIED
+
+  State mState; ///< Render state.
+
+  bool mRequiresSync : 1;    ///< Whether sync is needed to track the render
+  bool mActive : 1;          ///< True when the task is active, i.e. has valid source and camera
+  bool mWaitingToRender : 1; ///< True when an render once to FBO is waiting
+  bool mNotifyTrigger : 1;   ///< True if a render once render task has finished renderering
+  bool mExclusive : 1;       ///< Whether the render task has exclusive access to the source actor (node in the scene graph).
+  bool mClearEnabled : 1;    ///< Whether previous results are cleared.
+  bool mCullMode : 1;        ///< Whether renderers should be frustum culled
 };
 
 // Messages for RenderTask
+inline void SetFrameBufferMessage(EventThreadServices& eventThreadServices, const RenderTask& task, Render::FrameBuffer* frameBuffer)
+{
+  using LocalType = MessageValue1<RenderTask, Render::FrameBuffer*>;
+
+  // 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(&task, &RenderTask::SetFrameBuffer, frameBuffer);
+}
 
-inline void SetFrameBufferIdMessage( EventToUpdate& eventToUpdate, RenderTask& task, unsigned int resourceId )
+inline void SetClearColorMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value)
 {
-  typedef MessageValue1< RenderTask, unsigned int > LocalType;
+  using LocalType = MessageDoubleBuffered1<RenderTask, Vector4>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::SetFrameBufferId, resourceId );
+  new(slot) LocalType(&task, &RenderTask::SetClearColor, value);
 }
 
-inline void SetClearColorMessage( EventToUpdate& eventToUpdate, RenderTask& task, const Vector4& value )
+inline void BakeClearColorMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector4& value)
 {
-  typedef MessageDoubleBuffered1< RenderTask, Vector4 > LocalType;
+  using LocalType = MessageDoubleBuffered1<RenderTask, Vector4>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::SetClearColor, value );
+  new(slot) LocalType(&task, &RenderTask::BakeClearColor, value);
 }
 
-inline void BakeClearColorMessage( EventToUpdate& eventToUpdate, const RenderTask& task, const Vector4& value )
+inline void SetClearEnabledMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool enabled)
 {
-  typedef MessageDoubleBuffered1< RenderTask, Vector4 > LocalType;
+  using LocalType = MessageValue1<RenderTask, bool>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::BakeClearColor, value );
+  new(slot) LocalType(&task, &RenderTask::SetClearEnabled, enabled);
 }
 
-inline void SetClearEnabledMessage( EventToUpdate& eventToUpdate, RenderTask& task, bool enabled )
+inline void SetCullModeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool mode)
 {
-  typedef MessageValue1< RenderTask, bool > LocalType;
+  using LocalType = MessageValue1<RenderTask, bool>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::SetClearEnabled, enabled );
+  new(slot) LocalType(&task, &RenderTask::SetCullMode, mode);
 }
 
-inline void SetRefreshRateMessage( EventToUpdate& eventToUpdate, RenderTask& task, unsigned int refreshRate )
+inline void SetRefreshRateMessage(EventThreadServices& eventThreadServices, const RenderTask& task, uint32_t refreshRate)
 {
-  typedef MessageValue1< RenderTask, unsigned int > LocalType;
+  using LocalType = MessageValue1<RenderTask, uint32_t>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::SetRefreshRate, refreshRate );
+  new(slot) LocalType(&task, &RenderTask::SetRefreshRate, refreshRate);
 }
 
-inline void SetSourceNodeMessage( EventToUpdate& eventToUpdate, RenderTask& task, const Node* constNode )
+inline void SetSourceNodeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode)
 {
   // Scene graph thread can destroy this object.
-  Node* node = const_cast< Node* >( constNode );
+  Node* node = const_cast<Node*>(constNode);
 
-  typedef MessageValue1< RenderTask, Node* > LocalType;
+  using LocalType = MessageValue1<RenderTask, Node*>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::SetSourceNode, node );
+  new(slot) LocalType(&task, &RenderTask::SetSourceNode, node);
 }
 
-inline void SetCameraNodeMessage( EventToUpdate& eventToUpdate, RenderTask& task, const Node* constNode )
+inline void SetCameraMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Node* constNode, const Camera* constCamera)
 {
-  // Scene graph thread can destroy this object.
-  Node* node = const_cast< Node* >( constNode );
+  using LocalType = MessageValue2<RenderTask, Node*, Camera*>;
 
-  typedef MessageValue1< RenderTask, Node* > LocalType;
+  Node*   node   = const_cast<Node*>(constNode);
+  Camera* camera = const_cast<Camera*>(constCamera);
+  // Reserve 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(&task, &RenderTask::SetCamera, node, camera);
+}
+
+inline void SetExclusiveMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool exclusive)
+{
+  using LocalType = MessageValue1<RenderTask, bool>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::SetCameraNode, node );
+  new(slot) LocalType(&task, &RenderTask::SetExclusive, exclusive);
 }
 
-inline void SetExclusiveMessage( EventToUpdate& eventToUpdate, RenderTask& task, bool exclusive )
+inline void SetSyncRequiredMessage(EventThreadServices& eventThreadServices, const RenderTask& task, bool requiresSync)
 {
-  typedef MessageValue1< RenderTask, bool > LocalType;
+  using LocalType = MessageValue1<RenderTask, bool>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::SetExclusive, exclusive );
+  new(slot) LocalType(&task, &RenderTask::SetSyncRequired, requiresSync);
 }
 
-inline void BakeViewportPositionMessage( EventToUpdate& eventToUpdate, const RenderTask& task, const Vector2& value )
+inline void BakeViewportPositionMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value)
 {
-  typedef MessageDoubleBuffered1< RenderTask, Vector2 > LocalType;
+  using LocalType = MessageDoubleBuffered1<RenderTask, Vector2>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::BakeViewportPosition, value );
+  new(slot) LocalType(&task, &RenderTask::BakeViewportPosition, value);
 }
 
-inline void BakeViewportSizeMessage( EventToUpdate& eventToUpdate, const RenderTask& task, const Vector2& value )
+inline void BakeViewportSizeMessage(EventThreadServices& eventThreadServices, const RenderTask& task, const Vector2& value)
 {
-  typedef MessageDoubleBuffered1< RenderTask, Vector2 > LocalType;
+  using LocalType = MessageDoubleBuffered1<RenderTask, Vector2>;
 
   // Reserve some memory inside the message queue
-  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+  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( &task, &RenderTask::BakeViewportSize, value );
+  new(slot) LocalType(&task, &RenderTask::BakeViewportSize, value);
 }
 
 } // namespace SceneGraph
@@ -466,4 +536,4 @@ inline void BakeViewportSizeMessage( EventToUpdate& eventToUpdate, const RenderT
 
 } // namespace Dali
 
-#endif // __DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H__
+#endif // DALI_INTERNAL_SCENE_GRAPH_RENDER_TASK_H