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