[Tizen] Sync for libds
[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) 2020 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/signals/dali-signal.h>
23 #include <dali/public-api/object/any.h>
24 #include <dali/public-api/object/base-handle.h>
25
26 namespace Dali
27 {
28
29 /**
30  * @addtogroup dali_adaptor_framework
31  * @{
32  */
33
34 class OffscreenWindow;
35
36 namespace Internal
37 {
38 class OffscreenApplication;
39 }
40
41 /**
42  * @brief Appliations can draw UI on offscreen surface with the OffscreenApplication.
43  * When you use a OffscreenApplication, you don't have to create a Window.
44  */
45 class DALI_IMPORT_API OffscreenApplication : public Dali::BaseHandle
46 {
47
48 public:
49
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   /**
64    * @brief This is the constructor of OffscreenApplication
65    *
66    * @param[in] width The initial width of the default OffscreenWindow
67    * @param[in] height The initial height of the default OffscreenWindow
68    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
69    * @param[in] renderMode The RenderMode of the OffscreenApplication
70    */
71   static OffscreenApplication New( uint16_t width, uint16_t height, bool isTranslucent,
72                                    RenderMode renderMode = RenderMode::AUTO );
73
74   /**
75    * @brief This is the constructor of OffscreenApplication
76    *
77    * @param[in] surface The native surface handle to create the OffscreenWindow
78    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
79    * @param[in] renderMode The RenderMode of the OffscreenApplication
80    */
81   static OffscreenApplication New( Dali::Any surface, bool isTranslucent, RenderMode renderMode = RenderMode::AUTO );
82
83   /**
84    * @brief Constructs an empty handle
85    */
86   OffscreenApplication();
87
88   /**
89    * @brief Copy constructor
90    *
91    * @param [in] offscreenApplication A reference to the copied handle
92    */
93   OffscreenApplication( const OffscreenApplication& offscreenApplication );
94
95   /**
96    * @brief Assignment operator
97    *
98    * @param [in] offscreenApplication A reference to the copied handle
99    * @return A reference to this
100    */
101   OffscreenApplication& operator=( const OffscreenApplication& offscreenApplication );
102
103   /**
104    * @brief Destructor
105    */
106   ~OffscreenApplication();
107
108 public:
109
110   /**
111    * @brief Starts the OffscreenApplication (rendering, event handling, etc)
112    */
113   void Start();
114
115   /**
116    * @brief Stops the OffscreenApplication
117    */
118   void Stop();
119
120
121   /**
122    * @brief Get the default OffscreenWindow handle
123    * @return The default OffscreenWindow
124    */
125   OffscreenWindow GetWindow();
126
127   /**
128    * @brief Renders once more even if we're paused
129    */
130   void RenderOnce();
131
132 public:  // Signals
133
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 public: // Not intended for application developers
151   /**
152    * @brief Internal constructor
153    */
154   explicit DALI_INTERNAL OffscreenApplication( Internal::OffscreenApplication* offscreenApplication );
155
156 };
157
158 /**
159  * @}
160  */
161
162 }  // namespace Dali
163
164 #endif // DALI_OFFSCREEN_APPLICATION_H