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