[dali_2.3.25] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / offscreen-window.h
1 #ifndef DALI_OFFSCREEN_WINDOW_H
2 #define DALI_OFFSCREEN_WINDOW_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
21 // EXTERNAL INCLUDES
22 #include <dali/public-api/actors/actor.h>
23 #include <dali/public-api/math/uint-16-pair.h>
24 #include <dali/public-api/object/any.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_adaptor_framework
33  * @{
34  */
35
36 class Layer;
37
38 namespace Internal
39 {
40 class OffscreenWindow;
41 }
42
43 class DALI_ADAPTOR_API OffscreenWindow : public Dali::BaseHandle
44 {
45 public:
46   using WindowSize = Uint16Pair;
47
48 public:
49   /**
50    * @brief Creates an initialized handle to a new OffscreenWindow
51    * @note You should hold the returned handle. If you missed the handle, the OffscreenWindow will be released
52    *
53    * @param[in] width The initial width of the OffscreenWindow
54    * @param[in] height The initial height of the OffscreenWindow
55    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
56    */
57   static OffscreenWindow New(uint16_t width, uint16_t height, bool isTranslucent);
58
59   /**
60    * @brief Creates an initialized handle to a new OffscreenWindow
61    * @note You should hold the returned handle. If you missed the handle, the OffscreenWindow will be released
62    *
63    * @param[in] surface The native surface handle of your platform
64    */
65   static OffscreenWindow New(Any surface);
66
67   /**
68    * @brief Constructs an empty handle
69    */
70   OffscreenWindow();
71
72   /**
73    * @brief Copy constructor
74    *
75    * @param [in] window A reference to the copied handle
76    */
77   OffscreenWindow(const OffscreenWindow& window);
78
79   /**
80    * @brief Assignment operator
81    *
82    * @param [in] window A reference to the copied handle
83    * @return A reference to this
84    */
85   OffscreenWindow& operator=(const OffscreenWindow& window);
86
87   /**
88    * @brief Move constructor
89    *
90    * @param [in] window A reference to the moved handle
91    */
92   OffscreenWindow(OffscreenWindow&& window);
93
94   /**
95    * @brief Move assignment operator
96    *
97    * @param [in] window A reference to the moved handle
98    * @return A reference to this
99    */
100   OffscreenWindow& operator=(OffscreenWindow&& window);
101
102   /**
103    * @brief Destructor
104    */
105   ~OffscreenWindow();
106
107 public:
108   /**
109    * @brief Adds a child Actor to the OffscreenWindow.
110    *
111    * The child will be referenced.
112    *
113    * @param[in] actor The child
114    * @pre The actor has been initialized.
115    * @pre The actor does not have a parent.
116    */
117   void Add(Actor actor);
118
119   /**
120    * @brief Removes a child Actor from the OffscreenWindow.
121    *
122    * The child will be unreferenced.
123    *
124    * @param[in] actor The child
125    * @pre The actor has been added to the OffscreenWindow.
126    */
127   void Remove(Actor actor);
128
129   /**
130    * @brief Sets the background color of the OffscreenWindow.
131    *
132    * @param[in] color The new background color
133    */
134   void SetBackgroundColor(const Vector4& color);
135
136   /**
137    * @brief Gets the background color of the OffscreenWindow.
138    *
139    * @return The background color
140    */
141   Vector4 GetBackgroundColor() const;
142
143   /**
144    * @brief Returns the root Layer of the OffscreenWindow.
145    *
146    * @return The root layer
147    */
148   Layer GetRootLayer() const;
149
150   /**
151    * @brief Queries the number of on-scene layers.
152    *
153    * Note that a default layer is always provided (count >= 1).
154    *
155    * @return The number of layers
156    */
157   uint32_t GetLayerCount() const;
158
159   /**
160    * @brief Retrieves the layer at a specified depth in the OffscreenWindow.
161    *
162    * @param[in] depth The depth
163    * @return The layer found at the given depth
164    * @pre Depth is less than layer count; see GetLayerCount().
165    */
166   Layer GetLayer(uint32_t depth) const;
167
168   /**
169    * @brief Returns the size of the OffscreenWindow in pixels as a Vector.
170    *
171    * The x component will be the width of the OffscreenWindow in pixels.
172    * The y component will be the height of the OffscreenWindow in pixels.
173    *
174    * @return The size of the OffscreenWindow as a Vector
175    */
176   WindowSize GetSize() const;
177
178   /**
179    * @brief Gets the native handle.
180    * @note When users call this function, it wraps the actual type used by the underlying system.
181    * @return The native handle or an empty handle
182    */
183   Any GetNativeHandle() const;
184
185   /**
186    * @brief Retrieves the DPI of the window.
187    *
188    * @return The DPI of the window
189    */
190   Uint16Pair GetDpi() const;
191
192   /**
193    * @brief Sets the PostRenderCallback of the OffscreenWindow.
194    *
195    * @param[in] callback The PostRenderCallback function
196    * @code
197    *   void MyFunction( OffscreenWindow window, Any nativeSurface );
198    * @endcode
199    *
200    * @note Ownership of the callback is passed onto this class.
201    *
202    */
203   void SetPostRenderCallback(CallbackBase* callback);
204
205   /**
206    * @brief Sets a callback that is called when the frame rendering is done by the graphics driver.
207    *
208    * @param[in] callback The function to call
209    *
210    * @note A callback of the following type may be used:
211    * @code
212    *   void MyFunction();
213    * @endcode
214    *
215    * @note Ownership of the callback is passed onto this class.
216    */
217   void SetFrameRenderedCallback(CallbackBase* callback);
218
219 public: // Not intended for application developers
220   /**
221    * @brief Internal constructor
222    */
223   explicit DALI_INTERNAL OffscreenWindow(Internal::OffscreenWindow* window);
224 };
225
226 /**
227  * @}
228  */
229
230 } // namespace Dali
231
232 #endif // DALI_OFFSCREEN_WINDOW_H