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>
39 * Implementation of the OffscreenApplication class.
41 class OffscreenApplication : public BaseObject, public Adaptor::Framework::Observer, public Adaptor::Framework::TaskObserver
44 using OffscreenApplicationSignalType = Dali::OffscreenApplication::OffscreenApplicationSignalType;
47 * @brief Create a new OffscreenApplication
48 * @param[in] width The width of the default OffscreenWindow
49 * @param[in] height The height of the default OffscreenWindow
50 * @param[in] surface The native surface handle to create the default OffscreenWindow
51 * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
52 * @param[in] renderMode The RenderMode of the OffscreenApplication
54 static IntrusivePtr<OffscreenApplication> New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
60 virtual ~OffscreenApplication();
63 * @copydoc Dali::OffscreenApplication::MainLoop()
68 * @copydoc Dali::OffscreenApplication::Quit()
73 * @copydoc Dali::OffscreenApplication::GetDefaultWindow()
75 Dali::OffscreenWindow GetWindow();
78 * @copydoc Dali::OffscreenApplication::RenderOnce()
84 * @copydoc Dali::OffscreenApplication::InitSignal()
86 OffscreenApplicationSignalType& InitSignal()
92 * @copydoc Dali::OffscreenApplication::TerminateSignal()
94 OffscreenApplicationSignalType& TerminateSignal()
96 return mTerminateSignal;
99 public: // From Framework::Observer
101 * Called when the framework is initialised.
103 void OnInit() override;
106 * Called when the framework is terminated.
108 void OnTerminate() override;
112 * Private constructor
113 * @param[in] width The width of the OffscreenWindow
114 * @param[in] height The height of the OffscreenApplication
115 * @param[in] surface The native surface handle to create the default OffscreenWindow
116 * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
117 * @param[in] renderMode The RenderMode of the OffscreenApplication
119 OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
122 * Quits from the main loop
124 void QuitFromMainLoop();
127 OffscreenApplication(const OffscreenApplication&) = delete;
128 OffscreenApplication& operator=(OffscreenApplication&) = delete;
129 OffscreenApplication& operator=(const OffscreenApplication&) = delete;
130 OffscreenApplication& operator=(OffscreenApplication&&) = delete;
133 std::unique_ptr<Dali::Adaptor> mAdaptor;
134 Dali::OffscreenWindow mDefaultWindow;
136 std::unique_ptr<Internal::Adaptor::Framework> mFramework;
138 OffscreenApplicationSignalType mInitSignal;
139 OffscreenApplicationSignalType mTerminateSignal;
142 inline OffscreenApplication& GetImplementation(Dali::OffscreenApplication& offscreenApplication)
144 DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
146 BaseObject& handle = offscreenApplication.GetBaseObject();
148 return static_cast<OffscreenApplication&>(handle);
151 inline const OffscreenApplication& GetImplementation(const Dali::OffscreenApplication& offscreenApplication)
153 DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
155 const BaseObject& handle = offscreenApplication.GetBaseObject();
157 return static_cast<const OffscreenApplication&>(handle);
160 } // namespace Internal
164 #endif // DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H