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