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