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