a959f49c3a927fa0606212174c54c0ecffde3b08
[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) 2018 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/devel-api/rendering/renderer-devel.h>
23 #include <dali/internal/common/blending-options.h>
24 #include <dali/internal/common/type-abstraction-enums.h>
25 #include <dali/internal/event/common/event-thread-services.h>
26 #include <dali/internal/update/common/property-owner.h>
27 #include <dali/internal/update/common/uniform-map.h>
28 #include <dali/internal/update/common/scene-graph-connection-change-propagator.h>
29 #include <dali/internal/update/common/animatable-property.h>
30 #include <dali/internal/render/data-providers/render-data-provider.h>
31 #include <dali/internal/render/renderers/render-renderer.h>
32
33 namespace Dali
34 {
35
36 namespace Internal
37 {
38
39 namespace Render
40 {
41 class Renderer;
42 class Geometry;
43 }
44
45 namespace SceneGraph
46 {
47 class SceneController;
48
49 class Renderer;
50 typedef Dali::Vector< Renderer* > RendererContainer;
51 typedef RendererContainer::Iterator RendererIter;
52 typedef RendererContainer::ConstIterator RendererConstIter;
53
54 class TextureSet;
55 class Geometry;
56
57 class Renderer :  public PropertyOwner,
58                   public UniformMapDataProvider,
59                   public UniformMap::Observer,
60                   public ConnectionChangePropagator::Observer
61 {
62 public:
63
64   enum OpacityType
65   {
66     OPAQUE,
67     TRANSPARENT,
68     TRANSLUCENT
69   };
70
71   /**
72    * Construct a new Renderer
73    */
74   static Renderer* New();
75
76   /**
77    * Destructor
78    */
79   virtual ~Renderer();
80
81   /**
82    * Overriden delete operator
83    * Deletes the renderer from its global memory pool
84    */
85   void operator delete( void* ptr );
86
87   /**
88    * Set the texture set for the renderer
89    * @param[in] textureSet The texture set this renderer will use
90    */
91   void SetTextures( TextureSet* textureSet );
92
93   /**
94    * Returns current texture set object
95    * @return Pointer to the texture set
96    */
97   const TextureSet* GetTextures() const
98   {
99     return mTextureSet;
100   }
101
102   /**
103    * Set the shader for the renderer
104    * @param[in] shader The shader this renderer will use
105    */
106   void SetShader( Shader* shader );
107
108   /**
109    * Get the shader used by this renderer
110    * @return the shader this renderer uses
111    */
112   const Shader& GetShader() const
113   {
114     return *mShader;
115   }
116
117   /**
118    * Set the geometry for the renderer
119    * @param[in] geometry The geometry this renderer will use
120    */
121   void SetGeometry( Render::Geometry* geometry );
122
123   /**
124    * Set the depth index
125    * @param[in] depthIndex the new depth index to use
126    */
127   void SetDepthIndex( int depthIndex );
128
129   /**
130    * @brief Get the depth index
131    * @return The depth index
132    */
133   int GetDepthIndex() const
134   {
135     return mDepthIndex;
136   }
137
138   /**
139    * Set the face culling mode
140    * @param[in] faceCullingMode to use
141    */
142   void SetFaceCullingMode( FaceCullingMode::Type faceCullingMode );
143
144   /**
145    * Get face culling mode
146    * @return The face culling mode
147    */
148   FaceCullingMode::Type GetFaceCullingMode() const;
149
150   /**
151    * Set the blending mode
152    * @param[in] blendingMode to use
153    */
154   void SetBlendMode( BlendMode::Type blendingMode );
155
156   /**
157    * Get the blending mode
158    * @return The the blending mode
159    */
160   BlendMode::Type GetBlendMode() const;
161
162   /**
163    * Set the blending options. This should only be called from the update thread.
164    * @param[in] options A bitmask of blending options.
165    */
166   void SetBlendingOptions( uint32_t options );
167
168   /**
169    * Get the blending options
170    * @return The the blending mode
171    */
172   uint32_t GetBlendingOptions() const;
173
174   /**
175    * Set the blend color for blending operation
176    * @param blendColor to pass to GL
177    */
178   void SetBlendColor( const Vector4& blendColor );
179
180   /**
181    * Get the blending color
182    * @return The blend color
183    */
184   Vector4 GetBlendColor() const;
185
186   /**
187    * Set the index of first element for indexed draw
188    * @param[in] firstElement index of first element to draw
189    */
190   void SetIndexedDrawFirstElement( uint32_t firstElement );
191
192   /**
193    * Get the index of first element for indexed draw
194    * @return The index of first element for indexed draw
195    */
196   uint32_t GetIndexedDrawFirstElement() const;
197
198   /**
199    * Set the number of elements to draw by indexed draw
200    * @param[in] elementsCount number of elements to draw
201    */
202   void SetIndexedDrawElementsCount( uint32_t elementsCount );
203
204   /**
205    * Get the number of elements to draw by indexed draw
206    * @return The number of elements to draw by indexed draw
207    */
208   uint32_t GetIndexedDrawElementsCount() const;
209
210   /**
211    * @brief Set whether the Pre-multiplied Alpha Blending is required
212    * @param[in] preMultipled whether alpha is pre-multiplied.
213    */
214   void EnablePreMultipliedAlpha( bool preMultipled );
215
216   /**
217    * @brief Query whether alpha is pre-multiplied.
218    * @return True is alpha is pre-multiplied, false otherwise.
219    */
220   bool IsPreMultipliedAlphaEnabled() const;
221
222   /**
223    * Sets the depth buffer write mode
224    * @param[in] depthWriteMode The depth buffer write mode
225    */
226   void SetDepthWriteMode( DepthWriteMode::Type depthWriteMode );
227
228   /**
229    * Get the depth buffer write mode
230    * @return The depth buffer write mode
231    */
232   DepthWriteMode::Type GetDepthWriteMode() const;
233
234   /**
235    * Sets the depth buffer test mode
236    * @param[in] depthTestMode The depth buffer test mode
237    */
238   void SetDepthTestMode( DepthTestMode::Type depthTestMode );
239
240   /**
241    * Get the depth buffer test mode
242    * @return The depth buffer test mode
243    */
244   DepthTestMode::Type GetDepthTestMode() const;
245
246   /**
247    * Sets the depth function
248    * @param[in] depthFunction The depth function
249    */
250   void SetDepthFunction( DepthFunction::Type depthFunction );
251
252   /**
253    * Get the depth function
254    * @return The depth function
255    */
256   DepthFunction::Type GetDepthFunction() const;
257
258   /**
259    * Sets the render mode
260    * @param[in] mode The render mode
261    */
262   void SetRenderMode( RenderMode::Type mode );
263
264   /**
265    * Sets the stencil function
266    * @param[in] stencilFunction The stencil function
267    */
268   void SetStencilFunction( StencilFunction::Type stencilFunction );
269
270   /**
271    * Sets the stencil function mask
272    * @param[in] stencilFunctionMask The stencil function mask
273    */
274   void SetStencilFunctionMask( int stencilFunctionMask );
275
276   /**
277    * Sets the stencil function reference
278    * @param[in] stencilFunctionReference The stencil function reference
279    */
280   void SetStencilFunctionReference( int stencilFunctionReference );
281
282   /**
283    * Sets the stencil mask
284    * @param[in] stencilMask The stencil mask
285    */
286   void SetStencilMask( int stencilMask );
287
288   /**
289    * Sets the stencil operation for when the stencil test fails
290    * @param[in] stencilOperationOnFail The stencil operation
291    */
292   void SetStencilOperationOnFail( StencilOperation::Type stencilOperationOnFail );
293
294   /**
295    * Sets the stencil operation for when the depth test fails
296    * @param[in] stencilOperationOnZFail The stencil operation
297    */
298   void SetStencilOperationOnZFail( StencilOperation::Type stencilOperationOnZFail );
299
300   /**
301    * Sets the stencil operation for when the depth test passes
302    * @param[in] stencilOperationOnZPass The stencil operation
303    */
304   void SetStencilOperationOnZPass( StencilOperation::Type stencilOperationOnZPass );
305
306   /**
307    * Gets the stencil parameters
308    * @return The stencil parameters
309    */
310   const Render::Renderer::StencilParameters& GetStencilParameters() const;
311
312   /**
313    * Bakes the opacity
314    * @param[in] updateBufferIndex The current update buffer index.
315    * @param[in] opacity The opacity
316    */
317   void BakeOpacity( BufferIndex updateBufferIndex, float opacity );
318
319   /**
320    * Gets the opacity
321    * @param[in] bufferIndex The buffer to read from.
322    * @return The opacity
323    */
324   float GetOpacity( BufferIndex updateBufferIndex ) const;
325
326   /**
327    * Sets the rendering behavior
328    * @param[in] renderingBehavior The rendering behavior required.
329    */
330   void SetRenderingBehavior( DevelRenderer::Rendering::Type renderingBehavior );
331
332   /**
333    * Gets the rendering behavior
334    * @return The rendering behavior
335    */
336   DevelRenderer::Rendering::Type GetRenderingBehavior() const;
337
338   /**
339    * Prepare the object for rendering.
340    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
341    * @param[in] updateBufferIndex The current update buffer index.
342    */
343   void PrepareRender( BufferIndex updateBufferIndex );
344
345   /**
346    * Retrieve the Render thread renderer
347    * @return The associated render thread renderer
348    */
349   Render::Renderer& GetRenderer();
350
351   /**
352    * Query whether the renderer is fully opaque, fully transparent or transparent.
353    * @param[in] updateBufferIndex The current update buffer index.
354    * @return OPAQUE if fully opaque, TRANSPARENT if fully transparent and TRANSLUCENT if in between
355    */
356   OpacityType GetOpacityType( BufferIndex updateBufferIndex, const Node& node ) const;
357
358   /**
359    * Called by the TextureSet to notify to the renderer that it has changed
360    */
361   void TextureSetChanged();
362
363   /**
364    * Called by the TextureSet to notify to the renderer that it is about to be deleted
365    */
366   void TextureSetDeleted();
367
368   /**
369    * Connect the object to the scene graph
370    *
371    * @param[in] sceneController The scene controller - used for sending messages to render thread
372    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
373    */
374   void ConnectToSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
375
376   /**
377    * Disconnect the object from the scene graph
378    * @param[in] sceneController The scene controller - used for sending messages to render thread
379    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
380    */
381   void DisconnectFromSceneGraph( SceneController& sceneController, BufferIndex bufferIndex );
382
383   /**
384    * Enable/Disable Partial update dirty flag
385    * @param[in] true to mark dirty else false
386    */
387   void SetDirty( bool value );
388
389   /**
390    * Get Partial update dirty flag
391    * @return true if dirty else false
392    */
393   bool IsDirty() const;
394
395 public: // Implementation of ConnectionChangePropagator
396   /**
397    * @copydoc ConnectionChangePropagator::AddObserver
398    */
399   void AddConnectionObserver(ConnectionChangePropagator::Observer& observer){};
400
401   /**
402    * @copydoc ConnectionChangePropagator::RemoveObserver
403    */
404   void RemoveConnectionObserver(ConnectionChangePropagator::Observer& observer){};
405
406 public: // UniformMap::Observer
407   /**
408    * @copydoc UniformMap::Observer::UniformMappingsChanged
409    */
410   virtual void UniformMappingsChanged( const UniformMap& mappings );
411
412 public: // ConnectionChangePropagator::Observer
413
414   /**
415    * @copydoc ConnectionChangePropagator::ConnectionsChanged
416    */
417   virtual void ConnectionsChanged( PropertyOwner& owner );
418
419   /**
420    * @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
421    */
422   virtual void ConnectedUniformMapChanged( );
423
424   /**
425    * @copydoc ConnectionChangePropagator::ConnectedUniformMapChanged
426    */
427   virtual void ObservedObjectDestroyed(PropertyOwner& owner);
428
429 public: // PropertyOwner implementation
430   /**
431    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
432    */
433   virtual void ResetDefaultProperties( BufferIndex updateBufferIndex ){};
434
435 public: // From UniformMapDataProvider
436
437   /**
438    * @copydoc UniformMapDataProvider::GetUniformMapChanged
439    */
440   virtual bool GetUniformMapChanged( BufferIndex bufferIndex ) const{ return mUniformMapChanged[bufferIndex];}
441
442   /**
443    * @copydoc UniformMapDataProvider::GetUniformMap
444    */
445   virtual const CollectedUniformMap& GetUniformMap( BufferIndex bufferIndex ) const;
446
447 private:
448
449   /**
450    * Protected constructor; See also Renderer::New()
451    */
452   Renderer();
453
454   /**
455    * Update texture set to the render data provider
456    */
457   void UpdateTextureSet();
458
459 private:
460
461   CollectedUniformMap          mCollectedUniformMap[2];           ///< Uniform maps collected by the renderer
462
463   SceneController*             mSceneController;                  ///< Used for initializing renderers
464   Render::Renderer*            mRenderer;                         ///< Raw pointer to the renderer (that's owned by RenderManager)
465   TextureSet*                  mTextureSet;                       ///< The texture set this renderer uses. (Not owned)
466   Render::Geometry*            mGeometry;                         ///< The geometry this renderer uses. (Not owned)
467   Shader*                      mShader;                           ///< The shader this renderer uses. (Not owned)
468   RenderDataProvider*          mRenderDataProvider;               ///< The render data provider
469   OwnerPointer< Vector4 >      mBlendColor;                       ///< The blend color for blending operation
470
471   Dali::Internal::Render::Renderer::StencilParameters mStencilParameters;         ///< Struct containing all stencil related options
472
473   uint32_t                     mIndexedDrawFirstElement;          ///< first element index to be drawn using indexed draw
474   uint32_t                     mIndexedDrawElementsCount;         ///< number of elements to be drawn using indexed draw
475   uint32_t                     mBlendBitmask;                     ///< The bitmask of blending options
476   uint32_t                     mRegenerateUniformMap;             ///< 2 if the map should be regenerated, 1 if it should be copied.
477   uint32_t                     mResendFlag;                       ///< Indicate whether data should be resent to the renderer
478
479   DepthFunction::Type          mDepthFunction:4;                  ///< Local copy of the depth function
480   FaceCullingMode::Type        mFaceCullingMode:3;                ///< Local copy of the mode of face culling
481   BlendMode::Type              mBlendMode:3;                      ///< Local copy of the mode of blending
482   DepthWriteMode::Type         mDepthWriteMode:3;                 ///< Local copy of the depth write mode
483   DepthTestMode::Type          mDepthTestMode:3;                  ///< Local copy of the depth test mode
484   DevelRenderer::Rendering::Type mRenderingBehavior:2;            ///< The rendering behavior
485   bool                         mUniformMapChanged[2];             ///< Records if the uniform map has been altered this frame
486   bool                         mPremultipledAlphaEnabled:1;       ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
487   bool                         mDirty:1;                          ///< Required for marking it dirty in case of partial update.
488
489 public:
490
491   AnimatableProperty< float >  mOpacity;                          ///< The opacity value
492   int32_t                      mDepthIndex;                       ///< Used only in PrepareRenderInstructions
493
494 };
495
496
497 /// Messages
498 inline void SetTexturesMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const TextureSet& textureSet )
499 {
500   typedef MessageValue1< Renderer, TextureSet* > LocalType;
501
502   // Reserve some memory inside the message queue
503   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
504
505   // Construct message in the message queue memory; note that delete should not be called on the return value
506   new (slot) LocalType( &renderer, &Renderer::SetTextures, const_cast<TextureSet*>(&textureSet) );
507 }
508
509 inline void SetGeometryMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry )
510 {
511   typedef MessageValue1< Renderer, Render::Geometry* > LocalType;
512
513   // Reserve some memory inside the message queue
514   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
515
516   // Construct message in the message queue memory; note that delete should not be called on the return value
517   new (slot) LocalType( &renderer, &Renderer::SetGeometry, const_cast<Render::Geometry*>(&geometry) );
518 }
519
520 inline void SetShaderMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Shader& shader )
521 {
522   typedef MessageValue1< Renderer, Shader* > LocalType;
523
524   // Reserve some memory inside the message queue
525   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
526
527   // Construct message in the message queue memory; note that delete should not be called on the return value
528   new (slot) LocalType( &renderer, &Renderer::SetShader, const_cast<Shader*>( &shader ) );
529 }
530
531 inline void SetDepthIndexMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex )
532 {
533   typedef MessageValue1< Renderer, int > LocalType;
534
535   // Reserve some memory inside the message queue
536   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
537
538   // Construct message in the message queue memory; note that delete should not be called on the return value
539   new (slot) LocalType( &renderer, &Renderer::SetDepthIndex, depthIndex );
540 }
541
542 inline void SetFaceCullingModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode )
543 {
544   typedef MessageValue1< Renderer, FaceCullingMode::Type > LocalType;
545
546   // Reserve some memory inside the message queue
547   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
548
549   new (slot) LocalType( &renderer, &Renderer::SetFaceCullingMode, faceCullingMode );
550 }
551
552 inline void SetBlendModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode )
553 {
554   typedef MessageValue1< Renderer, BlendMode::Type > LocalType;
555
556   // Reserve some memory inside the message queue
557   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
558
559   new (slot) LocalType( &renderer, &Renderer::SetBlendMode, blendingMode );
560 }
561
562 inline void SetBlendingOptionsMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t options )
563 {
564   typedef MessageValue1< Renderer, uint32_t > LocalType;
565
566   // Reserve some memory inside the message queue
567   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
568
569   new (slot) LocalType( &renderer, &Renderer::SetBlendingOptions, options );
570 }
571
572 inline void SetBlendColorMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, const Vector4& blendColor )
573 {
574   typedef MessageValue1< Renderer, Vector4 > LocalType;
575
576   // Reserve some memory inside the message queue
577   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
578
579   new (slot) LocalType( &renderer, &Renderer::SetBlendColor, blendColor );
580 }
581
582 inline void SetIndexedDrawFirstElementMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t firstElement )
583 {
584   typedef MessageValue1< Renderer, uint32_t > LocalType;
585
586   // Reserve some memory inside the message queue
587   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
588
589   new (slot) LocalType( &renderer, &Renderer::SetIndexedDrawFirstElement, firstElement );
590 }
591
592 inline void SetIndexedDrawElementsCountMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t elementsCount )
593 {
594   typedef MessageValue1< Renderer, uint32_t > LocalType;
595
596   // Reserve some memory inside the message queue
597   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
598
599   new (slot) LocalType( &renderer, &Renderer::SetIndexedDrawElementsCount, elementsCount );
600 }
601
602 inline void SetEnablePreMultipliedAlphaMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, bool preMultiplied )
603 {
604   typedef MessageValue1< Renderer, bool > LocalType;
605
606   // Reserve some memory inside the message queue
607   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
608
609   new (slot) LocalType( &renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied );
610 }
611
612 inline void SetDepthWriteModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode )
613 {
614   typedef MessageValue1< Renderer, DepthWriteMode::Type > LocalType;
615
616   // Reserve some memory inside the message queue
617   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
618
619   new (slot) LocalType( &renderer, &Renderer::SetDepthWriteMode, depthWriteMode );
620 }
621
622 inline void SetDepthTestModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode )
623 {
624   typedef MessageValue1< Renderer, DepthTestMode::Type > LocalType;
625
626   // Reserve some memory inside the message queue
627   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
628
629   new (slot) LocalType( &renderer, &Renderer::SetDepthTestMode, depthTestMode );
630 }
631
632 inline void SetDepthFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction )
633 {
634   typedef MessageValue1< Renderer, DepthFunction::Type > LocalType;
635
636   // Reserve some memory inside the message queue
637   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
638
639   new (slot) LocalType( &renderer, &Renderer::SetDepthFunction, depthFunction );
640 }
641
642 inline void SetRenderModeMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode )
643 {
644   typedef MessageValue1< Renderer, RenderMode::Type > LocalType;
645
646   // Reserve some memory inside the message queue
647   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
648
649   new (slot) LocalType( &renderer, &Renderer::SetRenderMode, mode );
650 }
651
652 inline void SetStencilFunctionMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction )
653 {
654   typedef MessageValue1< Renderer, StencilFunction::Type > LocalType;
655
656   // Reserve some memory inside the message queue
657   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
658
659   new (slot) LocalType( &renderer, &Renderer::SetStencilFunction, stencilFunction );
660 }
661
662 inline void SetStencilFunctionMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int mask )
663 {
664   typedef MessageValue1< Renderer, int > LocalType;
665
666   // Reserve some memory inside the message queue
667   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
668
669   new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionMask, mask );
670 }
671
672 inline void SetStencilFunctionReferenceMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference )
673 {
674   typedef MessageValue1< Renderer, int > LocalType;
675
676   // Reserve some memory inside the message queue
677   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
678
679   new (slot) LocalType( &renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference );
680 }
681
682 inline void SetStencilMaskMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask )
683 {
684   typedef MessageValue1< Renderer, int > LocalType;
685
686   // Reserve some memory inside the message queue
687   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
688
689   new (slot) LocalType( &renderer, &Renderer::SetStencilMask, stencilMask );
690 }
691
692 inline void SetStencilOperationOnFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
693 {
694   typedef MessageValue1< Renderer, StencilOperation::Type > LocalType;
695
696   // Reserve some memory inside the message queue
697   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
698
699   new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnFail, stencilOperation );
700 }
701
702 inline void SetStencilOperationOnZFailMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
703 {
704   typedef MessageValue1< Renderer, StencilOperation::Type > LocalType;
705
706   // Reserve some memory inside the message queue
707   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
708
709   new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation );
710 }
711
712 inline void SetStencilOperationOnZPassMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation )
713 {
714   typedef MessageValue1< Renderer, StencilOperation::Type > LocalType;
715
716   // Reserve some memory inside the message queue
717   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
718
719   new (slot) LocalType( &renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation );
720 }
721
722 inline void BakeOpacityMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity )
723 {
724   typedef MessageDoubleBuffered1< Renderer, float > LocalType;
725
726   // Reserve some memory inside the message queue
727   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
728
729   new (slot) LocalType( &renderer, &Renderer::BakeOpacity, opacity );
730 }
731
732 inline void SetRenderingBehaviorMessage( EventThreadServices& eventThreadServices, const Renderer& renderer, DevelRenderer::Rendering::Type renderingBehavior )
733 {
734   using LocalType = MessageValue1< Renderer, DevelRenderer::Rendering::Type >;
735
736   // Reserve some memory inside the message queue
737   uint32_t* slot = eventThreadServices.ReserveMessageSlot( sizeof( LocalType ) );
738
739   new (slot) LocalType( &renderer, &Renderer::SetRenderingBehavior, renderingBehavior );
740 }
741
742 } // namespace SceneGraph
743 } // namespace Internal
744 } // namespace Dali
745
746 #endif //  DALI_INTERNAL_SCENE_GRAPH_RENDERER_H