00b217dd70e3c9df025c1c69c6de99b60409cca5
[platform/core/uifw/dali-adaptor.git] / dali / internal / window-system / tizen-wayland / 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;
109
110   /**
111    * @copydoc Dali::RenderSurface::InitializeEgl()
112    */
113   virtual void InitializeEgl( EglInterface& egl );
114
115   /**
116    * @copydoc Dali::RenderSurface::CreateEglSurface()
117    */
118   virtual void CreateEglSurface( EglInterface& egl );
119
120   /**
121    * @copydoc Dali::RenderSurface::DestroyEglSurface()
122    */
123   virtual void DestroyEglSurface( EglInterface& egl );
124
125   /**
126    * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
127    */
128   virtual bool ReplaceEGLSurface( EglInterface& egl );
129
130   /**
131    * @copydoc Dali::RenderSurface::MoveResize()
132    */
133   virtual void MoveResize( Dali::PositionSize positionSize);
134
135   /**
136    * @copydoc Dali::RenderSurface::SetViewMode()
137    */
138   void SetViewMode( ViewMode viewMode );
139
140   /**
141    * @copydoc Dali::RenderSurface::StartRender()
142    */
143   virtual void StartRender();
144
145   /**
146    * @copydoc Dali::RenderSurface::PreRender()
147    */
148   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface );
149
150   /**
151    * @copydoc Dali::RenderSurface::PostRender()
152    */
153   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface );
154
155   /**
156    * @copydoc Dali::RenderSurface::StopRender()
157    */
158   virtual void StopRender();
159
160   /**
161    * @copydoc Dali::RenderSurface::SetThreadSynchronization
162    */
163   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization );
164
165   /**
166    * @copydoc Dali::RenderSurface::ReleaseLock()
167    */
168   virtual void ReleaseLock();
169
170   /**
171    * @copydoc Dali::RenderSurface::GetSurfaceType()
172    */
173   virtual RenderSurface::Type GetSurfaceType();
174
175 private: // from WindowRenderSurface
176
177   /**
178    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::Initialize()
179    */
180   void Initialize( Any surface ) override;
181
182   /**
183    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::CreateRenderable()
184    */
185   void CreateRenderable() override;
186
187   /**
188    * @copydoc Dali::Internal::Adaptor::WindowRenderSurface::UseExistingRenderable()
189    */
190   void UseExistingRenderable( unsigned int surfaceId ) override;
191
192 private:
193
194   /**
195    * Get the surface id if the surface parameter is not empty
196    * @param surface Any containing a surface id, or can be empty
197    * @return surface id, or zero if surface is empty
198    */
199   unsigned int GetSurfaceId( Any surface ) const;
200
201   /**
202    * Used as the callback for the rotation-trigger.
203    */
204   void ProcessRotationRequest();
205
206 private: // Data
207
208   std::string                     mTitle;              ///< Title of window which shows from "xinfo -topvwins" command
209   PositionSize                    mPositionSize;       ///< Position
210   Ecore_Wl_Window*                mWlWindow;           ///< Wayland-Window
211   wl_surface*                     mWlSurface;
212   wl_egl_window*                  mEglWindow;
213   ThreadSynchronizationInterface* mThreadSynchronization;
214   TriggerEventInterface*          mRenderNotification; ///< Render notification trigger
215   TriggerEventInterface*          mRotationTrigger;
216   ColorDepth                      mColorDepth;         ///< Color depth of surface (32 bit or 24 bit)
217   int                             mRotationAngle;
218   int                             mScreenRotationAngle;
219   bool                            mOwnSurface;         ///< Whether we own the surface (responsible for deleting it)
220   bool                            mRotationSupported;
221   bool                            mRotationFinished;
222   bool                            mScreenRotationFinished;
223   bool                            mResizeFinished;
224
225 }; // class WindowRenderSurfaceEcoreWl
226
227 } // namespace Adaptor
228
229 } // namespace internal
230
231 } // namespace Dali
232
233 #endif // __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__