[Tizen] Add OffscreenApplication
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / native-render-surface-ecore-wl.h
1 #ifndef DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H
2 #define DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_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 <tbm_surface.h>
23 #include <tbm_surface_queue.h>
24 #include <dali/devel-api/threading/conditional-wait.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/public-api/dali-adaptor-common.h>
28 #include <dali/integration-api/adaptor-framework/egl-interface.h>
29 #include <dali/integration-api/adaptor-framework/native-render-surface.h>
30 #include <dali/internal/graphics/common/graphics-interface.h>
31
32 namespace Dali
33 {
34
35 class DisplayConnection;
36 class EglInterface;
37
38 /**
39  * Ecore Wayland Native implementation of render surface.
40  */
41 class NativeRenderSurfaceEcoreWl : public Dali::NativeRenderSurface
42 {
43 public:
44
45   /**
46     * Uses an Wayland surface to render to.
47     * @param [in] surfaceSize the size of the surface
48     * @param [in] surface the native surface handle
49     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
50     */
51   NativeRenderSurfaceEcoreWl( SurfaceSize surfaceSize, Any surface, bool isTransparent = false );
52
53   /**
54    * @brief Destructor
55    */
56   virtual ~NativeRenderSurfaceEcoreWl();
57
58 public: // from WindowRenderSurface
59
60   /**
61    * @copydoc Dali::NativeRenderSurface::GetSurface()
62    */
63   virtual Any GetDrawable() override;
64
65   /**
66    * @copydoc Dali::NativeRenderSurface::SetRenderNotification()
67    */
68   virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
69
70   /**
71    * @copydoc Dali::NativeRenderSurface::WaitUntilSurfaceReplaced()
72    */
73   virtual void WaitUntilSurfaceReplaced() override;
74
75   /**
76    * @copydoc Dali::NativeRenderSurface::GetNativeRenderable()
77    */
78   virtual Any GetNativeRenderable() override;
79
80 public: // from Dali::RenderSurfaceInterface
81
82   /**
83    * @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
84    */
85   virtual PositionSize GetPositionSize() const override;
86
87   /**
88    * @copydoc Dali::RenderSurfaceInterface::GetDpi()
89    */
90   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
91
92   /**
93    * @brief Return the orientation of the surface.
94    * @return The orientation
95    */
96   virtual int GetOrientation() const override;
97
98   /**
99    * @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
100    */
101   virtual void InitializeGraphics() override;
102
103   /**
104    * @copydoc Dali::RenderSurfaceInterface::CreateSurface()
105    */
106   virtual void CreateSurface() override;
107
108   /**
109    * @copydoc Dali::RenderSurfaceInterface::DestroySurface()
110    */
111   virtual void DestroySurface() override;
112
113   /**
114    * @copydoc Dali::RenderSurfaceInterface::ReplaceGraphicsSurface()
115    */
116   virtual bool ReplaceGraphicsSurface() override;
117
118   /**
119    * @copydoc Dali::RenderSurfaceInterface::MoveResize()
120    */
121   virtual void MoveResize( Dali::PositionSize positionSize) override;
122
123   /**
124    * @copydoc Dali::RenderSurfaceInterface::StartRender()
125    */
126   virtual void StartRender() override;
127
128   /**
129    * @copydoc Dali::RenderSurfaceInterface::PreRender()
130    */
131   virtual bool PreRender( bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect ) override;
132
133   /**
134    * @copydoc Dali::RenderSurfaceInterface::PostRender()
135    */
136   virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface, const std::vector<Rect<int>>& damagedRects ) override;
137
138   /**
139    * @copydoc Dali::RenderSurfaceInterface::StopRender()
140    */
141   virtual void StopRender() override;
142
143   /**
144    * @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
145    */
146   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization )override;
147
148   /**
149    * @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
150    */
151   virtual Dali::RenderSurfaceInterface::Type GetSurfaceType() override;
152
153   /**
154    * @copydoc Dali::RenderSurfaceInterface::MakeContextCurrent()
155    */
156   virtual void MakeContextCurrent() override;
157
158   /**
159    * @copydoc Dali::RenderSurfaceInterface::GetDepthBufferRequired()
160    */
161   virtual Integration::DepthBufferAvailable GetDepthBufferRequired() override;
162
163   /**
164    * @copydoc Dali::RenderSurfaceInterface::GetStencilBufferRequired()
165    */
166   virtual Integration::StencilBufferAvailable GetStencilBufferRequired() override;
167
168 private:
169
170   /**
171    * @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
172    */
173   virtual void ReleaseLock() override;
174
175   /**
176    * @copydoc Dali::NativeRenderSurface::CreateNativeRenderable()
177    */
178   virtual void CreateNativeRenderable() override;
179
180   /**
181    * @copydoc Dali::NativeRenderSurface::ReleaseDrawable()
182    */
183   virtual void ReleaseDrawable() override;
184
185 private: // Data
186
187   SurfaceSize                            mSurfaceSize;
188   TriggerEventInterface*                 mRenderNotification;
189   Internal::Adaptor::GraphicsInterface*  mGraphics;                  ///< The graphics interface
190   EglInterface*                          mEGL;
191   EGLSurface                             mEGLSurface;
192   EGLContext                             mEGLContext;
193   ColorDepth                             mColorDepth;
194   tbm_format                             mTbmFormat;
195   bool                                   mOwnSurface;
196   bool                                   mDrawableCompleted;
197
198   tbm_surface_queue_h                    mTbmQueue;
199   tbm_surface_h                          mConsumeSurface;
200   ThreadSynchronizationInterface*        mThreadSynchronization;     ///< A pointer to the thread-synchronization
201   ConditionalWait                        mTbmSurfaceCondition;
202
203 };
204
205 } // namespace Dali
206
207 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H