Revert "[Tizen] ecore-wl2: add zxdg_shell define"
[platform/core/uifw/dali-adaptor.git] / dali / integration-api / wayland / ecore-wl / ecore-wl-render-surface.h
1 #ifndef __DALI_ECORE_WL_RENDER_SURFACE_H__
2 #define __DALI_ECORE_WL_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 <Ecore_Wayland.h>
23 #include <dali/public-api/common/dali-common.h>
24
25 // INTERNAL INCLUDES
26 #include <dali/devel-api/adaptor-framework/render-surface.h>
27 #ifdef DALI_ADAPTOR_COMPILATION  // full path doesn't exist until adaptor is installed so we have to use relative
28 #include <dali/integration-api/egl-interface.h>
29 #else
30 #include <dali/integration-api/adaptors/egl-interface.h>
31 #endif
32
33 namespace Dali
34 {
35
36 class TriggerEventInterface;
37
38 namespace ECore
39 {
40
41 /**
42  * Ecore Wayland implementation of render surface.
43  * @todo change namespace to ECore_Wayland as the class
44  * is no longer pure Wayland.
45  */
46 class DALI_IMPORT_API EcoreWlRenderSurface : public Dali::RenderSurface
47 {
48 public:
49   /**
50     * Uses an Wayland surface to render to.
51     * @param [in] positionSize the position and size of the surface
52     * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
53     * @param [in] name optional name of surface passed in
54     * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
55     */
56   EcoreWlRenderSurface(Dali::PositionSize positionSize,
57                        Any surface,
58                        const std::string& name,
59                        bool isTransparent = false);
60
61   /**
62    * Destructor.
63    * Will delete the display, if it has ownership.
64    * Will delete the window/pixmap if it has owner ship
65    */
66   virtual ~EcoreWlRenderSurface();
67
68 protected:
69   /**
70    * Second stage construction
71    * Creates the surface (window, pixmap or native buffer)
72    */
73   void Init( Any surface );
74
75 public: // API
76
77   /**
78    * @brief Sets the render notification trigger to call when render thread is completed a frame
79    *
80    * @param renderNotification to use
81    */
82   void SetRenderNotification(TriggerEventInterface* renderNotification);
83
84   /**
85    * @brief Get window handle
86    *
87    * @return the Ecore X window handle
88    */
89   virtual Ecore_Wl_Window* GetWlWindow();
90
91   /**
92    * Get the surface as an Ecore_Wl_Window
93    */
94   virtual Ecore_Wl_Window* GetDrawable();
95
96 public: // from Dali::RenderSurface
97
98   /**
99    * @copydoc Dali::RenderSurface::GetPositionSize()
100    */
101   virtual PositionSize GetPositionSize() const;
102
103   /**
104    * @copydoc Dali::RenderSurface::InitializeEgl()
105    */
106   virtual void InitializeEgl( EglInterface& egl ) = 0;
107
108   /**
109    * @copydoc Dali::RenderSurface::CreateEglSurface()
110    */
111   virtual void CreateEglSurface( EglInterface& egl ) = 0;
112
113   /**
114    * @copydoc Dali::RenderSurface::DestroyEglSurface()
115    */
116   virtual void DestroyEglSurface( EglInterface& egl ) = 0;
117
118   /**
119    * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
120    */
121   virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
122
123   /**
124    * @copydoc Dali::RenderSurface::MoveResize()
125    */
126   virtual void MoveResize( Dali::PositionSize positionSize);
127
128   /**
129    * @copydoc Dali::RenderSurface::SetViewMode()
130    */
131   void SetViewMode( ViewMode viewMode );
132
133   /**
134    * @copydoc Dali::RenderSurface::StartRender()
135    */
136   virtual void StartRender() = 0;
137
138   /**
139    * @copydoc Dali::RenderSurface::PreRender()
140    */
141   virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface ) = 0;
142
143   /**
144    * @copydoc Dali::RenderSurface::PostRender()
145    */
146   virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface ) = 0;
147
148   /**
149    * @copydoc Dali::RenderSurface::ReleaseLock()
150    */
151   virtual void ReleaseLock() = 0;
152
153   /**
154    * @copydoc Dali::RenderSurface::GetSurfaceType()
155    */
156   virtual RenderSurface::Type GetSurfaceType();
157
158 private:
159
160   /**
161    * Get the surface id if the surface parameter is not empty
162    * @param surface Any containing a surface id, or can be empty
163    * @return surface id, or zero if surface is empty
164    */
165   unsigned int GetSurfaceId( Any surface ) const;
166
167 protected:
168
169   /**
170    * Create XRenderable
171    */
172   virtual void CreateWlRenderable() = 0;
173
174   /**
175    * Use an existing render surface
176    * @param surfaceId the id of the surface
177    */
178   virtual void UseExistingRenderable( unsigned int surfaceId ) = 0;
179
180 protected: // Data
181
182   PositionSize                mPositionSize;       ///< Position
183   std::string                 mTitle;              ///< Title of window which shows from "xinfo -topvwins" command
184   TriggerEventInterface*      mRenderNotification; ///< Render notification trigger
185   ColorDepth                  mColorDepth;         ///< Color depth of surface (32 bit or 24 bit)
186   bool                        mOwnSurface;         ///< Whether we own the surface (responsible for deleting it)
187 };
188
189 } // namespace ECore
190
191 } // namespace Dali
192
193 #endif // __DALI_ECORE_WL_RENDER_SURFACE_H__