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