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;
109 public: // From Framework::Observer
111 * Called when the framework is initialised.
113 void OnInit() override;
116 * Called when the framework is terminated.
118 void OnTerminate() override;
122 * Private constructor
123 * @param[in] width The width of the OffscreenWindow
124 * @param[in] height The height of the OffscreenApplication
125 * @param[in] surface The native surface handle to create the default OffscreenWindow
126 * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
127 * @param[in] renderMode The RenderMode of the OffscreenApplication
129 OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
132 * Quits from the main loop
134 void QuitFromMainLoop();
137 OffscreenApplication(const OffscreenApplication&) = delete;
138 OffscreenApplication& operator=(OffscreenApplication&) = delete;
139 OffscreenApplication& operator=(const OffscreenApplication&) = delete;
140 OffscreenApplication& operator=(OffscreenApplication&&) = delete;
143 std::unique_ptr<Dali::Adaptor> mAdaptor;
144 Dali::OffscreenWindow mDefaultWindow;
146 std::unique_ptr<Internal::Adaptor::Framework> mFramework;
147 std::unique_ptr<Internal::Adaptor::FrameworkFactory> mFrameworkFactory;
149 OffscreenApplicationSignalType mInitSignal;
150 OffscreenApplicationSignalType mTerminateSignal;
153 inline OffscreenApplication& GetImplementation(Dali::OffscreenApplication& offscreenApplication)
155 DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
157 BaseObject& handle = offscreenApplication.GetBaseObject();
159 return static_cast<OffscreenApplication&>(handle);
162 inline const OffscreenApplication& GetImplementation(const Dali::OffscreenApplication& offscreenApplication)
164 DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
166 const BaseObject& handle = offscreenApplication.GetBaseObject();
168 return static_cast<const OffscreenApplication&>(handle);
171 } // namespace Internal
175 #endif // DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H