1 #ifndef DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
2 #define DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
5 * Copyright (c) 2019 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/devel-api/threading/conditional-wait.h>
25 #include <dali/public-api/dali-adaptor-common.h>
26 #include <dali/integration-api/adaptor-framework/egl-interface.h>
27 #include <dali/internal/graphics/common/graphics-interface.h>
28 #include <dali/internal/graphics/gles/egl-implementation.h>
29 #include <dali/internal/system/linux/dali-ecore-x.h>
30 #include <dali/internal/window-system/common/pixmap-render-surface.h>
31 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
41 * Ecore X11 Pixmap implementation of render surface.
43 class PixmapRenderSurfaceEcoreX : public PixmapRenderSurface
48 * Uses an X11 surface to render to.
49 * @param [in] positionSize the position and size of the surface
50 * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
51 * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
53 PixmapRenderSurfaceEcoreX( Dali::PositionSize positionSize, Any surface, bool isTransparent = false );
58 virtual ~PixmapRenderSurfaceEcoreX();
60 public: // from WindowRenderSurface
63 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
65 virtual Any GetSurface() override;
68 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
70 virtual void SetRenderNotification( TriggerEventInterface* renderNotification ) override;
72 public: // from Dali::Integration::RenderSurface
75 * @copydoc Dali::Integration::RenderSurface::GetPositionSize()
77 virtual PositionSize GetPositionSize() const override;
80 * @copydoc Dali::Integration::RenderSurface::GetDpi()
82 virtual void GetDpi( unsigned int& dpiHorizontal, unsigned int& dpiVertical ) override;
85 * @brief Return the orientation of the surface.
86 * @return The orientation
88 virtual int GetOrientation() const override;
91 * @copydoc Dali::Integration::RenderSurface::InitializeGraphics()
93 virtual void InitializeGraphics() override;
96 * @copydoc Dali::Integration::RenderSurface::CreateSurface()
98 virtual void CreateSurface() override;
101 * @copydoc Dali::Integration::RenderSurface::DestroySurface()
103 virtual void DestroySurface() override;
106 * @copydoc Dali::Integration::RenderSurface::ReplaceGraphicsSurface()
108 virtual bool ReplaceGraphicsSurface() override;
111 * @copydoc Dali::Integration::RenderSurface::MoveResize()
113 virtual void MoveResize( Dali::PositionSize positionSize) override {}
116 * @copydoc Dali::Integration::RenderSurface::StartRender()
118 virtual void StartRender() override;
121 * @copydoc Dali::Integration::RenderSurface::PreRender()
123 virtual bool PreRender( bool resizingSurface ) override;
126 * @copydoc Dali::Integration::RenderSurface::PostRender()
128 virtual void PostRender( bool renderToFbo, bool replacingSurface, bool resizingSurface ) override;
131 * @copydoc Dali::Integration::RenderSurface::StopRender()
133 virtual void StopRender() override;
136 * @copydoc Dali::Integration::RenderSurface::SetThreadSynchronization
138 virtual void SetThreadSynchronization( ThreadSynchronizationInterface& threadSynchronization ) override;
141 * @copydoc Dali::Integration::RenderSurface::GetSurfaceType()
143 virtual Integration::RenderSurface::Type GetSurfaceType() override;
146 * @copydoc Dali::Integration::RenderSurface::MakeContextCurrent()
148 virtual void MakeContextCurrent() override;
150 private: // from PixmapRenderSurface
153 * @copydoc Dali::Integration::RenderSurface::ReleaseLock()
155 virtual void ReleaseLock() override;
158 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
160 virtual void Initialize( Any surface ) override;
163 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
165 virtual void CreateRenderable() override;
168 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
170 virtual void UseExistingRenderable( unsigned int surfaceId ) override;
173 * @copydoc Dali::Integration::RenderSurface::SetDamagedRect()
175 virtual void SetDamagedRect( const Dali::DamagedRect& damagedRect, Dali::DamagedRect& mergedRect ) override;
178 * @copydoc Dali::Integration::RenderSurface::GetBufferAge()
180 virtual int32_t GetBufferAge() override;
185 * Get the surface id if the surface parameter is not empty
186 * @param surface Any containing a surface id, or can be empty
187 * @return surface id, or zero if surface is empty
189 unsigned int GetSurfaceId( Any surface ) const;
193 static const int BUFFER_COUNT = 2;
194 GraphicsInterface* mGraphics; ///< Graphics interface
195 Dali::DisplayConnection* mDisplayConnection; ///< Display connection
196 PositionSize mPosition; ///< Position
197 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
198 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
199 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
201 int mProduceBufferIndex;
202 int mConsumeBufferIndex;
203 XPixmap mX11Pixmaps[BUFFER_COUNT]; ///< X-Pixmap
204 EGLSurface mEglSurfaces[BUFFER_COUNT];
205 ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
206 ConditionalWait mPixmapCondition; ///< condition to share pixmap
209 } // namespace Adaptor
211 } // namespace internal
215 #endif // DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H