Add front buffer rendering APIs in Dali::Window
[platform/core/uifw/dali-adaptor.git] / dali / public-api / adaptor-framework / application.cpp
1 /*
2  * Copyright (c) 2023 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *
16  */
17
18 // CLASS HEADER
19 #include <dali/public-api/adaptor-framework/application.h>
20
21 // EXTERNAL INCLUDES
22 #include <dali/integration-api/debug.h>
23 #include <dali/public-api/object/object-registry.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/internal/adaptor/common/application-impl.h>
27
28 namespace Dali
29 {
30 Application Application::New()
31 {
32   return New(NULL, NULL);
33 }
34
35 Application Application::New(int* argc, char** argv[])
36 {
37   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
38   if(internal)
39   {
40     // pre-initialized application
41     internal->SetCommandLineOptions(argc, argv);
42   }
43   else
44   {
45     WindowData windowData;
46     windowData.SetTransparency(false);
47
48     internal = Internal::Adaptor::Application::New(argc, argv, "", Internal::Adaptor::Framework::NORMAL, false, windowData);
49   }
50   return Application(internal.Get());
51 }
52
53 Application Application::New(int* argc, char** argv[], const std::string& stylesheet)
54 {
55   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
56   if(internal)
57   {
58     // pre-initialized application
59     internal->SetCommandLineOptions(argc, argv);
60     internal->SetStyleSheet(stylesheet);
61   }
62   else
63   {
64     WindowData windowData;
65     windowData.SetTransparency(false);
66
67     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, Internal::Adaptor::Framework::NORMAL, false, windowData);
68   }
69   return Application(internal.Get());
70 }
71
72 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, WINDOW_MODE windowMode)
73 {
74   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
75   if(internal)
76   {
77     // pre-initialized application
78     internal->SetCommandLineOptions(argc, argv);
79     internal->SetStyleSheet(stylesheet);
80
81     internal->GetWindow().SetTransparency((windowMode == Application::TRANSPARENT));
82   }
83   else
84   {
85     WindowData windowData;
86     windowData.SetTransparency(windowMode == Application::TRANSPARENT);
87
88     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, Internal::Adaptor::Framework::NORMAL, false, windowData);
89   }
90   return Application(internal.Get());
91 }
92
93 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize)
94 {
95   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
96   if(internal)
97   {
98     // pre-initialized application
99     internal->SetCommandLineOptions(argc, argv);
100     internal->SetStyleSheet(stylesheet);
101
102     internal->GetWindow().SetTransparency(windowMode == Application::TRANSPARENT);
103
104     // Store only the value before adaptor is created
105     internal->StoreWindowPositionSize(positionSize);
106   }
107   else
108   {
109     WindowData windowData;
110     windowData.SetPositionSize(positionSize);
111     windowData.SetTransparency(windowMode == Application::TRANSPARENT);
112
113     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, Internal::Adaptor::Framework::NORMAL, false, windowData);
114   }
115   return Application(internal.Get());
116 }
117
118 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, Application::WINDOW_MODE windowMode, PositionSize positionSize, bool useUiThread)
119 {
120   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
121   if(internal)
122   {
123     // pre-initialized application
124     internal->SetCommandLineOptions(argc, argv);
125     internal->SetStyleSheet(stylesheet);
126
127     internal->GetWindow().SetTransparency(windowMode == Application::TRANSPARENT);
128
129     // Store only the value before adaptor is created
130     internal->StoreWindowPositionSize(positionSize);
131   }
132   else
133   {
134     WindowData windowData;
135     windowData.SetPositionSize(positionSize);
136     windowData.SetTransparency(windowMode == Application::TRANSPARENT);
137
138     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, Internal::Adaptor::Framework::NORMAL, useUiThread, windowData);
139   }
140   return Application(internal.Get());
141 }
142
143 Application Application::New(int* argc, char** argv[], const std::string& stylesheet, bool useUiThread, WindowData& windowData)
144 {
145   Internal::Adaptor::ApplicationPtr internal = Internal::Adaptor::Application::GetPreInitializedApplication();
146   if(internal)
147   {
148     // pre-initialized application
149     internal->SetCommandLineOptions(argc, argv);
150     internal->SetStyleSheet(stylesheet);
151
152     // Set defaut Window type
153     internal->SetDefaultWindowType(windowData.GetWindowType());
154     internal->GetWindow().SetTransparency(windowData.GetTransparency());
155
156     // Store only the value before adaptor is created
157     internal->StoreWindowPositionSize(windowData.GetPositionSize());
158
159     // Set front buffer rendering
160     internal->StoreFrontBufferRendering(windowData.GetFrontBufferRendering());
161   }
162   else
163   {
164     internal = Internal::Adaptor::Application::New(argc, argv, stylesheet, Internal::Adaptor::Framework::NORMAL, useUiThread, windowData);
165   }
166   return Application(internal.Get());
167 }
168
169 Application::~Application()
170 {
171 }
172
173 Application::Application()
174 {
175 }
176
177 Application::Application(const Application& copy) = default;
178
179 Application& Application::operator=(const Application& rhs) = default;
180
181 Application::Application(Application&& rhs) noexcept = default;
182
183 Application& Application::operator=(Application&& rhs) noexcept = default;
184
185 void Application::MainLoop()
186 {
187   Internal::Adaptor::GetImplementation(*this).MainLoop();
188 }
189
190 void Application::Lower()
191 {
192   Internal::Adaptor::GetImplementation(*this).Lower();
193 }
194
195 void Application::Quit()
196 {
197   Internal::Adaptor::GetImplementation(*this).Quit();
198 }
199
200 bool Application::AddIdle(CallbackBase* callback)
201 {
202   return Internal::Adaptor::GetImplementation(*this).AddIdle(callback, false);
203 }
204
205 Window Application::GetWindow()
206 {
207   return Internal::Adaptor::GetImplementation(*this).GetWindow();
208 }
209
210 std::string Application::GetResourcePath()
211 {
212   return Internal::Adaptor::Application::GetResourcePath();
213 }
214
215 std::string Application::GetRegion() const
216 {
217   return Internal::Adaptor::GetImplementation(*this).GetRegion();
218 }
219
220 std::string Application::GetLanguage() const
221 {
222   return Internal::Adaptor::GetImplementation(*this).GetLanguage();
223 }
224
225 ObjectRegistry Application::GetObjectRegistry() const
226 {
227   return Internal::Adaptor::GetImplementation(*this).GetObjectRegistry();
228 }
229
230 Application::AppSignalType& Application::InitSignal()
231 {
232   return Internal::Adaptor::GetImplementation(*this).InitSignal();
233 }
234
235 Application::AppSignalType& Application::TerminateSignal()
236 {
237   return Internal::Adaptor::GetImplementation(*this).TerminateSignal();
238 }
239
240 Application::AppSignalType& Application::PauseSignal()
241 {
242   return Internal::Adaptor::GetImplementation(*this).PauseSignal();
243 }
244
245 Application::AppSignalType& Application::ResumeSignal()
246 {
247   return Internal::Adaptor::GetImplementation(*this).ResumeSignal();
248 }
249
250 Application::AppSignalType& Application::ResetSignal()
251 {
252   return Internal::Adaptor::GetImplementation(*this).ResetSignal();
253 }
254
255 Application::AppControlSignalType& Application::AppControlSignal()
256 {
257   return Internal::Adaptor::GetImplementation(*this).AppControlSignal();
258 }
259
260 Application::AppSignalType& Application::LanguageChangedSignal()
261 {
262   return Internal::Adaptor::GetImplementation(*this).LanguageChangedSignal();
263 }
264
265 Application::AppSignalType& Application::RegionChangedSignal()
266 {
267   return Internal::Adaptor::GetImplementation(*this).RegionChangedSignal();
268 }
269
270 Application::LowBatterySignalType& Application::LowBatterySignal()
271 {
272   return Internal::Adaptor::GetImplementation(*this).LowBatterySignal();
273 }
274
275 Application::LowMemorySignalType& Application::LowMemorySignal()
276 {
277   return Internal::Adaptor::GetImplementation(*this).LowMemorySignal();
278 }
279
280 Application::DeviceOrientationChangedSignalType& Application::DeviceOrientationChangedSignal()
281 {
282   return Internal::Adaptor::GetImplementation(*this).DeviceOrientationChangedSignal();
283 }
284
285 Application::AppSignalType& Application::TaskInitSignal()
286 {
287   return Internal::Adaptor::GetImplementation(*this).TaskInitSignal();
288 }
289
290 Application::AppSignalType& Application::TaskTerminateSignal()
291 {
292   return Internal::Adaptor::GetImplementation(*this).TaskTerminateSignal();
293 }
294
295 Application::AppControlSignalType& Application::TaskAppControlSignal()
296 {
297   return Internal::Adaptor::GetImplementation(*this).TaskAppControlSignal();
298 }
299
300 Application::AppSignalType& Application::TaskLanguageChangedSignal()
301 {
302   return Internal::Adaptor::GetImplementation(*this).TaskLanguageChangedSignal();
303 }
304
305 Application::AppSignalType& Application::TaskRegionChangedSignal()
306 {
307   return Internal::Adaptor::GetImplementation(*this).TaskRegionChangedSignal();
308 }
309
310 Application::LowBatterySignalType& Application::TaskLowBatterySignal()
311 {
312   return Internal::Adaptor::GetImplementation(*this).TaskLowBatterySignal();
313 }
314
315 Application::LowMemorySignalType& Application::TaskLowMemorySignal()
316 {
317   return Internal::Adaptor::GetImplementation(*this).TaskLowMemorySignal();
318 }
319
320 Application::DeviceOrientationChangedSignalType& Application::TaskDeviceOrientationChangedSignal()
321 {
322   return Internal::Adaptor::GetImplementation(*this).TaskDeviceOrientationChangedSignal();
323 }
324
325 Application::Application(Internal::Adaptor::Application* application)
326 : BaseHandle(application)
327 {
328 }
329
330 } // namespace Dali