[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-core.git] / dali / internal / event / actors / actor-renderer-container.h
1 #ifndef DALI_INTERNAL_ACTORS_ACTOR_RENDERER_CONTAINER_H
2 #define DALI_INTERNAL_ACTORS_ACTOR_RENDERER_CONTAINER_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/event/common/event-thread-services.h>
22 #include <dali/public-api/common/vector-wrapper.h>
23
24 namespace Dali::Internal
25 {
26 using RendererPtr = IntrusivePtr<Renderer>;
27 class Renderer;
28
29 namespace SceneGraph
30 {
31 class Node;
32 }
33
34 /**
35  * Class to contain an actor's renderers.
36  * Enables actor to set the blending for all renderers at once.
37  */
38 class RendererContainer
39 {
40 public:
41   /**
42    * Constructor.
43    *
44    * @param[in] eventThreadServices - thread services for sending messages
45    */
46   RendererContainer(EventThreadServices& eventThreadServices);
47
48   /**
49    * Add a renderer to this actor & actor's node, with blending applied if necessary.
50    * @param[in] node The node to add this renderer's scene graph object to
51    * @param[in] renderer the renderer to add
52    * @param[in] blending If blending equation should be applied to this renderer
53    * @param[in] blendEquation The current blending equation
54    */
55   uint32_t Add(const SceneGraph::Node& node, Renderer& renderer, bool blending, DevelBlendEquation::Type blendEquation);
56
57   /**
58    * Remove the renderer, if present
59    * @param[in] node The node to remove this renderer's scene graph object from
60    * @param[in] renderer The renderer to remove
61    */
62   void Remove(const SceneGraph::Node& node, Renderer& renderer);
63
64   /**
65    * Remove the renderer at given index
66    * @param[in] node The node to remove this renderer's scene graph object from
67    * @param[in] index The index of the renderer to remove
68    */
69   void Remove(const SceneGraph::Node& node, uint32_t index);
70
71   /**
72    * Remove all renderers
73    * @param[in] node The node to remove these renderer's scene graph object from
74    */
75   void RemoveAll(const SceneGraph::Node& node);
76
77   /**
78    * Return the number of renderers
79    * @return the number of renderers
80    */
81   uint32_t GetCount() const;
82
83   /**
84    * @return true if there aren't any renderers
85    */
86   bool IsEmpty() const
87   {
88     return mRenderers.empty();
89   }
90
91   /**
92    * Get the renderer at the given index, if in range.
93    * @param[in] index The index of the renderer to return
94    * @return A renderer at the given index, or nullptr if out of range
95    */
96   RendererPtr GetRendererAt(uint32_t index) const;
97
98   /**
99    * Set the blending equation for all renderers
100    */
101   void SetBlending(DevelBlendEquation::Type blendEquation);
102
103 private:
104   EventThreadServices&     mEventThreadServices; ///< The event thread services (for sending messages)
105   std::vector<RendererPtr> mRenderers;           ///< The contained renderers
106 };
107
108 } // namespace Dali::Internal
109
110 #endif //DALI_INTERNAL_ACTORS_ACTOR_RENDERER_CONTAINER_H