Revert "[Tizen] Add GetFrameworkContext to OffscreenApplication"
[platform/core/uifw/dali-adaptor.git] / dali / internal / offscreen / common / offscreen-application-impl.h
1 #ifndef DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H
2 #define DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H
3
4 /*
5  * Copyright (c) 2023 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 // EXTERNAL INCLUDES
22 #include <dali/public-api/common/intrusive-ptr.h>
23 #include <dali/public-api/object/base-object.h>
24 #include <memory>
25
26 // INTERNAL INCLUDES
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>
31
32 namespace Dali
33 {
34 class Adaptor;
35
36 namespace Internal
37 {
38 /**
39  * Implementation of the OffscreenApplication class.
40  */
41 class OffscreenApplication : public BaseObject, public Adaptor::Framework::Observer, public Adaptor::Framework::TaskObserver
42 {
43 public:
44   using OffscreenApplicationSignalType = Dali::OffscreenApplication::OffscreenApplicationSignalType;
45
46   /**
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
53    */
54   static IntrusivePtr<OffscreenApplication> New(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
55
56 public:
57   /**
58    * Destructor
59    */
60   virtual ~OffscreenApplication();
61
62   /**
63    * @copydoc Dali::OffscreenApplication::MainLoop()
64    */
65   void MainLoop();
66
67   /**
68    * @copydoc Dali::OffscreenApplication::Quit()
69    */
70   void Quit();
71
72   /**
73    * @copydoc Dali::OffscreenApplication::GetDefaultWindow()
74    */
75   Dali::OffscreenWindow GetWindow();
76
77   /**
78    * @copydoc Dali::OffscreenApplication::RenderOnce()
79    */
80   void RenderOnce();
81
82 public: // Signals
83   /**
84    * @copydoc Dali::OffscreenApplication::InitSignal()
85    */
86   OffscreenApplicationSignalType& InitSignal()
87   {
88     return mInitSignal;
89   }
90
91   /**
92    * @copydoc Dali::OffscreenApplication::TerminateSignal()
93    */
94   OffscreenApplicationSignalType& TerminateSignal()
95   {
96     return mTerminateSignal;
97   }
98
99 public: // From Framework::Observer
100   /**
101    * Called when the framework is initialised.
102    */
103   void OnInit() override;
104
105   /**
106    * Called when the framework is terminated.
107    */
108   void OnTerminate() override;
109
110 private:
111   /**
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
118    */
119   OffscreenApplication(uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent, Dali::OffscreenApplication::RenderMode renderMode);
120
121   /**
122    * Quits from the main loop
123    */
124   void QuitFromMainLoop();
125
126   // Undefined
127   OffscreenApplication(const OffscreenApplication&) = delete;
128   OffscreenApplication& operator=(OffscreenApplication&) = delete;
129   OffscreenApplication& operator=(const OffscreenApplication&) = delete;
130   OffscreenApplication& operator=(OffscreenApplication&&) = delete;
131
132 private:
133   std::unique_ptr<Dali::Adaptor> mAdaptor;
134   Dali::OffscreenWindow          mDefaultWindow;
135
136   std::unique_ptr<Internal::Adaptor::Framework> mFramework;
137
138   OffscreenApplicationSignalType mInitSignal;
139   OffscreenApplicationSignalType mTerminateSignal;
140 };
141
142 inline OffscreenApplication& GetImplementation(Dali::OffscreenApplication& offscreenApplication)
143 {
144   DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
145
146   BaseObject& handle = offscreenApplication.GetBaseObject();
147
148   return static_cast<OffscreenApplication&>(handle);
149 }
150
151 inline const OffscreenApplication& GetImplementation(const Dali::OffscreenApplication& offscreenApplication)
152 {
153   DALI_ASSERT_ALWAYS(offscreenApplication && "OffscreenApplication handle is empty");
154
155   const BaseObject& handle = offscreenApplication.GetBaseObject();
156
157   return static_cast<const OffscreenApplication&>(handle);
158 }
159
160 } // namespace Internal
161
162 } // namespace Dali
163
164 #endif // DALI_INTERNAL_OFFSCREEN_APPLICATION_IMPL_H