Friendly janitor cleaning up unnecessary header dependencies
[platform/core/uifw/dali-core.git] / dali / internal / update / node-attachments / scene-graph-renderable-attachment.h
index 87477a5..1a6ff25 100644 (file)
@@ -19,7 +19,6 @@
  */
 
 // INTERNAL INCLUDES
-#include <dali/public-api/actors/layer.h>
 #include <dali/internal/common/blending-options.h>
 #include <dali/internal/common/event-to-update.h>
 #include <dali/internal/common/internal-constants.h>
@@ -27,7 +26,6 @@
 #include <dali/internal/update/controllers/scene-controller.h>
 #include <dali/internal/update/nodes/node.h>
 #include <dali/internal/update/node-attachments/node-attachment.h>
-#include <dali/internal/update/common/double-buffered.h>
 #include <dali/internal/update/resources/resource-manager-declarations.h>
 #include <dali/internal/render/renderers/scene-graph-renderer-declarations.h>
 
@@ -42,6 +40,7 @@ class ResourceTracker;
 namespace SceneGraph
 {
 class Renderer;
+class Shader;
 
 /**
  * RenderableAttachments are responsible for preparing textures, meshes, matrices etc. during the Update.
@@ -143,6 +142,19 @@ public: // API
    */
   void GetScaleForSize( const Vector3& nodeSize, Vector3& scaling );
 
+  /**
+   * Apply a shader on the renderable
+   * @param[in] updateBufferIndex The current update buffer index.
+   * @param[in] shader to apply.
+   */
+  void ApplyShader( BufferIndex updateBufferIndex, Shader* shader );
+
+  /**
+   * Remove the shader from the renderable
+   * @param[in] updateBufferIndex The current update buffer index.
+   */
+  void RemoveShader( BufferIndex updateBufferIndex );
+
 public: // For use during in the update algorithm only
 
   /**
@@ -319,6 +331,12 @@ private:
    */
   virtual bool DoPrepareResources( BufferIndex updateBufferIndex, ResourceManager& resourceManager ) = 0;
 
+  /**
+   * Sends the shader to the renderer
+   * @param updateBufferIndex for the message buffer
+   */
+  void SendShaderChangeMessage( BufferIndex updateBufferIndex );
+
   // Undefined
   RenderableAttachment( const RenderableAttachment& );
 
@@ -328,8 +346,13 @@ private:
 protected:
 
   SceneController* mSceneController;   ///< Used for initializing renderers whilst attached
+  Shader*          mShader;            ///< A pointer to the shader
 
-  BlendingMode::Type mBlendingMode:2;    ///< Whether blending is used to render the renderable attachment. 2 bits is enough for 3 values
+  Dali::Vector< Integration::ResourceId > mTrackedResources; ///< Filled during PrepareResources if there are uncomplete, tracked resources.
+
+  float mSortModifier;
+
+  BlendingMode::Type mBlendingMode:2;  ///< Whether blending is used to render the renderable attachment. 2 bits is enough for 3 values
 
   bool mUsesGeometryScaling:1;         ///< True if the derived renderer uses scaling.
   bool mScaleForSizeDirty:1;           ///< True if mScaleForSize has changed in the current frame.
@@ -340,9 +363,6 @@ protected:
   bool mHasUntrackedResources:1;       ///< Set during PrepareResources, true if have tried to follow untracked resources
   CullFaceMode mCullFaceMode:3;        ///< Cullface mode, 3 bits is enough for 4 values
 
-  float mSortModifier;
-
-  Dali::Vector< Integration::ResourceId > mTrackedResources; ///< Filled during PrepareResources if there are uncomplete, tracked resources.
 };
 
 // Messages for RenderableAttachment
@@ -410,6 +430,31 @@ inline void SetSamplerMessage( EventToUpdate& eventToUpdate, const RenderableAtt
   new (slot) LocalType( &attachment, &RenderableAttachment::SetSampler, samplerBitfield );
 }
 
+inline void ApplyShaderMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment, const Shader& constShader )
+{
+  // Update thread can edit the object
+  Shader& shader = const_cast< Shader& >( constShader );
+
+  typedef MessageDoubleBuffered1< RenderableAttachment, Shader* > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &attachment, &RenderableAttachment::ApplyShader, &shader );
+}
+
+inline void RemoveShaderMessage( EventToUpdate& eventToUpdate, const RenderableAttachment& attachment )
+{
+  typedef MessageDoubleBuffered0< RenderableAttachment > LocalType;
+
+  // Reserve some memory inside the message queue
+  unsigned int* slot = eventToUpdate.ReserveMessageSlot( sizeof( LocalType ) );
+
+  // Construct message in the message queue memory; note that delete should not be called on the return value
+  new (slot) LocalType( &attachment, &RenderableAttachment::RemoveShader );
+}
+
 } // namespace SceneGraph
 
 } // namespace Internal