[Tizen] Revert "Support screen rotation"
[platform/core/uifw/dali-adaptor.git] / adaptors / ecore / wayland / window-render-surface.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) 2017 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 <wayland-egl.h>
23
24 // INTERNAL INCLUDES
25 #include <ecore-wl-render-surface.h>
26 #include <window.h>
27 #include <integration-api/thread-synchronization-interface.h>
28
29 namespace Dali
30 {
31
32 namespace ECore
33 {
34
35 /**
36  * @copydoc Dali::ECore::EcoreWlRenderSurface.
37  * Window specialization.
38  */
39 class WindowRenderSurface : public EcoreWlRenderSurface
40 {
41 public:
42
43   /**
44     * Uses an Wayland surface to render to.
45     * @param [in] positionSize the position and size of the surface
46     * @param [in] surface can be a Wayland-window or Wayland-pixmap (type must be unsigned int).
47     * @param [in] name optional name of surface passed in
48     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
49     */
50   WindowRenderSurface( Dali::PositionSize positionSize,
51                        Any surface,
52                        const std::string& name,
53                        bool isTransparent = false );
54
55   /**
56    * @copydoc Dali::ECore::EcoreWlRenderSurface::~EcoreWlRenderSurface
57    */
58   virtual ~WindowRenderSurface();
59
60 public: // API
61
62   /**
63    * @copydoc Dali::RenderSurface::GetDrawable()
64    */
65   virtual Ecore_Wl_Window* GetDrawable();
66
67   /**
68    * Map window
69    */
70   virtual void Map();
71
72   /**
73    * @copydoc Dali::ECore::EcoreWlRenderSurface::GetSurface()
74    */
75   virtual Any GetSurface();
76
77   /**
78    * @copydoc Dali::ECore::EcoreWlRenderSurface::GetWlWindow()
79    */
80   virtual Ecore_Wl_Window* GetWlWindow();
81
82   /**
83    * Request surface rotation
84    * @param[in] orientation A new orientation of the surface
85    * @param[in] width A new width of the surface
86    * @param[in] height A new height of the surface
87    */
88   void RequestRotation( Dali::Window::WindowOrientation orientation, int width, int height );
89
90   /**
91    * @brief Sets whether the surface is transparent or not.
92    *
93    * @param[in] transparent Whether the surface is transparent
94    */
95   void SetTransparency( bool transparent );
96
97 public: // from Dali::RenderSurface
98
99   /**
100    * @copydoc Dali::RenderSurface::InitializeEgl()
101    */
102   virtual void InitializeEgl( EglInterface& egl );
103
104   /**
105    * @copydoc Dali::RenderSurface::CreateEglSurface()
106    */
107   virtual void CreateEglSurface( EglInterface& egl );
108
109   /**
110    * @copydoc Dali::RenderSurface::DestroyEglSurface()
111    */
112   virtual void DestroyEglSurface( EglInterface& egl );
113
114   /**
115    * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
116    */
117   virtual bool ReplaceEGLSurface( EglInterface& egl );
118
119   /**
120    * @copydoc Dali::RenderSurface::MoveResize()
121    */
122   virtual void MoveResize( Dali::PositionSize positionSize);
123
124   /**
125    * @copydoc Dali::RenderSurface::SetViewMode()
126    */
127   void SetViewMode( ViewMode viewMode );
128
129   /**
130    * @copydoc Dali::RenderSurface::StartRender()
131    */
132   virtual void StartRender();
133
134   /**
135    * @copydoc Dali::RenderSurface::PreRender()
136    */
137   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction );
138
139   /**
140    * @copydoc Dali::RenderSurface::PostRender()
141    */
142   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface );
143
144   /**
145    * @copydoc Dali::RenderSurface::StopRender()
146    */
147   virtual void StopRender();
148
149   /**
150    * @copydoc Dali::RenderSurface::SetThreadSynchronization
151    */
152   virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization );
153
154   /**
155    * @copydoc Dali::RenderSurface::ReleaseLock()
156    */
157   virtual void ReleaseLock();
158
159 protected:
160
161   /**
162    * Create WlWindow
163    */
164   virtual void CreateWlRenderable();
165
166   /**
167    * @copydoc Dali::Internal::Adaptor::ECore::EcoreWlRenderSurface::UseExistingRenderable
168    */
169   virtual void UseExistingRenderable( unsigned int surfaceId );
170
171 private:
172
173   /**
174    * Used as the callback for the rotation-trigger.
175    */
176   void ProcessRotationRequest();
177
178 private: // Data
179
180   typedef int (*EglWinGetCapabilitiesFunction)( wl_egl_window* eglWindow );
181   typedef int (*EglWinSetRotationFunction)( wl_egl_window* eglWindow, int rotation );
182
183   EglWinGetCapabilitiesFunction  mEglWinGetCapabilitiesPtr;
184   EglWinSetRotationFunction      mEglWinSetRotationPtr;
185
186   void*                           mLibHandle; ///< Handle for the loaded library
187   Ecore_Wl_Window*                mWlWindow;  ///< Wayland-Window
188   wl_surface*                     mWlSurface;
189   wl_egl_window*                  mEglWindow;
190   ThreadSynchronizationInterface* mThreadSynchronization;
191   TriggerEventInterface*          mRotationTrigger;
192   bool                            mRotationSupported;
193   bool                            mRotated;
194
195 }; // class WindowRenderSurface
196
197 } // namespace ECore
198
199 } // namespace Dali
200
201 #endif // __DALI_INTERNAL_ECORE_WL_WINDOW_RENDER_SURFACE_H__