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