1 #ifndef DALI_OFFSCREEN_WINDOW_H
2 #define DALI_OFFSCREEN_WINDOW_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
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>
27 #include <dali/public-api/dali-adaptor-common.h>
32 * @addtogroup dali_adaptor_framework
40 class OffscreenWindow;
43 class DALI_ADAPTOR_API OffscreenWindow : public Dali::BaseHandle
46 using WindowSize = Uint16Pair;
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
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
57 static OffscreenWindow New(uint16_t width, uint16_t height, bool isTranslucent);
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
63 * @param[in] surface The native surface handle of your platform
65 static OffscreenWindow New(Any surface);
68 * @brief Constructs an empty handle
73 * @brief Copy constructor
75 * @param [in] window A reference to the copied handle
77 OffscreenWindow(const OffscreenWindow& window);
80 * @brief Assignment operator
82 * @param [in] window A reference to the copied handle
83 * @return A reference to this
85 OffscreenWindow& operator=(const OffscreenWindow& window);
88 * @brief Move constructor
90 * @param [in] window A reference to the moved handle
92 OffscreenWindow(OffscreenWindow&& window);
95 * @brief Move assignment operator
97 * @param [in] window A reference to the moved handle
98 * @return A reference to this
100 OffscreenWindow& operator=(OffscreenWindow&& window);
109 * @brief Adds a child Actor to the OffscreenWindow.
111 * The child will be referenced.
113 * @param[in] actor The child
114 * @pre The actor has been initialized.
115 * @pre The actor does not have a parent.
117 void Add(Actor actor);
120 * @brief Removes a child Actor from the OffscreenWindow.
122 * The child will be unreferenced.
124 * @param[in] actor The child
125 * @pre The actor has been added to the OffscreenWindow.
127 void Remove(Actor actor);
130 * @brief Sets the background color of the OffscreenWindow.
132 * @param[in] color The new background color
134 void SetBackgroundColor(const Vector4& color);
137 * @brief Gets the background color of the OffscreenWindow.
139 * @return The background color
141 Vector4 GetBackgroundColor() const;
144 * @brief Returns the root Layer of the OffscreenWindow.
146 * @return The root layer
148 Layer GetRootLayer() const;
151 * @brief Queries the number of on-scene layers.
153 * Note that a default layer is always provided (count >= 1).
155 * @return The number of layers
157 uint32_t GetLayerCount() const;
160 * @brief Retrieves the layer at a specified depth in the OffscreenWindow.
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().
166 Layer GetLayer(uint32_t depth) const;
169 * @brief Returns the size of the OffscreenWindow in pixels as a Vector.
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.
174 * @return The size of the OffscreenWindow as a Vector
176 WindowSize GetSize() const;
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
183 Any GetNativeHandle() const;
186 * @brief Retrieves the DPI of the window.
188 * @return The DPI of the window
190 Uint16Pair GetDpi() const;
193 * @brief Sets the PostRenderCallback of the OffscreenWindow.
195 * @param[in] callback The PostRenderCallback function
197 * void MyFunction( OffscreenWindow window, Any nativeSurface );
200 * @note Ownership of the callback is passed onto this class.
203 void SetPostRenderCallback(CallbackBase* callback);
206 * @brief Sets a callback that is called when the frame rendering is done by the graphics driver.
208 * @param[in] callback The function to call
210 * @note A callback of the following type may be used:
215 * @note Ownership of the callback is passed onto this class.
217 void SetFrameRenderedCallback(CallbackBase* callback);
219 public: // Not intended for application developers
221 * @brief Internal constructor
223 explicit DALI_INTERNAL OffscreenWindow(Internal::OffscreenWindow* window);
232 #endif // DALI_OFFSCREEN_WINDOW_H