Geometry Batching
[platform/core/uifw/dali-core.git] / dali / internal / update / rendering / scene-graph-renderer.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDERER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H
3
4 /*
5  * Copyright (c) 2016 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #include <dali/public-api/rendering/geometry.h>
21 #include <dali/public-api/rendering/renderer.h> // Dali::Renderer
22 #include <dali/internal/common/blending-options.h>
23 #include <dali/internal/common/type-abstraction-enums.h>
24 #include <dali/internal/event/common/event-thread-services.h>
25 #include <dali/internal/update/common/property-owner.h>
26 #include <dali/internal/update/common/uniform-map.h>
27 #include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
28 #include <dali/internal/render/data-providers/render-data-provider.h>
29 #include <dali/internal/render/renderers/render-renderer.h>
30
31 namespace Dali
32 {
33 namespace Internal
34 {
35
36 namespace Render
37 {
38 class Renderer;
39 class Geometry;
40 }
41
42 namespace SceneGraph
43 {
44 class SceneController;
45
46 class Renderer;
47 typedef Dali::Vector< Renderer* > RendererContainer;
48 typedef RendererContainer::Iterator RendererIter;
49 typedef RendererContainer::ConstIterator RendererConstIter;
50
51 class TextureSet;
52 class Geometry;
53
54 class Renderer :  public PropertyOwner,
55                   public UniformMapDataProvider,
56                   public UniformMap::Observer,
57                   public ConnectionChangePropagator::Observer
58 {
59 public:
60
61   enum Opacity
62   {
63     OPAQUE,
64     TRANSPARENT,
65     TRANSLUCENT
66   };
67
68   /**
69    * Construct a new Renderer
70    */
71   static Renderer* New();
72
73   /**
74    * Destructor
75    */
76   virtual ~Renderer();
77
78   /**
79    * Overriden delete operator
80    * Deletes the renderer from its global memory pool
81    */
82   void operator delete( void* ptr );
83
84   /**
85    * Set the texture set for the renderer
86    * @param[in] textureSet The texture set this renderer will use
87    */
88   void SetTextures( TextureSet* textureSet );
89
90   /**
91    * Returns current texture set object
92    * @return Pointer to the texture set
93    */
94   const TextureSet* GetTextures() const
95   {
96     return mTextureSet;
97   }
98
99   /**
100    * Set the shader for the renderer
101    * @param[in] shader The shader this renderer will use
102    */
103   void SetShader( Shader* shader );
104
105   /**
106    * Get the shader used by this renderer
107    * @return the shader this renderer uses
108    */
109   const Shader& GetShader() const
110   {
111     return *mShader;
112   }
113
114   /**
115    * Set the geometry for the renderer
116    * @param[in] geometry The geometry this renderer will use
117    */
118   void SetGeometry( Render::Geometry* geometry );
119
120   /**
121    * Get the geometry of this renderer
122    * @return the geometry this renderer uses
123    */
124   const Render::Geometry& GetGeometry() const
125   {
126     return *mGeometry;
127   }
128
129   /**
130    * Set the depth index
131    * @param[in] depthIndex the new depth index to use
132    */
133   void SetDepthIndex( int depthIndex );
134
135   /**
136    * @brief Get the depth index
137    * @return The depth index
138    */
139   int GetDepthIndex() const
140   {
141     return mDepthIndex;
142   }
143
144   /**
145    * Set the face culling mode
146    * @param[in] faceCullingMode to use
147    */
148   void SetFaceCullingMode( FaceCullingMode::Type faceCullingMode );
149
150   /**
151    * Set the blending mode
152    * @param[in] blendingMode to use
153    */
154   void SetBlendMode( BlendMode::Type blendingMode );
155
156   /**
157    * Set the blending options. This should only be called from the update thread.
158    * @param[in] options A bitmask of blending options.
159    */
160   void SetBlendingOptions( unsigned int options );
161
162   /**
163    * Set the blend color for blending operation
164    * @param blendColor to pass to GL
165    */
166   void SetBlendColor( const Vector4& blendColor );
167
168   /**
169    * Set the index of first element for indexed draw
170    * @param[in] firstElement index of first element to draw
171    */
172   void SetIndexedDrawFirstElement( size_t firstElement );
173
174   /**
175    * Set the number of elements to draw by indexed draw
176    * @param[in] elementsCount number of elements to draw
177    */
178   void SetIndexedDrawElementsCount( size_t elementsCount );
179
180   /**
181    * @brief Set whether the Pre-multiplied Alpha Blending is required
182    * @param[in] preMultipled whether alpha is pre-multiplied.
183    */
184   void EnablePreMultipliedAlpha( bool preMultipled );
185
186   /**
187    * Sets the depth buffer write mode
188    * @param[in] depthWriteMode The depth buffer write mode
189    */
190   void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
191
192   /**
193    * Sets the depth buffer test mode
194    * @param[in] depthTestMode The depth buffer test mode
195    */
196   void SetDepthTestMode( DepthTestMode::Type depthTestMode );
197
198   /**
199    * Sets the depth function
200    * @param[in] depthFunction The depth function
201    */
202   void SetDepthFunction( DepthFunction::Type depthFunction );
203
204   /**
205    * Sets the stencil mode
206    * @param[in] mode The stencil function
207    */
208   void SetStencilMode( StencilMode::Type mode );
209
210   /**
211    * Sets the stencil function
212    * @param[in] stencilFunction The stencil function
213    */
214   void SetStencilFunction( StencilFunction::Type stencilFunction );
215
216   /**
217    * Sets the stencil function mask
218    * @param[in] stencilFunctionMask The stencil function mask
219    */
220   void SetStencilFunctionMask( int stencilFunctionMask );
221
222   /**
223    * Sets the stencil function reference
224    * @param[in] stencilFunctionReference The stencil function reference
225    */
226   void SetStencilFunctionReference( int stencilFunctionReference );
227
228   /**
229    * Sets the stencil mask
230    * @param[in] stencilMask The stencil mask
231    */
232   void SetStencilMask( int stencilMask );
233
234   /**
235    * Sets the stencil operation for when the stencil test fails
236    * @param[in] stencilOperationOnFail The stencil operation
237    */
238   void SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail );
239
240   /**
241    * Sets the stencil operation for when the depth test fails
242    * @param[in] stencilOperationOnZFail The stencil operation
243    */
244   void SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail );
245
246   /**
247    * Sets the stencil operation for when the depth test passes
248    * @param[in] stencilOperationOnZPass The stencil operation
249    */
250   void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass );
251
252   /**
253    * Sets whether or not to write to the color buffer
254    * @param[in] writeToColorBuffer True to write to the color buffer
255    */
256   void SetWriteToColorBuffer( bool writeToColorBuffer );
257
258   /**
259    * Turns on batching feature for the renderer
260    * @param[in] batchingEnabled if true, enables the batching mode for the renderer
261    */
262   void SetBatchingEnabled( bool batchingEnabled );
263
264   /**
265    * Tests whether batching feature is enabled for this renderer
266    * @return batching state
267    */
268   bool IsBatchingEnabled() const
269   {
270     return mBatchingEnabled;
271   }
272
273   /**
274    * Prepare the object for rendering.
275    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
276    * @param[in] updateBufferIndex The current update buffer index.
277    */
278   void PrepareRender( BufferIndex updateBufferIndex );
279
280   /*
281    * Retrieve the Render thread renderer
282    * @return The associated render thread renderer
283    */
284   Render::Renderer& GetRenderer();
285
286   /**
287    * Check whether the renderer has been marked as ready to render
288    * ready means that renderer has all resources and should produce correct result
289    * complete means all resources have finished loading
290    * It's possible that renderer is complete but not ready,
291    * for example in case of resource load failed
292    * @param[out] ready TRUE if the renderer has resources to render
293    * @param[out] complete TRUE if the renderer resources are complete
294    */
295   void GetReadyAndComplete( bool& ready, bool& complete ) const;
296
297   /**
298    * Query whether the renderer is fully opaque, fully transparent or transparent.
299    * @param[in] updateBufferIndex The current update buffer index.
300    * @return OPAQUE if fully opaque, TRANSPARENT if fully transparent and TRANSLUCENT if in between
301    */
302   Opacity GetOpacity( BufferIndex updateBufferIndex, const Node& node ) const;
303
304   /**
305    * Called by the TextureSet to notify to the renderer that it has changed
306    */
307   void TextureSetChanged();
308
309 public: // Implementation of ObjectOwnerContainer template methods
310   /**
311    * Connect the object to the scene graph
312    *
313    * @param[in] sceneController The scene controller - used for sending messages to render thread
314    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
315    */
316   void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
317
318   /**
319    * Disconnect the object from the scene graph
320    * @param[in] sceneController The scene controller - used for sending messages to render thread
321    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
322    */
323   void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
324
325 public: // Implementation of ConnectionChangePropagator
326   /**
327    * @copydoc ConnectionChangePropagator::AddObserver
328    */
329   void AddConnectionObserver(ConnectionChangePropagator::Observer& observer){};
330
331   /**
332    * @copydoc ConnectionChangePropagator::RemoveObserver
333    */
334   void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer){};
335
336 public:
337
338
339 public: // UniformMap::Observer
340   /**
341    * @copydoc UniformMap::Observer::UniformMappingsChanged
342    */
343   virtual void UniformMappingsChanged( const UniformMap& mappings );
344
345 public: // ConnectionChangePropagator::Observer
346
347   /**
348    * @copydoc ConnectionChangePropagator::ConnectionsChanged
349    */
350   virtual void ConnectionsChanged( PropertyOwner& owner );
351
352   /**
353    * @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
354    */
355   virtual void ConnectedUniformMapChanged( );
356
357   /**
358    * @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
359    */
360   virtual void ObservedObjectDestroyed(PropertyOwner& owner);
361
362 public: // PropertyOwner implementation
363   /**
364    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
365    */
366   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ){};
367
368 public: // From UniformMapDataProvider
369
370   /**
371    * @copydoc UniformMapDataProvider::GetUniformMapChanged
372    */
373   virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const{ return mUniformMapChanged[bufferIndex];}
374
375   /**
376    * @copydoc UniformMapDataProvider::GetUniformMap
377    */
378   virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const;
379
380 private:
381
382   /**
383    * Protected constructor; See also Renderer::New()
384    */
385   Renderer();
386
387   /**
388    * Helper function to create a new render data provider
389    * @return the new (initialized) data provider
390    */
391   RenderDataProvider* NewRenderDataProvider();
392
393 private:
394
395   CollectedUniformMap          mCollectedUniformMap[2];           ///< Uniform maps collected by the renderer
396   SceneController*             mSceneController;                  ///< Used for initializing renderers
397   Render::Renderer*            mRenderer;                         ///< Raw pointer to the renderer (that's owned by RenderManager)
398   TextureSet*                  mTextureSet;                       ///< The texture set this renderer uses. (Not owned)
399   Render::Geometry*            mGeometry;                         ///< The geometry this renderer uses. (Not owned)
400   Shader*                      mShader;                           ///< The shader this renderer uses. (Not owned)
401   Vector4*                     mBlendColor;                       ///< The blend color for blending operation
402
403   Render::Renderer::StencilParameters mStencilParameters;         ///< Struct containing all stencil related options
404
405   size_t                       mIndexedDrawFirstElement;          ///< first element index to be drawn using indexed draw
406   size_t                       mIndexedDrawElementsCount;         ///< number of elements to be drawn using indexed draw
407   unsigned int                 mBlendBitmask;                     ///< The bitmask of blending options
408   unsigned int                 mRegenerateUniformMap;             ///< 2 if the map should be regenerated, 1 if it should be copied.
409   unsigned int                 mResendFlag;                       ///< Indicate whether data should be resent to the renderer
410
411   DepthFunction::Type          mDepthFunction:3;                  ///< Local copy of the depth function
412   FaceCullingMode::Type        mFaceCullingMode:2;                ///< Local copy of the mode of face culling
413   BlendMode::Type              mBlendMode:2;                      ///< Local copy of the mode of blending
414   DepthWriteMode::Type         mDepthWriteMode:2;                 ///< Local copy of the depth write mode
415   DepthTestMode::Type          mDepthTestMode:2;                  ///< Local copy of the depth test mode
416   bool                         mWriteToColorBuffer:1;             ///< Local copy of the write to color buffer flag
417
418   bool                         mUniformMapChanged[2];             ///< Records if the uniform map has been altered this frame
419   bool                         mResourcesReady;                   ///< Set during the Update algorithm; true if the renderer has resources ready for the current frame.
420   bool                         mFinishedResourceAcquisition;      ///< Set during DoPrepareResources; true if ready & all resource acquisition has finished (successfully or otherwise)
421   bool                         mPremultipledAlphaEnabled:1;       ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
422
423 public:
424
425   bool                         mBatchingEnabled : 1;              ///< Flag indicating whether the render supports batching
426   int                          mDepthIndex;                       ///< Used only in PrepareRenderInstructions
427 };
428
429
430 /// Messages
431 inline void SetTexturesMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const TextureSet& textureSet )
432 {
433   typedef MessageValue1< Renderer, TextureSet* > LocalType;
434
435   // Reserve some memory inside the message queue
436   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
437
438   // Construct message in the message queue memory; note that delete should not be called on the return value
439   new (slot) LocalType( &renderer, &Renderer::SetTextures, const_cast<TextureSet*>(&textureSet) );
440 }
441
442 inline void SetGeometryMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry )
443 {
444   typedef MessageValue1< Renderer, Render::Geometry* > LocalType;
445
446   // Reserve some memory inside the message queue
447   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
448
449   // Construct message in the message queue memory; note that delete should not be called on the return value
450   new (slot) LocalType( &renderer, &Renderer::SetGeometry, const_cast<Render::Geometry*>(&geometry) );
451 }
452
453 inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, Shader& shader )
454 {
455   typedef MessageValue1< Renderer, Shader* > LocalType;
456
457   // Reserve some memory inside the message queue
458   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
459
460   // Construct message in the message queue memory; note that delete should not be called on the return value
461   new (slot) LocalType( &renderer, &Renderer::SetShader, &shader );
462 }
463
464 inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex )
465 {
466   typedef MessageValue1< Renderer, int > LocalType;
467
468   // Reserve some memory inside the message queue
469   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
470
471   // Construct message in the message queue memory; note that delete should not be called on the return value
472   new (slot) LocalType( &renderer, &Renderer::SetDepthIndex, depthIndex );
473 }
474
475 inline void SetFaceCullingModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode )
476 {
477   typedef MessageValue1< Renderer, FaceCullingMode::Type > LocalType;
478
479   // Reserve some memory inside the message queue
480   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
481
482   new (slot) LocalType( &renderer, &Renderer::SetFaceCullingMode, faceCullingMode );
483 }
484
485 inline void SetBlendModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode )
486 {
487   typedef MessageValue1< Renderer, BlendMode::Type > LocalType;
488
489   // Reserve some memory inside the message queue
490   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
491
492   new (slot) LocalType( &renderer, &Renderer::SetBlendMode, blendingMode );
493 }
494
495 inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, unsigned int options )
496 {
497   typedef MessageValue1< Renderer, unsigned int > LocalType;
498
499   // Reserve some memory inside the message queue
500   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
501
502   new (slot) LocalType( &renderer, &Renderer::SetBlendingOptions, options );
503 }
504
505 inline void SetBlendColorMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Vector4& blendColor )
506 {
507   typedef MessageValue1< Renderer, Vector4 > LocalType;
508
509   // Reserve some memory inside the message queue
510   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
511
512   new (slot) LocalType( &renderer, &Renderer::SetBlendColor, blendColor );
513 }
514
515 inline void SetIndexedDrawFirstElementMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, size_t firstElement )
516 {
517   typedef MessageValue1< Renderer, size_t > LocalType;
518
519   // Reserve some memory inside the message queue
520   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
521
522   new (slot) LocalType( &renderer, &Renderer::SetIndexedDrawFirstElement, firstElement );
523 }
524
525 inline void SetIndexedDrawElementsCountMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, size_t elementsCount )
526 {
527   typedef MessageValue1< Renderer, size_t > LocalType;
528
529   // Reserve some memory inside the message queue
530   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
531
532   new (slot) LocalType( &renderer, &Renderer::SetIndexedDrawElementsCount, elementsCount );
533 }
534
535 inline void SetEnablePreMultipliedAlphaMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, bool preMultiplied )
536 {
537   typedef MessageValue1< Renderer, bool > LocalType;
538
539   // Reserve some memory inside the message queue
540   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
541
542   new (slot) LocalType( &renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied );
543 }
544
545 inline void SetDepthWriteModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode )
546 {
547   typedef MessageValue1< Renderer, DepthWriteMode::Type > LocalType;
548
549   // Reserve some memory inside the message queue
550   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
551
552   new (slot) LocalType( &renderer, &Renderer::SetDepthWriteMode, depthWriteMode );
553 }
554
555 inline void SetDepthTestModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode )
556 {
557   typedef MessageValue1< Renderer, DepthTestMode::Type > LocalType;
558
559   // Reserve some memory inside the message queue
560   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
561
562   new (slot) LocalType( &renderer, &Renderer::SetDepthTestMode, depthTestMode );
563 }
564
565 inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction )
566 {
567   typedef MessageValue1< Renderer, DepthFunction::Type > LocalType;
568
569   // Reserve some memory inside the message queue
570   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
571
572   new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction );
573 }
574
575 inline void SetStencilModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilMode::Type mode )
576 {
577   typedef MessageValue1< Renderer, StencilMode::Type > LocalType;
578
579   // Reserve some memory inside the message queue
580   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
581
582   new (slot) LocalType( &renderer, &Renderer::SetStencilMode, mode );
583 }
584
585 inline void SetStencilFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction )
586 {
587   typedef MessageValue1< Renderer, StencilFunction::Type > LocalType;
588
589   // Reserve some memory inside the message queue
590   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
591
592   new (slot) LocalType( &renderer, &Renderer::SetStencilFunction, stencilFunction );
593 }
594
595 inline void SetStencilFunctionMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int mask )
596 {
597   typedef MessageValue1< Renderer, int > LocalType;
598
599   // Reserve some memory inside the message queue
600   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
601
602   new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionMask, mask );
603 }
604
605 inline void SetStencilFunctionReferenceMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference )
606 {
607   typedef MessageValue1< Renderer, int > LocalType;
608
609   // Reserve some memory inside the message queue
610   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
611
612   new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference );
613 }
614
615 inline void SetStencilMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask )
616 {
617   typedef MessageValue1< Renderer, int > LocalType;
618
619   // Reserve some memory inside the message queue
620   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
621
622   new (slot) LocalType( &renderer, &Renderer::SetStencilMask, stencilMask );
623 }
624
625 inline void SetStencilOperationOnFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
626 {
627   typedef MessageValue1< Renderer, StencilOperation::Type > LocalType;
628
629   // Reserve some memory inside the message queue
630   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
631
632   new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnFail, stencilOperation );
633 }
634
635 inline void SetStencilOperationOnZFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
636 {
637   typedef MessageValue1< Renderer, StencilOperation::Type > LocalType;
638
639   // Reserve some memory inside the message queue
640   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
641
642   new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation );
643 }
644
645 inline void SetStencilOperationOnZPassMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
646 {
647   typedef MessageValue1< Renderer, StencilOperation::Type > LocalType;
648
649   // Reserve some memory inside the message queue
650   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
651
652   new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation );
653 }
654
655 inline void SetWriteToColorBufferMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, bool writeToColorBuffer )
656 {
657   typedef MessageValue1< Renderer, bool > LocalType;
658
659   // Reserve some memory inside the message queue
660   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
661
662   new (slot) LocalType( &renderer, &Renderer::SetWriteToColorBuffer, writeToColorBuffer );
663 }
664
665 inline void SetBatchingEnabledMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, bool batchable )
666 {
667   typedef MessageValue1< Renderer, bool > LocalType;
668
669   // Reserve some memory inside the message queue
670   unsigned int* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
671
672   new (slot) LocalType( &renderer, &Renderer::SetBatchingEnabled, batchable );
673 }
674
675 } // namespace SceneGraph
676 } // namespace Internal
677 } // namespace Dali
678
679 #endif //  DALI_INTERNAL_SCENE_GRAPH_RENDERER_H