CanvasRenderer: Add Set/GetViewBox() API
[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) 2021 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
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_adaptor_framework
33  * @{
34  */
35
36 class Layer;
37
38 namespace Internal
39 {
40 class OffscreenWindow;
41 }
42
43 class DALI_ADAPTOR_API OffscreenWindow : public Dali::BaseHandle
44 {
45 public:
46   using WindowSize = Uint16Pair;
47
48 public:
49   /**
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
52    *
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
56    */
57   static OffscreenWindow New(uint16_t width, uint16_t height, bool isTranslucent);
58
59   /**
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
62    *
63    * @param[in] surface The native surface handle of your platform
64    */
65   static OffscreenWindow New(Any surface);
66
67   /**
68    * @brief Constructs an empty handle
69    */
70   OffscreenWindow();
71
72   /**
73    * @brief Copy constructor
74    *
75    * @param [in] window A reference to the copied handle
76    */
77   OffscreenWindow(const OffscreenWindow& window);
78
79   /**
80    * @brief Assignment operator
81    *
82    * @param [in] window A reference to the copied handle
83    * @return A reference to this
84    */
85   OffscreenWindow& operator=(const OffscreenWindow& window);
86
87   /**
88    * @brief Destructor
89    */
90   ~OffscreenWindow();
91
92 public:
93   /**
94    * @brief Adds a child Actor to the OffscreenWindow.
95    *
96    * The child will be referenced.
97    *
98    * @param[in] actor The child
99    * @pre The actor has been initialized.
100    * @pre The actor does not have a parent.
101    */
102   void Add(Actor actor);
103
104   /**
105    * @brief Removes a child Actor from the OffscreenWindow.
106    *
107    * The child will be unreferenced.
108    *
109    * @param[in] actor The child
110    * @pre The actor has been added to the OffscreenWindow.
111    */
112   void Remove(Actor actor);
113
114   /**
115    * @brief Sets the background color of the OffscreenWindow.
116    *
117    * @param[in] color The new background color
118    */
119   void SetBackgroundColor(const Vector4& color);
120
121   /**
122    * @brief Gets the background color of the OffscreenWindow.
123    *
124    * @return The background color
125    */
126   Vector4 GetBackgroundColor() const;
127
128   /**
129    * @brief Returns the root Layer of the OffscreenWindow.
130    *
131    * @return The root layer
132    */
133   Layer GetRootLayer() const;
134
135   /**
136    * @brief Queries the number of on-scene layers.
137    *
138    * Note that a default layer is always provided (count >= 1).
139    *
140    * @return The number of layers
141    */
142   uint32_t GetLayerCount() const;
143
144   /**
145    * @brief Retrieves the layer at a specified depth in the OffscreenWindow.
146    *
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().
150    */
151   Layer GetLayer(uint32_t depth) const;
152
153   /**
154    * @brief Returns the size of the OffscreenWindow in pixels as a Vector.
155    *
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.
158    *
159    * @return The size of the OffscreenWindow as a Vector
160    */
161   WindowSize GetSize() const;
162
163   /**
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
167    */
168   Any GetNativeHandle() const;
169
170   /**
171    * @brief Retrieves the DPI of the window.
172    *
173    * @return The DPI of the window
174    */
175   Uint16Pair GetDpi() const;
176
177   /**
178    * @brief Sets the PostRenderCallback of the OffscreenWindow.
179    *
180    * @param[in] callback The PostRenderCallback function
181    * @code
182    *   void MyFunction( OffscreenWindow window, Any nativeSurface );
183    * @endcode
184    *
185    * @note Ownership of the callback is passed onto this class.
186    *
187    */
188   void SetPostRenderCallback(CallbackBase* callback);
189
190 public: // Not intended for application developers
191   /**
192    * @brief Internal constructor
193    */
194   explicit DALI_INTERNAL OffscreenWindow(Internal::OffscreenWindow* window);
195 };
196
197 /**
198  * @}
199  */
200
201 } // namespace Dali
202
203 #endif // DALI_OFFSCREEN_WINDOW_H