1 #ifndef __DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H__
2 #define __DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H__
5 * Copyright (c) 2018 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.
22 #include <dali/integration-api/egl-interface.h>
23 #include <dali/internal/graphics/gles20/egl-implementation.h>
24 #include <dali/internal/window-system/common/pixmap-render-surface.h>
25 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
28 #include <dali/public-api/common/dali-common.h>
29 #include <dali/devel-api/threading/conditional-wait.h>
40 * Ecore X11 Pixmap implementation of render surface.
42 class PixmapRenderSurfaceEcoreX : public PixmapRenderSurface
47 * Uses an X11 surface to render to.
48 * @param [in] positionSize the position and size of the surface
49 * @param [in] surface can be a X-window or X-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
53 PixmapRenderSurfaceEcoreX( Dali::PositionSize positionSize,
55 const std::string& name,
56 bool isTransparent = false);
61 virtual ~PixmapRenderSurfaceEcoreX();
63 public: // from WindowRenderSurface
66 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
68 virtual Any GetSurface() override;
71 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
73 virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
75 public: // from Dali::RenderSurface
78 * @copydoc Dali::RenderSurface::GetPositionSize()
80 virtual PositionSize GetPositionSize() const;
83 * @copydoc Dali::RenderSurface::InitializeEgl()
85 virtual void InitializeEgl( EglInterface& egl );
88 * @copydoc Dali::RenderSurface::CreateEglSurface()
90 virtual void CreateEglSurface( EglInterface& egl );
93 * @copydoc Dali::RenderSurface::DestroyEglSurface()
95 virtual void DestroyEglSurface( EglInterface& egl );
98 * @copydoc Dali::RenderSurface::ReplaceEGLSurface()
100 virtual bool ReplaceEGLSurface( EglInterface& egl );
103 * @copydoc Dali::RenderSurface::MoveResize()
105 virtual void MoveResize( Dali::PositionSize positionSize) {}
108 * @copydoc Dali::RenderSurface::SetViewMode()
110 void SetViewMode( ViewMode viewMode ) {}
113 * @copydoc Dali::RenderSurface::StartRender()
115 virtual void StartRender();
118 * @copydoc Dali::RenderSurface::PreRender()
120 virtual bool PreRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, bool resizingSurface );
123 * @copydoc Dali::RenderSurface::PostRender()
125 virtual void PostRender( EglInterface& egl, Integration::GlAbstraction& glAbstraction, DisplayConnection* displayConnection, bool replacingSurface, bool resizingSurface );
128 * @copydoc Dali::RenderSurface::StopRender()
130 virtual void StopRender();
133 * @copydoc Dali::RenderSurface::SetThreadSynchronization
135 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization );
138 * @copydoc Dali::RenderSurface::GetSurfaceType()
140 virtual RenderSurface::Type GetSurfaceType();
142 private: // from PixmapRenderSurface
145 * @copydoc Dali::RenderSurface::ReleaseLock()
147 virtual void ReleaseLock();
150 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
152 virtual void Initialize( Any surface ) override;
155 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
157 virtual void CreateRenderable() override;
160 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
162 virtual void UseExistingRenderable( unsigned int surfaceId ) override;
167 * Get the surface id if the surface parameter is not empty
168 * @param surface Any containing a surface id, or can be empty
169 * @return surface id, or zero if surface is empty
171 unsigned int GetSurfaceId( Any surface ) const;
175 static const int BUFFER_COUNT = 2;
177 PositionSize mPosition; ///< Position
178 std::string mTitle; ///< Title of window which shows from "xinfo -topvwins" command
179 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
180 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
181 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
183 int mProduceBufferIndex;
184 int mConsumeBufferIndex;
185 XPixmap mX11Pixmaps[BUFFER_COUNT]; ///< X-Pixmap
186 EGLSurface mEglSurfaces[BUFFER_COUNT];
187 ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
188 ConditionalWait mPixmapCondition; ///< condition to share pixmap
191 } // namespace Adaptor
193 } // namespace internal
197 #endif // __DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H__