1 #ifndef DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H
2 #define DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H
5 * Copyright (c) 2023 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/base-object.h>
27 #include <dali/devel-api/adaptor-framework/offscreen-application.h>
28 #include <dali/devel-api/adaptor-framework/offscreen-window.h>
29 #include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
30 #include <dali/internal/adaptor/common/framework.h>
40 class FrameworkFactory;
41 } // namespace Adaptor
44 * Implementation of the OffscreenApplication class.
46 class OffscreenApplication : public BaseObject, public Adaptor::Framework::Observer, public Adaptor::Framework::TaskObserver
49 using OffscreenApplicationSignalType = Dali::OffscreenApplication::OffscreenApplicationSignalType;
52 * @brief Create a new OffscreenApplication
53 * @param[in] width The width of the default OffscreenWindow
54 * @param[in] height The height of the default OffscreenWindow
55 * @param[in] surface The native surface handle to create the default OffscreenWindow
56 * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
57 * @param[in] renderMode The RenderMode of the OffscreenApplication
59 static IntrusivePtr<OffscreenApplication> New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
65 virtual ~OffscreenApplication();
68 * @copydoc Dali::OffscreenApplication::MainLoop()
73 * @copydoc Dali::OffscreenApplication::Quit()
78 * @copydoc Dali::OffscreenApplication::GetDefaultWindow()
80 Dali::OffscreenWindow GetWindow();
83 * @copydoc Dali::OffscreenApplication::RenderOnce()
88 * @copydoc Dali::OffscreenApplication::GetFrameworkContext()
90 Any GetFrameworkContext() const;
94 * @copydoc Dali::OffscreenApplication::InitSignal()
96 OffscreenApplicationSignalType& InitSignal()
102 * @copydoc Dali::OffscreenApplication::TerminateSignal()
104 OffscreenApplicationSignalType& TerminateSignal()
106 return mTerminateSignal;
110 * @copydoc Dali::OffscreenApplication::PauseSignal()
112 OffscreenApplicationSignalType& PauseSignal()
118 * @copydoc Dali::OffscreenApplication::ResumeSignal()
120 OffscreenApplicationSignalType& ResumeSignal()
122 return mResumeSignal;
126 * @copydoc Dali::OffscreenApplication::ResetSignal()
128 OffscreenApplicationSignalType& ResetSignal()
134 * @copydoc Dali::OffscreenApplication::LanguageChangedSignal()
136 OffscreenApplicationSignalType& LanguageChangedSignal()
138 return mLanguageChangedSignal;
141 public: // From Framework::Observer
143 * Called when the framework is initialised.
145 void OnInit() override;
148 * Called when the framework is terminated.
150 void OnTerminate() override;
153 * Called when the framework is paused.
155 void OnPause() override;
158 * Called when the framework resumes from a paused state.
160 void OnResume() override;
163 * Called when the framework informs the application that it should reset itself.
165 void OnReset() override;
168 * Called when the framework informs the application that the language of the device has changed.
170 void OnLanguageChanged() override;
174 * Private constructor
175 * @param[in] width The width of the OffscreenWindow
176 * @param[in] height The height of the OffscreenApplication
177 * @param[in] surface The native surface handle to create the default OffscreenWindow
178 * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
179 * @param[in] renderMode The RenderMode of the OffscreenApplication
181 OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
184 * Quits from the main loop
186 void QuitFromMainLoop();
189 OffscreenApplication(const OffscreenApplication&) = delete;
190 OffscreenApplication& operator=(OffscreenApplication&) = delete;
191 OffscreenApplication& operator=(const OffscreenApplication&) = delete;
192 OffscreenApplication& operator=(OffscreenApplication&&) = delete;
195 std::unique_ptr<Dali::Adaptor> mAdaptor;
196 Dali::OffscreenWindow mDefaultWindow;
198 std::unique_ptr<Internal::Adaptor::Framework> mFramework;
199 std::unique_ptr<Internal::Adaptor::FrameworkFactory> mFrameworkFactory;
201 OffscreenApplicationSignalType mInitSignal;
202 OffscreenApplicationSignalType mTerminateSignal;
203 OffscreenApplicationSignalType mPauseSignal;
204 OffscreenApplicationSignalType mResumeSignal;
205 OffscreenApplicationSignalType mResetSignal;
206 OffscreenApplicationSignalType mLanguageChangedSignal;
209 inline OffscreenApplication& GetImplementation(Dali::OffscreenApplication& offscreenApplication)
211 DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
213 BaseObject& handle = offscreenApplication.GetBaseObject();
215 return static_cast<OffscreenApplication&>(handle);
218 inline const OffscreenApplication& GetImplementation(const Dali::OffscreenApplication& offscreenApplication)
220 DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
222 const BaseObject& handle = offscreenApplication.GetBaseObject();
224 return static_cast<const OffscreenApplication&>(handle);
227 } // namespace Internal
231 #endif // DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H