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