[Tizen] Add OffscreenApplication
[platform/core/uifw/dali-adaptor.git] / dali / internal / offscreen / common / offscreen-window-impl.h
1 #ifndef DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_H
2 #define DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_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 <memory>
23 #include <dali/public-api/common/intrusive-ptr.h>
24 #include <dali/public-api/signals/connection-tracker.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/devel-api/adaptor-framework/offscreen-window.h>
28 #include <dali/integration-api/adaptor-framework/scene-holder-impl.h>
29
30 namespace Dali
31 {
32 class Adaptor;
33 class Layer;
34 class NativeRenderSurface;
35 class TriggerEventInterface;
36
37 namespace Internal
38 {
39
40 /**
41  * Implementation of the OffscreenWindow class.
42  */
43 class OffscreenWindow : public Dali::Internal::Adaptor::SceneHolder,
44                         public ConnectionTracker
45 {
46 public:
47   using WindowSize = Dali::OffscreenWindow::WindowSize;
48   using PostRenderSignalType = Dali::OffscreenWindow::PostRenderSignalType;
49
50   /**
51    * @brief Create a new OffscreenWindow
52    *
53    * @param[in] width The initial width of the OffscreenWindow
54    * @param[in] height The initial height of the OffscreenWindow
55    * @param[in] surface The native surface handle of your platform
56    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
57    */
58   static OffscreenWindow* New( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent );
59
60   OffscreenWindow() = default;
61
62 public:
63
64   /**
65    * Destructor
66    */
67   ~OffscreenWindow();
68
69   /**
70    * @copydoc Dali::OffscreenWindow::GetLayerCount
71    */
72   uint32_t GetLayerCount() const;
73
74   /**
75    * @copydoc Dali::OffscreenWindow::GetLayer
76    */
77   Dali::Layer GetLayer( uint32_t depth ) const;
78
79   /**
80    * @copydoc Dali::OffscreenWindow::GetSize
81    */
82   WindowSize GetSize() const;
83
84   /**
85    * @copydoc Dali::OffscreenWindow::GetNativeHandle
86    */
87   Any GetNativeHandle() const override;
88
89   /*
90    * @brief Initialize the OffscreenWindow
91    * @param[in] isDefaultWindow Whether the OffscreenWindow is a default one or not
92    */
93   void Initialize( bool isDefaultWindow );
94
95 public:  // Signals
96
97   /**
98    * @copydoc Dali::OffscreenWindow::PostRenderSignal
99    */
100   PostRenderSignalType& PostRenderSignal();
101
102 private:
103   /**
104    * This function is called after drawing by dali.
105    */
106   void OnPostRender();
107
108   /**
109    * @brief Get the native render surface
110    * @return The render surface
111    */
112   NativeRenderSurface* GetNativeRenderSurface() const;
113
114 private:
115
116  /**
117    * Private constructor
118    *
119    * @param[in] width The initial width of the OffscreenWindow
120    * @param[in] height The initial height of the OffscreenWindow
121    * @param[in] surface The native surface handle
122    * @param[in] isTranslucent Whether the OffscreenWindow is translucent or not
123    */
124   OffscreenWindow( uint16_t width, uint16_t height, Dali::Any surface, bool isTranslucent );
125
126   // Undefined
127   OffscreenWindow( const OffscreenWindow& );
128   OffscreenWindow& operator=( OffscreenWindow& );
129
130   /*
131    * @brief Initialize the OffscreenWindow (for internal use)
132    */
133   void Initialize();
134
135 private:
136
137   std::unique_ptr< TriggerEventInterface >  mRenderNotification;
138   PostRenderSignalType                      mPostRenderSignal;
139 };
140
141 inline OffscreenWindow& GetImplementation( Dali::OffscreenWindow& offscreenWindow )
142 {
143   DALI_ASSERT_ALWAYS( offscreenWindow && "Dali::OffscreenWindow handle is empty" );
144
145   BaseObject& handle = offscreenWindow.GetBaseObject();
146
147   return static_cast<OffscreenWindow&>( handle );
148 }
149
150 inline const OffscreenWindow& GetImplementation( const Dali::OffscreenWindow& offscreenWindow )
151 {
152   DALI_ASSERT_ALWAYS( offscreenWindow && "Dali::OffscreenWindow handle is empty" );
153
154   const BaseObject& handle = offscreenWindow.GetBaseObject();
155
156   return static_cast<const OffscreenWindow&>( handle );
157 }
158
159 } // namespace Internal
160
161 } // namespace Dali
162
163 #endif // DALI_INTERNAL_OFFSCREEN_WINDOW_IMPL_H