Merge "Move VisualRenderer properties definition in SceneGraph side." into devel...
[platform/core/uifw/dali-core.git] / dali / internal / update / rendering / scene-graph-renderer.h
1 #ifndef DALI_INTERNAL_SCENE_GRAPH_RENDERER_H
2 #define DALI_INTERNAL_SCENE_GRAPH_RENDERER_H
3
4 /*
5  * Copyright (c) 2022 Samsung Electronics Co., Ltd.
6  *
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  * http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  */
19
20 #include <dali/devel-api/rendering/renderer-devel.h>
21 #include <dali/internal/common/blending-options.h>
22 #include <dali/internal/common/type-abstraction-enums.h>
23 #include <dali/internal/event/common/event-thread-services.h>
24 #include <dali/internal/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                  public UniformMap::Observer
145 {
146 public:
147   enum OpacityType
148   {
149     OPAQUE,
150     TRANSPARENT,
151     TRANSLUCENT
152   };
153
154   /**
155    * Construct a new Renderer
156    */
157   static Renderer* New();
158
159   /**
160    * Destructor
161    */
162   ~Renderer() override;
163
164   /**
165    * Overriden delete operator
166    * Deletes the renderer from its global memory pool
167    */
168   void operator delete(void* ptr);
169
170   /**
171    * Set the texture set for the renderer
172    * @param[in] textureSet The texture set this renderer will use
173    */
174   void SetTextures(TextureSet* textureSet);
175
176   const SceneGraph::TextureSet* GetTextureSet() const
177   {
178     return mTextureSet;
179   }
180
181   /**
182    * @copydoc RenderDataProvider::GetTextures()
183    */
184   const Vector<Render::Texture*>* GetTextures() const override;
185
186   /**
187    * @copydoc RenderDataProvider::GetSamplers()
188    */
189   const Vector<Render::Sampler*>* GetSamplers() const override;
190
191   /**
192    * Set the shader for the renderer
193    * @param[in] shader The shader this renderer will use
194    */
195   void SetShader(Shader* shader);
196
197   /**
198    * @copydoc RenderDataProvider::GetShader()
199    */
200   const Shader& GetShader() const override
201   {
202     return *mShader;
203   }
204
205   /**
206    * Set the geometry for the renderer
207    * @param[in] geometry The geometry this renderer will use
208    */
209   void SetGeometry(Render::Geometry* geometry);
210
211   /**
212    * Set the depth index
213    * @param[in] depthIndex the new depth index to use
214    */
215   void SetDepthIndex(int depthIndex);
216
217   /**
218    * @brief Get the depth index
219    * @return The depth index
220    */
221   int GetDepthIndex() const
222   {
223     return mDepthIndex;
224   }
225
226   /**
227    * Set the face culling mode
228    * @param[in] faceCullingMode to use
229    */
230   void SetFaceCullingMode(FaceCullingMode::Type faceCullingMode);
231
232   /**
233    * Get face culling mode
234    * @return The face culling mode
235    */
236   FaceCullingMode::Type GetFaceCullingMode() const;
237
238   /**
239    * Set the blending mode
240    * @param[in] blendingMode to use
241    */
242   void SetBlendMode(BlendMode::Type blendingMode);
243
244   /**
245    * Get the blending mode
246    * @return The the blending mode
247    */
248   BlendMode::Type GetBlendMode() const;
249
250   /**
251    * Set the blending options. This should only be called from the update thread.
252    * @param[in] options A bitmask of blending options.
253    */
254   void SetBlendingOptions(uint32_t options);
255
256   /**
257    * Get the blending options
258    * @return The the blending mode
259    */
260   uint32_t GetBlendingOptions() const;
261
262   /**
263    * Set the blend color for blending operation
264    * @param blendColor to pass to GL
265    */
266   void SetBlendColor(const Vector4& blendColor);
267
268   /**
269    * Get the blending color
270    * @return The blend color
271    */
272   Vector4 GetBlendColor() const;
273
274   /**
275    * Set the index of first element for indexed draw
276    * @param[in] firstElement index of first element to draw
277    */
278   void SetIndexedDrawFirstElement(uint32_t firstElement);
279
280   /**
281    * Get the index of first element for indexed draw
282    * @return The index of first element for indexed draw
283    */
284   uint32_t GetIndexedDrawFirstElement() const;
285
286   /**
287    * Set the number of elements to draw by indexed draw
288    * @param[in] elementsCount number of elements to draw
289    */
290   void SetIndexedDrawElementsCount(uint32_t elementsCount);
291
292   /**
293    * Get the number of elements to draw by indexed draw
294    * @return The number of elements to draw by indexed draw
295    */
296   uint32_t GetIndexedDrawElementsCount() const;
297
298   /**
299    * @brief Set whether the Pre-multiplied Alpha Blending is required
300    * @param[in] preMultipled whether alpha is pre-multiplied.
301    */
302   void EnablePreMultipliedAlpha(bool preMultipled);
303
304   /**
305    * @brief Query whether alpha is pre-multiplied.
306    * @return True is alpha is pre-multiplied, false otherwise.
307    */
308   bool IsPreMultipliedAlphaEnabled() const;
309
310   /**
311    * Sets the depth buffer write mode
312    * @param[in] depthWriteMode The depth buffer write mode
313    */
314   void SetDepthWriteMode(DepthWriteMode::Type depthWriteMode);
315
316   /**
317    * Get the depth buffer write mode
318    * @return The depth buffer write mode
319    */
320   DepthWriteMode::Type GetDepthWriteMode() const;
321
322   /**
323    * Sets the depth buffer test mode
324    * @param[in] depthTestMode The depth buffer test mode
325    */
326   void SetDepthTestMode(DepthTestMode::Type depthTestMode);
327
328   /**
329    * Get the depth buffer test mode
330    * @return The depth buffer test mode
331    */
332   DepthTestMode::Type GetDepthTestMode() const;
333
334   /**
335    * Sets the depth function
336    * @param[in] depthFunction The depth function
337    */
338   void SetDepthFunction(DepthFunction::Type depthFunction);
339
340   /**
341    * Get the depth function
342    * @return The depth function
343    */
344   DepthFunction::Type GetDepthFunction() const;
345
346   /**
347    * Sets the render mode
348    * @param[in] mode The render mode
349    */
350   void SetRenderMode(RenderMode::Type mode);
351
352   /**
353    * Sets the stencil function
354    * @param[in] stencilFunction The stencil function
355    */
356   void SetStencilFunction(StencilFunction::Type stencilFunction);
357
358   /**
359    * Sets the stencil function mask
360    * @param[in] stencilFunctionMask The stencil function mask
361    */
362   void SetStencilFunctionMask(int stencilFunctionMask);
363
364   /**
365    * Sets the stencil function reference
366    * @param[in] stencilFunctionReference The stencil function reference
367    */
368   void SetStencilFunctionReference(int stencilFunctionReference);
369
370   /**
371    * Sets the stencil mask
372    * @param[in] stencilMask The stencil mask
373    */
374   void SetStencilMask(int stencilMask);
375
376   /**
377    * Sets the stencil operation for when the stencil test fails
378    * @param[in] stencilOperationOnFail The stencil operation
379    */
380   void SetStencilOperationOnFail(StencilOperation::Type stencilOperationOnFail);
381
382   /**
383    * Sets the stencil operation for when the depth test fails
384    * @param[in] stencilOperationOnZFail The stencil operation
385    */
386   void SetStencilOperationOnZFail(StencilOperation::Type stencilOperationOnZFail);
387
388   /**
389    * Sets the stencil operation for when the depth test passes
390    * @param[in] stencilOperationOnZPass The stencil operation
391    */
392   void SetStencilOperationOnZPass(StencilOperation::Type stencilOperationOnZPass);
393
394   /**
395    * Gets the stencil parameters
396    * @return The stencil parameters
397    */
398   const Render::Renderer::StencilParameters& GetStencilParameters() const;
399
400   /**
401    * Bakes the opacity
402    * @param[in] updateBufferIndex The current update buffer index.
403    * @param[in] opacity The opacity
404    */
405   void BakeOpacity(BufferIndex updateBufferIndex, float opacity);
406
407   /**
408    * @copydoc RenderDataProvider::GetOpacity()
409    */
410   float GetOpacity(BufferIndex updateBufferIndex) const override;
411
412   /**
413    * Sets the rendering behavior
414    * @param[in] renderingBehavior The rendering behavior required.
415    */
416   void SetRenderingBehavior(DevelRenderer::Rendering::Type renderingBehavior);
417
418   /**
419    * Gets the rendering behavior
420    * @return The rendering behavior
421    */
422   DevelRenderer::Rendering::Type GetRenderingBehavior() const;
423
424   /**
425    * Prepare the object for rendering.
426    * This is called by the UpdateManager when an object is due to be rendered in the current frame.
427    * @param[in] updateBufferIndex The current update buffer index.
428    * @return Whether this renderer has been updated in the current frame
429    */
430   bool PrepareRender(BufferIndex updateBufferIndex);
431
432   /**
433    * Retrieve the Render thread renderer
434    * @return The associated render thread renderer
435    */
436   Render::Renderer& GetRenderer();
437
438   /**
439    * Query whether the renderer is fully opaque, fully transparent or transparent.
440    * @param[in] updateBufferIndex The current update buffer index.
441    * @return OPAQUE if fully opaque, TRANSPARENT if fully transparent and TRANSLUCENT if in between
442    */
443   OpacityType GetOpacityType(BufferIndex updateBufferIndex, const Node& node) const;
444
445   /**
446    * Connect the object to the scene graph
447    *
448    * @param[in] sceneController The scene controller - used for sending messages to render thread
449    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
450    */
451   void ConnectToSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
452
453   /**
454    * Disconnect the object from the scene graph
455    * @param[in] sceneController The scene controller - used for sending messages to render thread
456    * @param[in] bufferIndex The current buffer index - used for sending messages to render thread
457    */
458   void DisconnectFromSceneGraph(SceneController& sceneController, BufferIndex bufferIndex);
459
460   /**
461    * @copydoc RenderDataProvider::GetUniformMapDataProvider()
462    */
463   const UniformMapDataProvider& GetUniformMapDataProvider() const override
464   {
465     return *this;
466   };
467
468   /**
469    * @copydoc RenderDataProvider::IsUpdated()
470    */
471   bool IsUpdated() const override
472   {
473     return Updated();
474   }
475
476   /**
477    * @copydoc RenderDataProvider::GetVisualTransformedUpdateArea()
478    */
479   Vector4 GetVisualTransformedUpdateArea(BufferIndex updateBufferIndex, const Vector4& originalUpdateArea) noexcept override;
480
481   /**
482    * Sets RenderCallback object
483    *
484    * @param[in] callback Valid pointer to RenderCallback object
485    */
486   void SetRenderCallback(RenderCallback* callback);
487
488   /**
489    * Returns currently set RenderCallback pointer
490    *
491    * @return RenderCallback pointer or nullptr
492    */
493   RenderCallback* GetRenderCallback()
494   {
495     return mRenderCallback;
496   }
497
498   /**
499    * Merge shader uniform map into renderer uniform map if any of the
500    * maps have changed.  Only update uniform map if added to render
501    * instructions.
502    * @param[in] updateBufferIndex The current update buffer index.
503    */
504   void UpdateUniformMap(BufferIndex updateBufferIndex);
505
506   /**
507    * Set the given external draw commands on this renderer.
508    */
509   void SetDrawCommands(Dali::DevelRenderer::DrawCommand* pDrawCommands, uint32_t size);
510
511   /**
512    * Query whether a renderer is dirty.
513    * @return true if the renderer is dirty.
514    * @note It is used to decide whether to reuse the RenderList. We can't reuse the RenderList if this is dirty.
515    */
516   bool IsDirty() const;
517
518   /**
519    * Reset both dirty flag and updated flag.
520    * @note This is called after rendering has completed.
521    */
522   void ResetDirtyFlag();
523
524   /**
525    * Get the capacity of the memory pools
526    * @return the capacity of the memory pools
527    */
528   static uint32_t GetMemoryPoolCapacity();
529
530 public: // UniformMap::Observer
531   /**
532    * @copydoc UniformMap::Observer::UniformMappingsChanged
533    */
534   void UniformMappingsChanged(const UniformMap& mappings) override;
535
536 public: // PropertyOwner implementation
537   /**
538    * @copydoc Dali::Internal::SceneGraph::PropertyOwner::ResetDefaultProperties()
539    */
540   virtual void ResetDefaultProperties(BufferIndex updateBufferIndex){};
541
542 public: // From UniformMapDataProvider
543   /**
544    * @copydoc UniformMapDataProvider::GetCollectedUniformMap
545    */
546   const CollectedUniformMap& GetCollectedUniformMap() const override;
547
548 public: // For VisualProperties
549   /**
550    * To be used only for 1st stage initialization in event thread.
551    */
552   void SetVisualProperties(VisualRenderer::AnimatableVisualProperties* visualProperties)
553   {
554     mVisualProperties = visualProperties;
555   }
556
557   /**
558    * May be accessed from event thread
559    */
560   const VisualRenderer::AnimatableVisualProperties* GetVisualProperties() const
561   {
562     return mVisualProperties.Get();
563   }
564
565 private:
566   /**
567    * Protected constructor; See also Renderer::New()
568    */
569   Renderer();
570
571 private:
572   enum Decay
573   {
574     DONE    = 0,
575     LAST    = 1,
576     INITIAL = 2
577   };
578
579 private:
580   CollectedUniformMap mCollectedUniformMap; ///< Uniform maps collected by the renderer
581
582   SceneController*  mSceneController; ///< Used for initializing renderers
583   Render::Renderer* mRenderer;        ///< Raw pointer to the renderer (that's owned by RenderManager)
584   TextureSet*       mTextureSet;      ///< The texture set this renderer uses. (Not owned)
585   Render::Geometry* mGeometry;        ///< The geometry this renderer uses. (Not owned)
586   Shader*           mShader;          ///< The shader this renderer uses. (Not owned)
587
588   OwnerPointer<VisualRenderer::AnimatableVisualProperties> mVisualProperties{nullptr}; ///< VisualProperties (optional/owned)
589   OwnerPointer<Vector4>                                    mBlendColor;                ///< The blend color for blending operation
590
591   Dali::Internal::Render::Renderer::StencilParameters mStencilParameters; ///< Struct containing all stencil related options
592
593   uint64_t mUniformsHash{0};             ///< Hash of uniform map property values
594   uint32_t mIndexedDrawFirstElement;     ///< first element index to be drawn using indexed draw
595   uint32_t mIndexedDrawElementsCount;    ///< number of elements to be drawn using indexed draw
596   uint32_t mBlendBitmask;                ///< The bitmask of blending options
597   uint32_t mResendFlag;                  ///< Indicate whether data should be resent to the renderer
598   uint32_t mUniformMapChangeCounter{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