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