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