DALi Version 2.2.14
[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) 2023 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/memory-pool-key.h>
23 #include <dali/internal/common/type-abstraction-enums.h>
24 #include <dali/internal/event/common/event-thread-services.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 class TextureSet;
49 class Geometry;
50
51 using RendererKey = MemoryPoolKey<SceneGraph::Renderer>;
52
53 } // namespace SceneGraph
54 } // namespace Internal
55
56 // Ensure RendererKey can be used in Dali::Vector
57 template<>
58 struct TypeTraits<Internal::SceneGraph::RendererKey> : public BasicTypes<Internal::SceneGraph::RendererKey>
59 {
60   enum
61   {
62     IS_TRIVIAL_TYPE = true
63   };
64 };
65
66 namespace Internal
67 {
68 namespace SceneGraph
69 {
70 using RendererContainer = Dali::Vector<RendererKey>;
71 using RendererIter      = RendererContainer::Iterator;
72 using RendererConstIter = RendererContainer::ConstIterator;
73
74 namespace VisualRenderer
75 {
76 struct AnimatableVisualProperties
77 {
78   AnimatableVisualProperties()
79   : mTransformOffset(Vector2::ZERO),
80     mTransformSize(Vector2::ONE),
81     mTransformOrigin(Vector2::ZERO),
82     mTransformAnchorPoint(Vector2::ZERO),
83     mTransformOffsetSizeMode(Vector4::ZERO),
84     mExtraSize(Vector2::ZERO),
85     mMixColor(Vector3::ONE),
86     mPreMultipliedAlpha(0.0f),
87     mExtendedPropertiesDeleteFunction(nullptr)
88   {
89   }
90
91   ~AnimatableVisualProperties()
92   {
93     if(mExtendedProperties && mExtendedPropertiesDeleteFunction)
94     {
95       mExtendedPropertiesDeleteFunction(mExtendedProperties);
96     }
97   }
98
99   /**
100    * @brief Cached coefficient value when we calculate visual transformed update size.
101    * It can reduce complexity of calculate the vertex position.
102    *
103    * Vector2 vertexPosition = (XA * aPosition + XB) * originalSize + (CA * aPosition + CB) + Vector2(D, D) * aPosition
104    */
105   struct VisualTransformedUpdateSizeCoefficientCache
106   {
107     Vector2 coefXA{Vector2::ZERO};
108     Vector2 coefXB{Vector2::ZERO};
109     Vector2 coefCA{Vector2::ZERO};
110     Vector2 coefCB{Vector2::ZERO};
111     float   coefD{0.0f};
112
113     uint64_t hash{0u};
114     uint64_t decoratedHash{0u};
115   };
116   VisualTransformedUpdateSizeCoefficientCache mCoefficient; ///< Coefficient value to calculate visual transformed update size by VisualProperties more faster.
117
118   AnimatableProperty<Vector2> mTransformOffset;
119   AnimatableProperty<Vector2> mTransformSize;
120   AnimatableProperty<Vector2> mTransformOrigin;
121   AnimatableProperty<Vector2> mTransformAnchorPoint;
122   AnimatableProperty<Vector4> mTransformOffsetSizeMode;
123   AnimatableProperty<Vector2> mExtraSize;
124   AnimatableProperty<Vector3> mMixColor;
125   AnimatableProperty<float>   mPreMultipliedAlpha;
126
127   void* mExtendedProperties{nullptr};                        // Enable derived class to extend properties further
128   void (*mExtendedPropertiesDeleteFunction)(void*){nullptr}; // Derived class's custom delete functor
129 };
130
131 struct AnimatableDecoratedVisualProperties
132 {
133   AnimatableDecoratedVisualProperties()
134   : mCornerRadius(Vector4::ZERO),
135     mCornerRadiusPolicy(1.0f),
136     mBorderlineWidth(0.0f),
137     mBorderlineColor(Color::BLACK),
138     mBorderlineOffset(0.0f),
139     mBlurRadius(0.0f)
140   {
141   }
142   ~AnimatableDecoratedVisualProperties()
143   {
144   }
145
146   // Delete function of AnimatableDecoratedVisualProperties* converted as void*
147   static void DeleteFunction(void* data)
148   {
149     delete static_cast<AnimatableDecoratedVisualProperties*>(data);
150   }
151
152   AnimatableProperty<Vector4> mCornerRadius;
153   AnimatableProperty<float>   mCornerRadiusPolicy;
154   AnimatableProperty<float>   mBorderlineWidth;
155   AnimatableProperty<Vector4> mBorderlineColor;
156   AnimatableProperty<float>   mBorderlineOffset;
157   AnimatableProperty<float>   mBlurRadius;
158 };
159 } // namespace VisualRenderer
160
161 class Renderer : public PropertyOwner,
162                  public UniformMapDataProvider,
163                  public RenderDataProvider
164 {
165 public:
166   enum OpacityType
167   {
168     OPAQUE,
169     TRANSPARENT,
170     TRANSLUCENT
171   };
172
173   /**
174    * Construct a new Renderer
175    */
176   static RendererKey NewKey();
177
178   /**
179    * Destructor
180    */
181   ~Renderer() override;
182
183   /**
184    * Overriden delete operator
185    * Deletes the renderer from its global memory pool
186    */
187   void operator delete(void* ptr);
188
189   /**
190    * Get a pointer to the object from the given key.
191    * Used by MemoryPoolKey to provide pointer semantics.
192    */
193   static Renderer* Get(RendererKey::KeyType);
194
195   /**
196    * Get the key of the given renderer in the associated memory pool.
197    * @param[in] renderer the given renderer
198    * @return The key in the associated memory pool.
199    */
200   static RendererKey GetKey(const SceneGraph::Renderer& renderer);
201
202   /**
203    * Get the key of the given renderer in the associated memory pool.
204    * @param[in] renderer the given renderer
205    * @return The key in the associated memory pool, or -1 if not
206    * found.
207    */
208   static RendererKey GetKey(SceneGraph::Renderer* renderer);
209
210   /**
211    * Set the texture set for the renderer
212    * @param[in] textureSet The texture set this renderer will use
213    */
214   void SetTextures(TextureSet* textureSet);
215
216   /**
217    * Get the associated texture set
218    * @return the texture set.
219    */
220   const SceneGraph::TextureSet* GetTextureSet() const
221   {
222     return mTextureSet;
223   }
224
225   /**
226    * @copydoc RenderDataProvider::GetTextures()
227    */
228   const Vector<Render::TextureKey>* GetTextures() const override;
229
230   /**
231    * @copydoc RenderDataProvider::GetSamplers()
232    */
233   const Vector<Render::Sampler*>* GetSamplers() const override;
234
235   /**
236    * Set the shader for the renderer
237    * @param[in] shader The shader this renderer will use
238    */
239   void SetShader(Shader* shader);
240
241   /**
242    * @copydoc RenderDataProvider::GetShader()
243    */
244   const Shader& GetShader() const override
245   {
246     return *mShader;
247   }
248
249   /**
250    * Set the geometry for the renderer
251    * @param[in] geometry The geometry this renderer will use
252    */
253   void SetGeometry(Render::Geometry* geometry);
254
255   /**
256    * Set the depth index
257    * @param[in] depthIndex the new depth index to use
258    */
259   void SetDepthIndex(int depthIndex);
260
261   /**
262    * @brief Get the depth index
263    * @return The depth index
264    */
265   int GetDepthIndex() const
266   {
267     return mDepthIndex;
268   }
269
270   /**
271    * Set the face culling mode
272    * @param[in] faceCullingMode to use
273    */
274   void SetFaceCullingMode(FaceCullingMode::Type faceCullingMode);
275
276   /**
277    * Get face culling mode
278    * @return The face culling mode
279    */
280   FaceCullingMode::Type GetFaceCullingMode() const;
281
282   /**
283    * Set the blending mode
284    * @param[in] blendingMode to use
285    */
286   void SetBlendMode(BlendMode::Type blendingMode);
287
288   /**
289    * Get the blending mode
290    * @return The the blending mode
291    */
292   BlendMode::Type GetBlendMode() const;
293
294   /**
295    * Set the blending options. This should only be called from the update thread.
296    * @param[in] options A bitmask of blending options.
297    */
298   void SetBlendingOptions(uint32_t options);
299
300   /**
301    * Get the blending options
302    * @return The the blending mode
303    */
304   uint32_t GetBlendingOptions() const;
305
306   /**
307    * Set the blend color for blending operation
308    * @param blendColor to pass to GL
309    */
310   void SetBlendColor(const Vector4& blendColor);
311
312   /**
313    * Get the blending color
314    * @return The blend color
315    */
316   Vector4 GetBlendColor() const;
317
318   /**
319    * Set the index of first element for indexed draw
320    * @param[in] firstElement index of first element to draw
321    */
322   void SetIndexedDrawFirstElement(uint32_t firstElement);
323
324   /**
325    * Get the index of first element for indexed draw
326    * @return The index of first element for indexed draw
327    */
328   uint32_t GetIndexedDrawFirstElement() const;
329
330   /**
331    * Set the number of elements to draw by indexed draw
332    * @param[in] elementsCount number of elements to draw
333    */
334   void SetIndexedDrawElementsCount(uint32_t elementsCount);
335
336   /**
337    * Get the number of elements to draw by indexed draw
338    * @return The number of elements to draw by indexed draw
339    */
340   uint32_t GetIndexedDrawElementsCount() const;
341
342   /**
343    * @brief Set whether the Pre-multiplied Alpha Blending is required
344    * @param[in] preMultipled whether alpha is pre-multiplied.
345    */
346   void EnablePreMultipliedAlpha(bool preMultipled);
347
348   /**
349    * @brief Query whether alpha is pre-multiplied.
350    * @return True is alpha is pre-multiplied, false otherwise.
351    */
352   bool IsPreMultipliedAlphaEnabled() const;
353
354   /**
355    * Sets the depth buffer write mode
356    * @param[in] depthWriteMode The depth buffer write mode
357    */
358   void SetDepthWriteMode(DepthWriteMode::Type depthWriteMode);
359
360   /**
361    * Get the depth buffer write mode
362    * @return The depth buffer write mode
363    */
364   DepthWriteMode::Type GetDepthWriteMode() const;
365
366   /**
367    * Sets the depth buffer test mode
368    * @param[in] depthTestMode The depth buffer test mode
369    */
370   void SetDepthTestMode(DepthTestMode::Type depthTestMode);
371
372   /**
373    * Get the depth buffer test mode
374    * @return The depth buffer test mode
375    */
376   DepthTestMode::Type GetDepthTestMode() const;
377
378   /**
379    * Sets the depth function
380    * @param[in] depthFunction The depth function
381    */
382   void SetDepthFunction(DepthFunction::Type depthFunction);
383
384   /**
385    * Get the depth function
386    * @return The depth function
387    */
388   DepthFunction::Type GetDepthFunction() const;
389
390   /**
391    * Sets the render mode
392    * @param[in] mode The render mode
393    */
394   void SetRenderMode(RenderMode::Type mode);
395
396   /**
397    * Sets the stencil function
398    * @param[in] stencilFunction The stencil function
399    */
400   void SetStencilFunction(StencilFunction::Type stencilFunction);
401
402   /**
403    * Sets the stencil function mask
404    * @param[in] stencilFunctionMask The stencil function mask
405    */
406   void SetStencilFunctionMask(int stencilFunctionMask);
407
408   /**
409    * Sets the stencil function reference
410    * @param[in] stencilFunctionReference The stencil function reference
411    */
412   void SetStencilFunctionReference(int stencilFunctionReference);
413
414   /**
415    * Sets the stencil mask
416    * @param[in] stencilMask The stencil mask
417    */
418   void SetStencilMask(int stencilMask);
419
420   /**
421    * Sets the stencil operation for when the stencil test fails
422    * @param[in] stencilOperationOnFail The stencil operation
423    */
424   void SetStencilOperationOnFail(StencilOperation::Type stencilOperationOnFail);
425
426   /**
427    * Sets the stencil operation for when the depth test fails
428    * @param[in] stencilOperationOnZFail The stencil operation
429    */
430   void SetStencilOperationOnZFail(StencilOperation::Type stencilOperationOnZFail);
431
432   /**
433    * Sets the stencil operation for when the depth test passes
434    * @param[in] stencilOperationOnZPass The stencil operation
435    */
436   void SetStencilOperationOnZPass(StencilOperation::Type stencilOperationOnZPass);
437
438   /**
439    * Gets the stencil parameters
440    * @return The stencil parameters
441    */
442   const Render::Renderer::StencilParameters& GetStencilParameters() const;
443
444   /**
445    * Bakes the opacity
446    * @param[in] updateBufferIndex The current update buffer index.
447    * @param[in] opacity The opacity
448    */
449   void BakeOpacity(BufferIndex updateBufferIndex, float opacity);
450
451   /**
452    * @copydoc RenderDataProvider::GetOpacity()
453    */
454   float GetOpacity(BufferIndex updateBufferIndex) const override;
455
456   /**
457    * Sets the rendering behavior
458    * @param[in] renderingBehavior The rendering behavior required.
459    */
460   void SetRenderingBehavior(DevelRenderer::Rendering::Type renderingBehavior);
461
462   /**
463    * Gets the rendering behavior
464    * @return The rendering behavior
465    */
466   DevelRenderer::Rendering::Type GetRenderingBehavior() const;
467
468   /**
469    * Prepare the object for rendering.
470    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
471    * @param[in] updateBufferIndex The current update buffer index.
472    * @return Whether this renderer has been updated in the current frame
473    */
474   bool PrepareRender(BufferIndex updateBufferIndex);
475
476   /**
477    * Retrieve the Render thread renderer
478    * @return The associated render thread renderer
479    */
480   Render::RendererKey GetRenderer();
481
482   /**
483    * Query whether the renderer is fully opaque, fully transparent or transparent.
484    * @param[in] updateBufferIndex The current update buffer index.
485    * @return OPAQUE if fully opaque, TRANSPARENT if fully transparent and TRANSLUCENT if in between
486    */
487   OpacityType GetOpacityType(BufferIndex updateBufferIndex, const Node& node) const;
488
489   /**
490    * Connect the object to the scene graph
491    *
492    * @param[in] sceneController The scene controller - used for sending messages to render thread
493    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
494    */
495   void ConnectToSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
496
497   /**
498    * Disconnect the object from the scene graph
499    * @param[in] sceneController The scene controller - used for sending messages to render thread
500    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
501    */
502   void DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
503
504   /**
505    * @copydoc RenderDataProvider::GetUniformMapDataProvider()
506    */
507   const UniformMapDataProvider& GetUniformMapDataProvider() const override
508   {
509     return *this;
510   };
511
512   /**
513    * @copydoc RenderDataProvider::IsUpdated()
514    */
515   bool IsUpdated() const override
516   {
517     return Updated();
518   }
519
520   /**
521    * @copydoc RenderDataProvider::GetVisualTransformedUpdateArea()
522    */
523   Vector4 GetVisualTransformedUpdateArea(BufferIndex updateBufferIndex, const Vector4& originalUpdateArea) noexcept override;
524
525   /**
526    * Sets RenderCallback object
527    *
528    * @param[in] callback Valid pointer to RenderCallback object
529    */
530   void SetRenderCallback(RenderCallback* callback);
531
532   /**
533    * Returns currently set RenderCallback pointer
534    *
535    * @return RenderCallback pointer or nullptr
536    */
537   RenderCallback* GetRenderCallback()
538   {
539     return mRenderCallback;
540   }
541
542   /**
543    * Merge shader uniform map into renderer uniform map if any of the
544    * maps have changed.  Only update uniform map if added to render
545    * instructions.
546    * @param[in] updateBufferIndex The current update buffer index.
547    */
548   void UpdateUniformMap(BufferIndex updateBufferIndex);
549
550   /**
551    * Set the given external draw commands on this renderer.
552    */
553   void SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size);
554
555   /**
556    * Query whether a renderer is dirty.
557    * @return true if the renderer is dirty.
558    * @note It is used to decide whether to reuse the RenderList. We can't reuse the RenderList if this is dirty.
559    */
560   bool IsDirty() const;
561
562   /**
563    * Reset both dirty flag and updated flag.
564    * @note This is called after rendering has completed.
565    */
566   void ResetDirtyFlag();
567
568   /**
569    * Get the capacity of the memory pools
570    * @return the capacity of the memory pools
571    */
572   static uint32_t GetMemoryPoolCapacity();
573
574 public: // PropertyOwner::MappingChanged
575   /**
576    * @copydoc PropertyOwner::OnMappingChanged
577    */
578   void OnMappingChanged() override;
579
580 public: // PropertyOwner implementation
581   /**
582    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
583    */
584   virtual void ResetDefaultProperties(BufferIndex updateBufferIndex){};
585
586 public: // From UniformMapDataProvider
587   /**
588    * @copydoc UniformMapDataProvider::GetCollectedUniformMap
589    */
590   const CollectedUniformMap& GetCollectedUniformMap() const override;
591
592 public: // For VisualProperties
593   /**
594    * To be used only for 1st stage initialization in event thread.
595    */
596   void SetVisualProperties(VisualRenderer::AnimatableVisualProperties* visualProperties)
597   {
598     mVisualProperties = visualProperties;
599   }
600
601   /**
602    * May be accessed from event thread
603    */
604   const VisualRenderer::AnimatableVisualProperties* GetVisualProperties() const
605   {
606     return mVisualProperties.Get();
607   }
608
609 private:
610   /**
611    * Protected constructor; See also Renderer::New()
612    */
613   Renderer();
614
615 private:
616   enum Decay
617   {
618     DONE    = 0,
619     LAST    = 1,
620     INITIAL = 2
621   };
622
623 private:
624   CollectedUniformMap mCollectedUniformMap; ///< Uniform maps collected by the renderer
625
626   SceneController*    mSceneController; ///< Used for initializing renderers
627   Render::RendererKey mRenderer;        ///< Key to the renderer (that's owned by RenderManager)
628   TextureSet*         mTextureSet;      ///< The texture set this renderer uses. (Not owned)
629   Render::Geometry*   mGeometry;        ///< The geometry this renderer uses. (Not owned)
630   Shader*             mShader;          ///< The shader this renderer uses. (Not owned)
631
632   OwnerPointer<VisualRenderer::AnimatableVisualProperties> mVisualProperties{nullptr}; ///< VisualProperties (optional/owned)
633   OwnerPointer<Vector4>                                    mBlendColor;                ///< The blend color for blending operation
634
635   Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
636
637   uint64_t             mUniformsHash{0};             ///< Hash of uniform map property values
638   uint32_t             mIndexedDrawFirstElement;     ///< first element index to be drawn using indexed draw
639   uint32_t             mIndexedDrawElementsCount;    ///< number of elements to be drawn using indexed draw
640   uint32_t             mBlendBitmask;                ///< The bitmask of blending options
641   uint32_t             mResendFlag;                  ///< Indicate whether data should be resent to the renderer
642   UniformMap::SizeType mUniformMapChangeCounter{0u}; ///< Value to check if uniform data should be updated
643   UniformMap::SizeType mShaderMapChangeCounter{0u};  ///< Value to check if uniform data should be updated
644
645   DepthFunction::Type            mDepthFunction : 4;     ///< Local copy of the depth function
646   FaceCullingMode::Type          mFaceCullingMode : 3;   ///< Local copy of the mode of face culling
647   BlendMode::Type                mBlendMode : 3;         ///< Local copy of the mode of blending
648   DepthWriteMode::Type           mDepthWriteMode : 3;    ///< Local copy of the depth write mode
649   DepthTestMode::Type            mDepthTestMode : 3;     ///< Local copy of the depth test mode
650   DevelRenderer::Rendering::Type mRenderingBehavior : 2; ///< The rendering behavior
651   Decay                          mUpdateDecay : 2;       ///< Update decay (aging)
652
653   bool mRegenerateUniformMap : 1;     ///< true if the map should be regenerated
654   bool mPremultipledAlphaEnabled : 1; ///< Flag indicating whether the Pre-multiplied Alpha Blending is required
655   bool mDirtyFlag : 1;                ///< Flag indicating whether the properties are changed
656
657   std::vector<Dali::DevelRenderer::DrawCommand> mDrawCommands;
658   Dali::RenderCallback*                         mRenderCallback{nullptr};
659
660 public:
661   AnimatableProperty<float> mOpacity;    ///< The opacity value
662   int32_t                   mDepthIndex; ///< Used only in PrepareRenderInstructions
663 };
664
665 /// Messages
666 inline void SetTexturesMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const TextureSet& textureSet)
667 {
668   using LocalType = MessageValue1<Renderer, TextureSet*>;
669
670   // Reserve some memory inside the message queue
671   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
672
673   // Construct message in the message queue memory; note that delete should not be called on the return value
674   new(slot) LocalType(&renderer, &Renderer::SetTextures, const_cast<TextureSet*>(&textureSet));
675 }
676
677 inline void SetGeometryMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Render::Geometry& geometry)
678 {
679   using LocalType = MessageValue1<Renderer, Render::Geometry*>;
680
681   // Reserve some memory inside the message queue
682   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
683
684   // Construct message in the message queue memory; note that delete should not be called on the return value
685   new(slot) LocalType(&renderer, &Renderer::SetGeometry, const_cast<Render::Geometry*>(&geometry));
686 }
687
688 inline void SetShaderMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Shader& shader)
689 {
690   using LocalType = MessageValue1<Renderer, Shader*>;
691
692   // Reserve some memory inside the message queue
693   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
694
695   // Construct message in the message queue memory; note that delete should not be called on the return value
696   new(slot) LocalType(&renderer, &Renderer::SetShader, const_cast<Shader*>(&shader));
697 }
698
699 inline void SetDepthIndexMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int depthIndex)
700 {
701   using LocalType = MessageValue1<Renderer, int>;
702
703   // Reserve some memory inside the message queue
704   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
705
706   // Construct message in the message queue memory; note that delete should not be called on the return value
707   new(slot) LocalType(&renderer, &Renderer::SetDepthIndex, depthIndex);
708 }
709
710 inline void SetFaceCullingModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, FaceCullingMode::Type faceCullingMode)
711 {
712   using LocalType = MessageValue1<Renderer, FaceCullingMode::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::SetFaceCullingMode, faceCullingMode);
718 }
719
720 inline void SetBlendModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, BlendMode::Type blendingMode)
721 {
722   using LocalType = MessageValue1<Renderer, BlendMode::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::SetBlendMode, blendingMode);
728 }
729
730 inline void SetBlendingOptionsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t options)
731 {
732   using LocalType = MessageValue1<Renderer, uint32_t>;
733
734   // Reserve some memory inside the message queue
735   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
736
737   new(slot) LocalType(&renderer, &Renderer::SetBlendingOptions, options);
738 }
739
740 inline void SetBlendColorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, const Vector4& blendColor)
741 {
742   using LocalType = MessageValue1<Renderer, Vector4>;
743
744   // Reserve some memory inside the message queue
745   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
746
747   new(slot) LocalType(&renderer, &Renderer::SetBlendColor, blendColor);
748 }
749
750 inline void SetIndexedDrawFirstElementMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t firstElement)
751 {
752   using LocalType = MessageValue1<Renderer, uint32_t>;
753
754   // Reserve some memory inside the message queue
755   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
756
757   new(slot) LocalType(&renderer, &Renderer::SetIndexedDrawFirstElement, firstElement);
758 }
759
760 inline void SetIndexedDrawElementsCountMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, uint32_t elementsCount)
761 {
762   using LocalType = MessageValue1<Renderer, 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::SetIndexedDrawElementsCount, elementsCount);
768 }
769
770 inline void SetEnablePreMultipliedAlphaMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, bool preMultiplied)
771 {
772   using LocalType = MessageValue1<Renderer, bool>;
773
774   // Reserve some memory inside the message queue
775   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
776
777   new(slot) LocalType(&renderer, &Renderer::EnablePreMultipliedAlpha, preMultiplied);
778 }
779
780 inline void SetDepthWriteModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthWriteMode::Type depthWriteMode)
781 {
782   using LocalType = MessageValue1<Renderer, DepthWriteMode::Type>;
783
784   // Reserve some memory inside the message queue
785   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
786
787   new(slot) LocalType(&renderer, &Renderer::SetDepthWriteMode, depthWriteMode);
788 }
789
790 inline void SetDepthTestModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthTestMode::Type depthTestMode)
791 {
792   using LocalType = MessageValue1<Renderer, DepthTestMode::Type>;
793
794   // Reserve some memory inside the message queue
795   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
796
797   new(slot) LocalType(&renderer, &Renderer::SetDepthTestMode, depthTestMode);
798 }
799
800 inline void SetDepthFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DepthFunction::Type depthFunction)
801 {
802   using LocalType = MessageValue1<Renderer, DepthFunction::Type>;
803
804   // Reserve some memory inside the message queue
805   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
806
807   new(slot) LocalType(&renderer, &Renderer::SetDepthFunction, depthFunction);
808 }
809
810 inline void SetRenderModeMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, RenderMode::Type mode)
811 {
812   using LocalType = MessageValue1<Renderer, RenderMode::Type>;
813
814   // Reserve some memory inside the message queue
815   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
816
817   new(slot) LocalType(&renderer, &Renderer::SetRenderMode, mode);
818 }
819
820 inline void SetStencilFunctionMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilFunction::Type stencilFunction)
821 {
822   using LocalType = MessageValue1<Renderer, StencilFunction::Type>;
823
824   // Reserve some memory inside the message queue
825   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
826
827   new(slot) LocalType(&renderer, &Renderer::SetStencilFunction, stencilFunction);
828 }
829
830 inline void SetStencilFunctionMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int mask)
831 {
832   using LocalType = MessageValue1<Renderer, int>;
833
834   // Reserve some memory inside the message queue
835   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
836
837   new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionMask, mask);
838 }
839
840 inline void SetStencilFunctionReferenceMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilFunctionReference)
841 {
842   using LocalType = MessageValue1<Renderer, int>;
843
844   // Reserve some memory inside the message queue
845   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
846
847   new(slot) LocalType(&renderer, &Renderer::SetStencilFunctionReference, stencilFunctionReference);
848 }
849
850 inline void SetStencilMaskMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, int stencilMask)
851 {
852   using LocalType = MessageValue1<Renderer, int>;
853
854   // Reserve some memory inside the message queue
855   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
856
857   new(slot) LocalType(&renderer, &Renderer::SetStencilMask, stencilMask);
858 }
859
860 inline void SetStencilOperationOnFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation)
861 {
862   using LocalType = MessageValue1<Renderer, StencilOperation::Type>;
863
864   // Reserve some memory inside the message queue
865   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
866
867   new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnFail, stencilOperation);
868 }
869
870 inline void SetStencilOperationOnZFailMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation)
871 {
872   using LocalType = MessageValue1<Renderer, StencilOperation::Type>;
873
874   // Reserve some memory inside the message queue
875   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
876
877   new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZFail, stencilOperation);
878 }
879
880 inline void SetStencilOperationOnZPassMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, StencilOperation::Type stencilOperation)
881 {
882   using LocalType = MessageValue1<Renderer, StencilOperation::Type>;
883
884   // Reserve some memory inside the message queue
885   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
886
887   new(slot) LocalType(&renderer, &Renderer::SetStencilOperationOnZPass, stencilOperation);
888 }
889
890 inline void BakeOpacityMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, float opacity)
891 {
892   using LocalType = MessageDoubleBuffered1<Renderer, float>;
893
894   // Reserve some memory inside the message queue
895   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
896
897   new(slot) LocalType(&renderer, &Renderer::BakeOpacity, opacity);
898 }
899
900 inline void SetRenderingBehaviorMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, DevelRenderer::Rendering::Type renderingBehavior)
901 {
902   using LocalType = MessageValue1<Renderer, DevelRenderer::Rendering::Type>;
903
904   // Reserve some memory inside the message queue
905   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
906
907   new(slot) LocalType(&renderer, &Renderer::SetRenderingBehavior, renderingBehavior);
908 }
909
910 inline void SetDrawCommandsMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size)
911 {
912   using LocalType = MessageValue2<Renderer, Dali::DevelRenderer::DrawCommand*, uint32_t>;
913
914   // Reserve some memory inside the message queue
915   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
916
917   new(slot) LocalType(&renderer, &Renderer::SetDrawCommands, pDrawCommands, size);
918 }
919
920 inline void SetRenderCallbackMessage(EventThreadServices& eventThreadServices, const Renderer& renderer, Dali::RenderCallback* callback)
921 {
922   using LocalType = MessageValue1<Renderer, Dali::RenderCallback*>;
923
924   // Reserve some memory inside the message queue
925   uint32_t* slot = eventThreadServices.ReserveMessageSlot(sizeof(LocalType));
926
927   new(slot) LocalType(&renderer, &Renderer::SetRenderCallback, callback);
928 }
929
930 } // namespace SceneGraph
931 } // namespace Internal
932 } // namespace Dali
933
934 #endif // DALI_INTERNAL_SCENE_GRAPH_RENDERER_H