[Tizen] Support Ecore-Wayland2
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / ecore-wl / window-render-surface-ecore-wl.h
1 #ifndef __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__
2 #define __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__
3
4 /*
5  * Copyright (c) 2018 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 <Ecore_Wayland.h>
23 #include <wayland-egl.h>
24 #include <dali/public-api/common/dali-common.h>
25
26 // INTERNAL INCLUDES
27 #include <dali/integration-api/egl-interface.h>
28 #include <dali/integration-api/thread-synchronization-interface.h>
29 #include <dali/internal/window-system/common/window-render-surface.h>
30
31 namespace Dali
32 {
33
34 namespace Internal
35 {
36 namespace Adaptor
37 {
38
39 /**
40  * Ecore Wayland Window implementation of render surface.
41  */
42 class WindowRenderSurfaceEcoreWl : public WindowRenderSurface
43 {
44 public:
45
46   /**
47     * Uses an Wayland surface to render to.
48     * @param [in] positionSize the position and size of the surface
49     * @param [in] surface can be a Wayland-window or Wayland-pixmap (type must be unsigned int).
50     * @param [in] name optional name of surface passed in
51     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
52     */
53   WindowRenderSurfaceEcoreWl( Dali::PositionSize positionSize,
54                        Any surface,
55                        const std::string& name,
56                        bool isTransparent = false );
57
58   /**
59    * @brief Destructor
60    */
61   virtual ~WindowRenderSurfaceEcoreWl();
62
63 public: // API
64
65   /**
66    * @brief Get window handle
67    * @return the Ecore Waylnad window handle
68    */
69   Ecore_Wl_Window* GetWlWindow();
70
71   /**
72    * Notify output is transformed.
73    */
74   void OutputTransformed();
75
76 public: // from WindowRenderSurface
77
78   /**
79    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::GetWindow()
80    */
81   virtual Any GetWindow() override;
82
83   /**
84    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::Map()
85    */
86   virtual void Map() override;
87
88   /**
89    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::SetRenderNotification()
90    */
91   virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
92
93   /**
94    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::SetTransparency()
95    */
96   virtual void SetTransparency( bool transparent ) override;
97
98   /**
99    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::RequestRotation()
100    */
101   virtual void RequestRotation( int angle, int width, int height ) override;
102
103 public: // from Dali::RenderSurface
104
105   /**
106    * @copydoc Dali::RenderSurface::GetPositionSize()
107    */
108   virtual PositionSize GetPositionSize() const override;
109
110   /**
111    * @copydoc Dali::RenderSurface::GetDpi()
112    */
113   virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
114
115   /**
116    * @copydoc Dali::RenderSurface::InitializeEgl()
117    */
118   virtual void InitializeEgl( EglInterface& egl ) override;
119
120   /**
121    * @copydoc Dali::RenderSurface::CreateEglSurface()
122    */
123   virtual void CreateEglSurface( EglInterface& egl ) override;
124
125   /**
126    * @copydoc Dali::RenderSurface::DestroyEglSurface()
127    */
128   virtual void DestroyEglSurface( EglInterface& egl ) override;
129
130   /**
131    * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
132    */
133   virtual bool ReplaceEGLSurface( EglInterface& egl ) override;
134
135   /**
136    * @copydoc Dali::RenderSurface::MoveResize()
137    */
138   virtual void MoveResize( Dali::PositionSize positionSize) override;
139
140   /**
141    * @copydoc Dali::RenderSurface::SetViewMode()
142    */
143   virtual void SetViewMode( ViewMode viewMode ) override;
144
145   /**
146    * @copydoc Dali::RenderSurface::StartRender()
147    */
148   virtual void StartRender() override;
149
150   /**
151    * @copydoc Dali::RenderSurface::PreRender()
152    */
153   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) override;
154
155   /**
156    * @copydoc Dali::RenderSurface::PostRender()
157    */
158   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) override;
159
160   /**
161    * @copydoc Dali::RenderSurface::StopRender()
162    */
163   virtual void StopRender() override;
164
165   /**
166    * @copydoc Dali::RenderSurface::SetThreadSynchronization
167    */
168   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
169
170   /**
171    * @copydoc Dali::RenderSurface::ReleaseLock()
172    */
173   virtual void ReleaseLock() override;
174
175   /**
176    * @copydoc Dali::RenderSurface::GetSurfaceType()
177    */
178   virtual RenderSurface::Type GetSurfaceType() override;
179
180 private: // from WindowRenderSurface
181
182   /**
183    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::Initialize()
184    */
185   void Initialize( Any surface ) override;
186
187   /**
188    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::CreateRenderable()
189    */
190   void CreateRenderable() override;
191
192   /**
193    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::UseExistingRenderable()
194    */
195   void UseExistingRenderable( unsigned int surfaceId ) override;
196
197 private:
198
199   /**
200    * Get the surface id if the surface parameter is not empty
201    * @param surface Any containing a surface id, or can be empty
202    * @return surface id, or zero if surface is empty
203    */
204   unsigned int GetSurfaceId( Any surface ) const;
205
206   /**
207    * Used as the callback for the rotation-trigger.
208    */
209   void ProcessRotationRequest();
210
211 private: // Data
212
213   std::string                     mTitle;              ///< Title of window which shows from "xinfo -topvwins" command
214   PositionSize                    mPositionSize;       ///< Position
215   Ecore_Wl_Window*                mWlWindow;           ///< Wayland-Window
216   wl_surface*                     mWlSurface;
217   wl_egl_window*                  mEglWindow;
218   ThreadSynchronizationInterface* mThreadSynchronization;
219   TriggerEventInterface*          mRenderNotification; ///< Render notification trigger
220   TriggerEventInterface*          mRotationTrigger;
221   ColorDepth                      mColorDepth;         ///< Color depth of surface (32 bit or 24 bit)
222   int                             mRotationAngle;
223   int                             mScreenRotationAngle;
224   bool                            mOwnSurface;         ///< Whether we own the surface (responsible for deleting it)
225   bool                            mRotationSupported;
226   bool                            mRotationFinished;
227   bool                            mScreenRotationFinished;
228   bool                            mResizeFinished;
229
230 }; // class WindowRenderSurfaceEcoreWl
231
232 } // namespace Adaptor
233
234 } // namespace internal
235
236 } // namespace Dali
237
238 #endif // __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__