1 #ifndef DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
2 #define DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H
5 * Copyright (c) 2021 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/integration-api/adaptor-framework/egl-interface.h>
26 #include <dali/internal/graphics/common/graphics-interface.h>
27 #include <dali/internal/graphics/gles/egl-implementation.h>
28 #include <dali/internal/system/linux/dali-ecore-x.h>
29 #include <dali/internal/window-system/common/pixmap-render-surface.h>
30 #include <dali/internal/window-system/ubuntu-x11/ecore-x-types.h>
31 #include <dali/public-api/dali-adaptor-common.h>
40 * Ecore X11 Pixmap implementation of render surface.
42 class PixmapRenderSurfaceEcoreX : public PixmapRenderSurface
46 * Uses an X11 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] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
51 PixmapRenderSurfaceEcoreX(Dali::PositionSize positionSize, Any surface, bool isTransparent = false);
56 virtual ~PixmapRenderSurfaceEcoreX();
58 public: // from WindowRenderSurface
60 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
62 Any GetSurface() override;
65 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
67 void SetRenderNotification(TriggerEventInterface* renderNotification) override;
69 public: // from Dali::RenderSurfaceInterface
71 * @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
73 PositionSize GetPositionSize() const override;
76 * @copydoc Dali::RenderSurfaceInterface::GetDpi()
78 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
81 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
83 int GetOrientation() const override;
86 * @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
88 void InitializeGraphics() override;
91 * @copydoc Dali::RenderSurfaceInterface::CreateSurface()
93 void CreateSurface() override;
96 * @copydoc Dali::RenderSurfaceInterface::DestroySurface()
98 void DestroySurface() override;
101 * @copydoc Dali::RenderSurfaceInterface::ReplaceGraphicsSurface()
103 bool ReplaceGraphicsSurface() override;
106 * @copydoc Dali::RenderSurfaceInterface::MoveResize()
108 virtual void MoveResize(Dali::PositionSize positionSize) override
113 * @copydoc Dali::RenderSurfaceInterface::StartRender()
115 void StartRender() override;
118 * @copydoc Dali::RenderSurfaceInterface::PreRender()
120 bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
123 * @copydoc Dali::RenderSurfaceInterface::PostRender()
125 void PostRender() override;
128 * @copydoc Dali::RenderSurfaceInterface::StopRender()
130 void StopRender() override;
133 * @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
135 void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
138 * @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
140 Dali::RenderSurfaceInterface::Type GetSurfaceType() override;
143 * @copydoc Dali::RenderSurfaceInterface::MakeContextCurrent()
145 void MakeContextCurrent() override;
147 private: // from PixmapRenderSurface
149 * @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
151 void ReleaseLock() override;
154 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
156 void Initialize(Any surface) override;
159 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
161 void CreateRenderable() override;
164 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
166 void UseExistingRenderable(unsigned int surfaceId) override;
170 * Get the surface id if the surface parameter is not empty
171 * @param surface Any containing a surface id, or can be empty
172 * @return surface id, or zero if surface is empty
174 unsigned int GetSurfaceId(Any surface) const;
177 static const int BUFFER_COUNT = 2;
178 GraphicsInterface* mGraphics; ///< Graphics interface
179 Dali::DisplayConnection* mDisplayConnection; ///< Display connection
180 PositionSize mPosition; ///< Position
181 TriggerEventInterface* mRenderNotification; ///< Render notification trigger
182 ColorDepth mColorDepth; ///< Color depth of surface (32 bit or 24 bit)
183 bool mOwnSurface; ///< Whether we own the surface (responsible for deleting it)
185 int mProduceBufferIndex;
186 int mConsumeBufferIndex;
187 XPixmap mX11Pixmaps[BUFFER_COUNT]; ///< X-Pixmap
188 EGLSurface mEglSurfaces[BUFFER_COUNT];
189 ThreadSynchronizationInterface* mThreadSynchronization; ///< A pointer to the thread-synchronization
190 ConditionalWait mPixmapCondition; ///< condition to share pixmap
193 } // namespace Adaptor
195 } // namespace Internal
199 #endif // DALI_ECORE_X_PIXMAP_RENDER_SURFACE_H