1 #ifndef __DALI_INTERNAL_ECORE_WL_RENDER_SURFACE_H__
2 #define __DALI_INTERNAL_ECORE_WL_RENDER_SURFACE_H__
5 * Copyright (c) 2014 Samsung Electronics Co., Ltd.
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
11 * http://www.apache.org/licenses/LICENSE-2.0
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.
23 #include <boost/thread.hpp>
25 #include <Ecore_Wayland.h>
26 #include <dali/public-api/common/dali-common.h>
29 #include <render-surface-impl.h>
30 #include <ecore-wl-types.h>
31 #include <gl/egl-implementation.h>
47 * Ecore Wayland implementation of render surface.
48 * @todo change namespace to ECore_Wayland as the class
49 * is no longer pure Wayland.
51 class RenderSurface : public Internal::Adaptor::RenderSurface
55 * Uses an Wayland surface to render to.
56 * @param [in] type the type of surface passed in
57 * @param [in] positionSize the position and size of the surface
58 * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
59 * @param [in] display connection to X-server if the surface is a X window or pixmap (type must be void * to X display struct)
60 * @param [in] name optional name of surface passed in
61 * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
63 RenderSurface( SurfaceType type,
64 Dali::PositionSize positionSize,
67 const std::string& name,
68 bool isTransparent = false);
72 * Will delete the display, if it has ownership.
73 * Will delete the window/pixmap if it has owner ship
75 virtual ~RenderSurface();
79 * Second stage construction
80 * Creates the surface (window, pixmap or native buffer)
82 void Init( Any surface );
87 * @return the Ecore X window handle
89 Ecore_Wl_Window* GetWlWindow();
92 * @return the Main X display
94 WlDisplay* GetMainDisplay();
97 * Sets the render notification trigger to call when render thread is completed a frame
98 * @param renderNotification to use
100 void SetRenderNotification( TriggerEvent* renderNotification );
103 * Get the surface as an Ecore_X_drawable
105 virtual Ecore_Wl_Window* GetDrawable();
107 public: // from Dali::RenderSurface
110 * @copydoc Dali::RenderSurface::GetType()
112 virtual Dali::RenderSurface::SurfaceType GetType() = 0;
115 * @copydoc Dali::RenderSurface::GetSurface()
117 virtual Any GetSurface() = 0;
120 * @copydoc Dali::RenderSurface::GetDisplay()
122 virtual Any GetDisplay();
125 * @copydoc Dali::RenderSurface::GetPositionSize()
127 virtual PositionSize GetPositionSize() const;
129 public: // from Internal::Adaptor::RenderSurface
132 * @copydoc Dali::Internal::Adaptor::RenderSurface::CreateEglSurface()
134 virtual void CreateEglSurface( EglInterface& egl ) = 0;
137 * @copydoc Dali::Internal::Adaptor::RenderSurface::DestroyEglSurface()
139 virtual void DestroyEglSurface( EglInterface& egl ) = 0;
142 * @copydoc Dali::Internal::Adaptor::RenderSurface::ReplaceEGLSurface()
144 virtual bool ReplaceEGLSurface( EglInterface& egl ) = 0;
147 * @copydoc Dali::Internal::Adaptor::RenderSurface::MoveResize()
149 virtual void MoveResize( Dali::PositionSize positionSize);
152 * @copydoc Dali::Internal::Adaptor::RenderSurface::GetDpi()
154 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) const;
157 * @copydoc Dali::Internal::Adaptor::RenderSurface::Map()
162 * @copydoc Dali::Internal::Adaptor::RenderSurface::TransferDisplayOwner()
164 virtual void TransferDisplayOwner( Internal::Adaptor::RenderSurface& newSurface );
167 * @copydoc Dali::Internal::Adaptor::RenderSurface::ConsumeEvents()
169 virtual void ConsumeEvents();
172 * @copydoc Dali::Internal::Adaptor::RenderSurface::SetViewMode()
174 void SetViewMode( ViewMode );
177 * @copydoc Dali::Internal::Adaptor::RenderSurface::PreRender()
179 virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction ) = 0;
182 * @copydoc Dali::Internal::Adaptor::RenderSurface::PostRender()
184 virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, unsigned int timeDelta, bool replacingSurface ) = 0;
189 * Sets the display, if display parameter is empty it opens a new display
192 void SetDisplay( Any display );
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
199 unsigned int GetSurfaceId( Any surface ) const;
206 virtual void CreateWlRenderable() = 0;
209 * Use an existing render surface
210 * @param surfaceId the id of the surface
212 virtual void UseExistingRenderable( unsigned int surfaceId ) = 0;
216 WlDisplay* mMainDisplay; ///< Wayland-connection for rendering
217 SurfaceType mType; ///< type of renderable
218 PositionSize mPosition; ///< Position
219 std::string mTitle; ///< Title of window which shows from "xinfo -topvwins" command
220 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
221 TriggerEvent* mRenderNotification; ///< Render notification trigger
223 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
224 bool mOwnDisplay; ///< Whether we own the display (responsible for deleting it)
229 } // namespace Adaptor
231 } // namespace internal
235 #endif // __DALI_INTERNAL_ECORE_WL_RENDER_SURFACE_H__