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