[dali_2.3.24] Merge branch 'devel/master'
[platform/core/uifw/dali-adaptor.git] / dali / devel-api / adaptor-framework / offscreen-application.h
1 #ifndef DALI_OFFSCREEN_APPLICATION_H
2 #define DALI_OFFSCREEN_APPLICATION_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/object/any.h>
23 #include <dali/public-api/object/base-handle.h>
24 #include <dali/public-api/signals/dali-signal.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28
29 namespace Dali
30 {
31 /**
32  * @addtogroup dali_adaptor_framework
33  * @{
34  */
35
36 class OffscreenWindow;
37
38 namespace Internal
39 {
40 class OffscreenApplication;
41 }
42
43 /**
44  * @brief Appliations can draw UI on offscreen surface with the OffscreenApplication.
45  * When you use a OffscreenApplication, you don't have to create a Window.
46  */
47 class DALI_ADAPTOR_API OffscreenApplication : public Dali::BaseHandle
48 {
49 public:
50   using OffscreenApplicationSignalType = Signal<void(void)>;
51
52   /**
53    * @brief Enumeration for the render mode
54    */
55   enum class RenderMode
56   {
57     AUTO,  // Scene is rendered automatically
58     MANUAL // Scene is rendered by RenderOnce()
59   };
60
61 public:
62   /**
63    * @brief This is the constructor of OffscreenApplication
64    *
65    * @param[in] width The initial width of the default OffscreenWindow
66    * @param[in] height The initial height of the default OffscreenWindow
67    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
68    * @param[in] renderMode The RenderMode of the OffscreenApplication
69    */
70   static OffscreenApplication New(uint16_t width, uint16_t height, bool isTranslucent, RenderMode renderMode = RenderMode::AUTO);
71
72   /**
73    * @brief This is the constructor of OffscreenApplication
74    *
75    * @param[in] surface The native surface handle to create the OffscreenWindow
76    * @param[in] renderMode The RenderMode of the OffscreenApplication
77    */
78   static OffscreenApplication New(Dali::Any surface, RenderMode renderMode = RenderMode::AUTO);
79
80   /**
81    * @brief Constructs an empty handle
82    */
83   OffscreenApplication();
84
85   /**
86    * @brief Copy constructor
87    *
88    * @param [in] offscreenApplication A reference to the copied handle
89    */
90   OffscreenApplication(const OffscreenApplication& offscreenApplication);
91
92   /**
93    * @brief Assignment operator
94    *
95    * @param [in] offscreenApplication A reference to the copied handle
96    * @return A reference to this
97    */
98   OffscreenApplication& operator=(const OffscreenApplication& offscreenApplication);
99
100   /**
101    * @brief Destructor
102    */
103   ~OffscreenApplication();
104
105 public:
106   /**
107    * @brief This starts the application.
108    */
109   void MainLoop();
110
111   /**
112    * @brief This quits the application.
113    */
114   void Quit();
115
116   /**
117    * @brief Get the default OffscreenWindow handle
118    * @return The default OffscreenWindow
119    */
120   OffscreenWindow GetWindow();
121
122   /**
123    * @brief Renders once more even if we're paused
124    */
125   void RenderOnce();
126
127   /**
128    * @brief Gets the context of the framwork
129    * @return Platform dependent context handle
130    */
131   Any GetFrameworkContext() const;
132
133 public: // Signals
134   /**
135    * @brief Signal to notify the client when the application is ready to be initialized
136    *
137    * @note OffscreenApplication::Start() should be called to be initialized
138    *
139    * @return The signal
140    */
141   OffscreenApplicationSignalType& InitSignal();
142
143   /**
144    * @brief Signal to notify the user when the application is about to be terminated
145    *
146    * @return The signal
147    */
148   OffscreenApplicationSignalType& TerminateSignal();
149
150   /**
151    * @brief Signal to notify the user when the application is about to be paused
152    *
153    * @return The signal
154    */
155   OffscreenApplicationSignalType& PauseSignal();
156
157   /**
158    * @brief Signal to notify the user when the application is about to be resumed
159    *
160    * @return The signal
161    */
162   OffscreenApplicationSignalType& ResumeSignal();
163
164   /**
165    * @brief Signal to notify the user when the application is about to be reinitialized
166    *
167    * @return The signal
168    */
169   OffscreenApplicationSignalType& ResetSignal();
170
171   /**
172    * @brief Signal to notify the user when the application is about to be language is changed on the device.
173    *
174    * @return The signal
175    */
176   OffscreenApplicationSignalType& LanguageChangedSignal();
177
178 public: // Not intended for application developers
179   /**
180    * @brief Internal constructor
181    */
182   explicit DALI_INTERNAL OffscreenApplication(Internal::OffscreenApplication* offscreenApplication);
183 };
184
185 /**
186  * @}
187  */
188
189 } // namespace Dali
190
191 #endif // DALI_OFFSCREEN_APPLICATION_H