Fix surface deletion order issue
[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    * Return the number of renderers
73    * @return the number of renderers
74    */
75   uint32_t GetCount() const;
76
77   /**
78    * @return true if there aren't any renderers
79    */
80   bool IsEmpty() const
81   {
82     return mRenderers.empty();
83   }
84
85   /**
86    * Get the renderer at the given index, if in range.
87    * @param[in] index The index of the renderer to return
88    * @return A renderer at the given index, or nullptr if out of range
89    */
90   RendererPtr GetRendererAt(uint32_t index) const;
91
92   /**
93    * Set the blending equation for all renderers
94    */
95   void SetBlending(DevelBlendEquation::Type blendEquation);
96
97 private:
98   EventThreadServices&     mEventThreadServices; ///< The event thread services (for sending messages)
99   std::vector<RendererPtr> mRenderers;           ///< The contained renderers
100 };
101
102 } // namespace Dali::Internal
103
104 #endif //DALI_INTERNAL_ACTORS_ACTOR_RENDERER_CONTAINER_H