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