Merge "Add OffscreenApplication" into 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) 2020 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 #include <dali/public-api/signals/dali-signal.h>
26
27 namespace Dali
28 {
29 /**
30  * @addtogroup dali_adaptor_framework
31  * @{
32  */
33
34 class Layer;
35
36 namespace Internal
37 {
38 class OffscreenWindow;
39 }
40
41 class DALI_IMPORT_API OffscreenWindow : public Dali::BaseHandle
42 {
43 public:
44   using WindowSize           = Uint16Pair;
45   using PostRenderSignalType = Signal<void(OffscreenWindow, Any)>;
46
47 public:
48   /**
49    * @brief Creates an initialized handle to a new OffscreenWindow
50    * @note You should hold the returned handle. If you missed the handle, the OffscreenWindow will be released
51    *
52    * @param[in] width The initial width of the OffscreenWindow
53    * @param[in] height The initial height of the OffscreenWindow
54    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
55    */
56   static OffscreenWindow New(uint16_t width, uint16_t height, bool isTranslucent);
57
58   /**
59    * @brief Creates an initialized handle to a new OffscreenWindow
60    * @note You should hold the returned handle. If you missed the handle, the OffscreenWindow will be released
61    *
62    * @param[in] surface The native surface handle of your platform
63    */
64   static OffscreenWindow New(Any surface);
65
66   /**
67    * @brief Constructs an empty handle
68    */
69   OffscreenWindow();
70
71   /**
72    * @brief Copy constructor
73    *
74    * @param [in] window A reference to the copied handle
75    */
76   OffscreenWindow(const OffscreenWindow& window);
77
78   /**
79    * @brief Assignment operator
80    *
81    * @param [in] window A reference to the copied handle
82    * @return A reference to this
83    */
84   OffscreenWindow& operator=(const OffscreenWindow& window);
85
86   /**
87    * @brief Destructor
88    */
89   ~OffscreenWindow();
90
91 public:
92   /**
93    * @brief Adds a child Actor to the OffscreenWindow.
94    *
95    * The child will be referenced.
96    *
97    * @param[in] actor The child
98    * @pre The actor has been initialized.
99    * @pre The actor does not have a parent.
100    */
101   void Add(Actor actor);
102
103   /**
104    * @brief Removes a child Actor from the OffscreenWindow.
105    *
106    * The child will be unreferenced.
107    *
108    * @param[in] actor The child
109    * @pre The actor has been added to the OffscreenWindow.
110    */
111   void Remove(Actor actor);
112
113   /**
114    * @brief Sets the background color of the OffscreenWindow.
115    *
116    * @param[in] color The new background color
117    */
118   void SetBackgroundColor(const Vector4& color);
119
120   /**
121    * @brief Gets the background color of the OffscreenWindow.
122    *
123    * @return The background color
124    */
125   Vector4 GetBackgroundColor() const;
126
127   /**
128    * @brief Returns the root Layer of the OffscreenWindow.
129    *
130    * @return The root layer
131    */
132   Layer GetRootLayer() const;
133
134   /**
135    * @brief Queries the number of on-scene layers.
136    *
137    * Note that a default layer is always provided (count >= 1).
138    *
139    * @return The number of layers
140    */
141   uint32_t GetLayerCount() const;
142
143   /**
144    * @brief Retrieves the layer at a specified depth in the OffscreenWindow.
145    *
146    * @param[in] depth The depth
147    * @return The layer found at the given depth
148    * @pre Depth is less than layer count; see GetLayerCount().
149    */
150   Layer GetLayer(uint32_t depth) const;
151
152   /**
153    * @brief Returns the size of the OffscreenWindow in pixels as a Vector.
154    *
155    * The x component will be the width of the OffscreenWindow in pixels.
156    * The y component will be the height of the OffscreenWindow in pixels.
157    *
158    * @return The size of the OffscreenWindow as a Vector
159    */
160   WindowSize GetSize() const;
161
162   /**
163    * @brief Gets the native handle.
164    * @note When users call this function, it wraps the actual type used by the underlying system.
165    * @return The native handle or an empty handle
166    */
167   Any GetNativeHandle() const;
168
169   /**
170    * @brief Retrieves the DPI of the window.
171    *
172    * @return The DPI of the window
173    */
174   Uint16Pair GetDpi() const;
175
176 public: // Signals
177   /**
178    * @brief This signal is emitted when the OffscreenWindow is rendered.
179    *
180    * @return The signal
181    */
182   PostRenderSignalType& PostRenderSignal();
183
184 public: // Not intended for application developers
185   /**
186    * @brief Internal constructor
187    */
188   explicit DALI_INTERNAL OffscreenWindow(Internal::OffscreenWindow* window);
189 };
190
191 /**
192  * @}
193  */
194
195 } // namespace Dali
196
197 #endif // DALI_OFFSCREEN_WINDOW_H