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