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