1 #ifndef DALI_OFFSCREEN_WINDOW_H
2 #define DALI_OFFSCREEN_WINDOW_H
5 * Copyright (c) 2021 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);
94 * @brief Adds a child Actor to the OffscreenWindow.
96 * The child will be referenced.
98 * @param[in] actor The child
99 * @pre The actor has been initialized.
100 * @pre The actor does not have a parent.
102 void Add(Actor actor);
105 * @brief Removes a child Actor from the OffscreenWindow.
107 * The child will be unreferenced.
109 * @param[in] actor The child
110 * @pre The actor has been added to the OffscreenWindow.
112 void Remove(Actor actor);
115 * @brief Sets the background color of the OffscreenWindow.
117 * @param[in] color The new background color
119 void SetBackgroundColor(const Vector4& color);
122 * @brief Gets the background color of the OffscreenWindow.
124 * @return The background color
126 Vector4 GetBackgroundColor() const;
129 * @brief Returns the root Layer of the OffscreenWindow.
131 * @return The root layer
133 Layer GetRootLayer() const;
136 * @brief Queries the number of on-scene layers.
138 * Note that a default layer is always provided (count >= 1).
140 * @return The number of layers
142 uint32_t GetLayerCount() const;
145 * @brief Retrieves the layer at a specified depth in the OffscreenWindow.
147 * @param[in] depth The depth
148 * @return The layer found at the given depth
149 * @pre Depth is less than layer count; see GetLayerCount().
151 Layer GetLayer(uint32_t depth) const;
154 * @brief Returns the size of the OffscreenWindow in pixels as a Vector.
156 * The x component will be the width of the OffscreenWindow in pixels.
157 * The y component will be the height of the OffscreenWindow in pixels.
159 * @return The size of the OffscreenWindow as a Vector
161 WindowSize GetSize() const;
164 * @brief Gets the native handle.
165 * @note When users call this function, it wraps the actual type used by the underlying system.
166 * @return The native handle or an empty handle
168 Any GetNativeHandle() const;
171 * @brief Retrieves the DPI of the window.
173 * @return The DPI of the window
175 Uint16Pair GetDpi() const;
178 * @brief Sets the PostRenderCallback of the OffscreenWindow.
180 * @param[in] callback The PostRenderCallback function
182 * void MyFunction( OffscreenWindow window, Any nativeSurface );
185 * @note Ownership of the callback is passed onto this class.
188 void SetPostRenderCallback(CallbackBase* callback);
190 public: // Not intended for application developers
192 * @brief Internal constructor
194 explicit DALI_INTERNAL OffscreenWindow(Internal::OffscreenWindow* window);
203 #endif // DALI_OFFSCREEN_WINDOW_H