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