[dali_2.3.42] Merge branch '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) 2023 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/adaptor-framework/event-thread-callback.h>
23 #include <dali/devel-api/threading/conditional-wait.h>
24 #include <tbm_surface.h>
25 #include <tbm_surface_queue.h>
26
27 // INTERNAL INCLUDES
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 #include <dali/public-api/dali-adaptor-common.h>
32
33 namespace Dali
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    * Uses an Wayland surface to render to.
46    * @param [in] surfaceSize the size of the surface
47    * @param [in] surface the native surface handle
48    * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
49    */
50   NativeRenderSurfaceEcoreWl(SurfaceSize surfaceSize, Any surface, bool isTransparent = false);
51
52   /**
53    * @brief Destructor
54    */
55   virtual ~NativeRenderSurfaceEcoreWl();
56
57 public:
58   /**
59    * @brief Triggers the FrameRenderedCallback
60    */
61   void TriggerFrameRenderedCallback();
62
63 public: // from NativeRenderSurface
64   /**
65    * @copydoc Dali::NativeRenderSurface::SetRenderNotification()
66    */
67   void SetRenderNotification(TriggerEventInterface* renderNotification) override;
68
69   /**
70    * @copydoc Dali::NativeRenderSurface::GetNativeRenderable()
71    */
72   virtual Any GetNativeRenderable() override;
73
74   /**
75    * @copydoc Dali::NativeRenderSurface::SetFrameRenderedCallback()
76    */
77   void SetFrameRenderedCallback(CallbackBase* callback) override;
78
79 public: // from Dali::RenderSurfaceInterface
80   /**
81    * @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
82    */
83   PositionSize GetPositionSize() const override;
84
85   /**
86    * @copydoc Dali::RenderSurfaceInterface::GetDpi()
87    */
88   void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
89
90   /**
91    * @copydoc Dali::RenderSurfaceInterface::GetSurfaceOrientation()
92    */
93   int GetSurfaceOrientation() const override;
94
95   /**
96    * @copydoc Dali::RenderSurfaceInterface::GetScreenOrientation()
97    */
98   int GetScreenOrientation() const override;
99
100   /**
101    * @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
102    */
103   void InitializeGraphics() override;
104
105   /**
106    * @copydoc Dali::RenderSurfaceInterface::CreateSurface()
107    */
108   void CreateSurface() override;
109
110   /**
111    * @copydoc Dali::RenderSurfaceInterface::DestroySurface()
112    */
113   void DestroySurface() override;
114
115   /**
116    * @copydoc Dali::RenderSurfaceInterface::ReplaceGraphicsSurface()
117    */
118   bool ReplaceGraphicsSurface() override;
119
120   /**
121    * @copydoc Dali::RenderSurfaceInterface::MoveResize()
122    */
123   void MoveResize(Dali::PositionSize positionSize) override;
124
125   /**
126    * @copydoc Dali::RenderSurfaceInterface::StartRender()
127    */
128   void StartRender() override;
129
130   /**
131    * @copydoc Dali::RenderSurfaceInterface::PreRender()
132    */
133   bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
134
135   /**
136    * @copydoc Dali::RenderSurfaceInterface::PostRender()
137    */
138   void PostRender() override;
139
140   /**
141    * @copydoc Dali::RenderSurfaceInterface::StopRender()
142    */
143   void StopRender() override;
144
145   /**
146    * @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
147    */
148   void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
149
150   /**
151    * @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
152    */
153   Dali::RenderSurfaceInterface::Type GetSurfaceType() override;
154
155   /**
156    * @copydoc Dali::RenderSurfaceInterface::MakeContextCurrent()
157    */
158   void MakeContextCurrent() override;
159
160   /**
161    * @copydoc Dali::RenderSurfaceInterface::GetDepthBufferRequired()
162    */
163   Integration::DepthBufferAvailable GetDepthBufferRequired() override;
164
165   /**
166    * @copydoc Dali::RenderSurfaceInterface::GetStencilBufferRequired()
167    */
168   Integration::StencilBufferAvailable GetStencilBufferRequired() override;
169
170 private:
171   /**
172    * @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
173    */
174   void ReleaseLock() override;
175
176   /**
177    * @copydoc Dali::NativeRenderSurface::CreateNativeRenderable()
178    */
179   void CreateNativeRenderable() override;
180
181 private: // Data
182   SurfaceSize                           mSurfaceSize;
183   TriggerEventInterface*                mRenderNotification;
184   Internal::Adaptor::GraphicsInterface* mGraphics; ///< The graphics interface
185   EglInterface*                         mEGL;
186   EGLSurface                            mEGLSurface;
187   EGLContext                            mEGLContext;
188   ColorDepth                            mColorDepth;
189   tbm_format                            mTbmFormat;
190   bool                                  mOwnSurface;
191
192   tbm_surface_queue_h                  mTbmQueue;
193   ThreadSynchronizationInterface*      mThreadSynchronization; ///< A pointer to the thread-synchronization
194   std::unique_ptr<EventThreadCallback> mFrameRenderedCallback; ///< The FrameRendredCallback called from graphics driver
195 };
196
197 } // namespace Dali
198
199 #endif // DALI_INTERNAL_WINDOWSYSTEM_TIZENWAYLAND_NATIVE_SURFACE_ECORE_WL_H