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/gles/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>
26 #include <dali/public-api/dali-adaptor-common.h>
27 #include <dali/internal/graphics/common/graphics-interface.h>
30 #include <dali/devel-api/threading/conditional-wait.h>
42 * Ecore X11 Pixmap implementation of render surface.
44 class PixmapRenderSurfaceEcoreX : public PixmapRenderSurface
49 * Uses an X11 surface to render to.
50 * @param [in] positionSize the position and size of the surface
51 * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
52 * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
54 PixmapRenderSurfaceEcoreX( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
59 virtual ~PixmapRenderSurfaceEcoreX();
61 public: // from WindowRenderSurface
64 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
66 virtual Any GetSurface() override;
69 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
71 virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
73 public: // from Dali::RenderSurface
76 * @copydoc Dali::RenderSurface::GetPositionSize()
78 virtual PositionSize GetPositionSize() const override;
81 * @copydoc Dali::RenderSurface::GetDpi()
83 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
86 * @copydoc Dali::RenderSurface::InitializeGraphics()
88 virtual void InitializeGraphics( GraphicsInterface& graphics, Dali::DisplayConnection& displayConnection ) override;
91 * @copydoc Dali::RenderSurface::CreateSurface()
93 virtual void CreateSurface() override;
96 * @copydoc Dali::RenderSurface::DestroySurface()
98 virtual void DestroySurface() override;
101 * @copydoc Dali::RenderSurface::ReplaceGraphicsSurface()
103 virtual bool ReplaceGraphicsSurface() override;
106 * @copydoc Dali::RenderSurface::MoveResize()
108 virtual void MoveResize( Dali::PositionSize positionSize) override {}
111 * @copydoc Dali::RenderSurface::StartRender()
113 virtual void StartRender() override;
116 * @copydoc Dali::RenderSurface::PreRender()
118 virtual bool PreRender( bool resizingSurface ) override;
121 * @copydoc Dali::RenderSurface::PostRender()
123 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) override;
126 * @copydoc Dali::RenderSurface::StopRender()
128 virtual void StopRender() override;
131 * @copydoc Dali::RenderSurface::SetThreadSynchronization
133 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
136 * @copydoc Dali::RenderSurface::GetSurfaceType()
138 virtual RenderSurface::Type GetSurfaceType() override;
140 private: // from PixmapRenderSurface
143 * @copydoc Dali::RenderSurface::ReleaseLock()
145 virtual void ReleaseLock() override;
148 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
150 virtual void Initialize( Any surface ) override;
153 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
155 virtual void CreateRenderable() override;
158 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
160 virtual void UseExistingRenderable( unsigned int surfaceId ) override;
165 * Get the surface id if the surface parameter is not empty
166 * @param surface Any containing a surface id, or can be empty
167 * @return surface id, or zero if surface is empty
169 unsigned int GetSurfaceId( Any surface ) const;
173 static const int BUFFER_COUNT = 2;
174 GraphicsInterface* mGraphics; ///< Graphics interface
175 Dali::DisplayConnection* mDisplayConnection; ///< Display connection
176 PositionSize mPosition; ///< Position
177 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
178 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
179 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
181 int mProduceBufferIndex;
182 int mConsumeBufferIndex;
183 XPixmap mX11Pixmaps[BUFFER_COUNT]; ///< X-Pixmap
184 EGLSurface mEglSurfaces[BUFFER_COUNT];
185 ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
186 ConditionalWait mPixmapCondition; ///< condition to share pixmap
189 } // namespace Adaptor
191 } // namespace internal
195 #endif // DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H