1 #ifndef DALI_WINDOW_SYSTEM_X11_PIXMAP_RENDER_SURFACE_H
2 #define DALI_WINDOW_SYSTEM_X11_PIXMAP_RENDER_SURFACE_H
5 * Copyright (c) 2022 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/window-system/common/pixmap-render-surface.h>
29 #include <dali/public-api/dali-adaptor-common.h>
38 * X11 Pixmap implementation of render surface.
40 class PixmapRenderSurfaceX : public PixmapRenderSurface
44 * Uses an X11 surface to render to.
45 * @param [in] positionSize the position and size of the surface
46 * @param [in] surface can be a X-window or X-pixmap (type must be unsigned int).
47 * @param [in] isTransparent if it is true, surface has 32 bit color depth, otherwise, 24 bit
49 PixmapRenderSurfaceX(Dali::PositionSize positionSize, Any surface, bool isTransparent = false);
54 virtual ~PixmapRenderSurfaceX();
56 public: // from WindowRenderSurface
58 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::GetSurface()
60 Any GetSurface() override;
63 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::SetRenderNotification()
65 void SetRenderNotification(TriggerEventInterface* renderNotification) override;
67 public: // from Dali::RenderSurfaceInterface
69 * @copydoc Dali::RenderSurfaceInterface::GetPositionSize()
71 PositionSize GetPositionSize() const override;
74 * @copydoc Dali::RenderSurfaceInterface::GetDpi()
76 void GetDpi(unsigned int& dpiHorizontal, unsigned int& dpiVertical) override;
79 * @copydoc Dali::Internal::Adaptor::WindowBase::GetOrientation()
81 int GetOrientation() const override;
84 * @copydoc Dali::RenderSurfaceInterface::InitializeGraphics()
86 void InitializeGraphics() override;
89 * @copydoc Dali::RenderSurfaceInterface::CreateSurface()
91 void CreateSurface() override;
94 * @copydoc Dali::RenderSurfaceInterface::DestroySurface()
96 void DestroySurface() override;
99 * @copydoc Dali::RenderSurfaceInterface::ReplaceGraphicsSurface()
101 bool ReplaceGraphicsSurface() override;
104 * @copydoc Dali::RenderSurfaceInterface::MoveResize()
106 virtual void MoveResize(Dali::PositionSize positionSize) override
111 * @copydoc Dali::RenderSurfaceInterface::StartRender()
113 void StartRender() override;
116 * @copydoc Dali::RenderSurfaceInterface::PreRender()
118 bool PreRender(bool resizingSurface, const std::vector<Rect<int>>& damagedRects, Rect<int>& clippingRect) override;
121 * @copydoc Dali::RenderSurfaceInterface::PostRender()
123 void PostRender() override;
126 * @copydoc Dali::RenderSurfaceInterface::StopRender()
128 void StopRender() override;
131 * @copydoc Dali::RenderSurfaceInterface::SetThreadSynchronization
133 void SetThreadSynchronization(ThreadSynchronizationInterface& threadSynchronization) override;
136 * @copydoc Dali::RenderSurfaceInterface::GetSurfaceType()
138 Dali::RenderSurfaceInterface::Type GetSurfaceType() override;
141 * @copydoc Dali::RenderSurfaceInterface::MakeContextCurrent()
143 void MakeContextCurrent() override;
145 private: // from PixmapRenderSurface
147 * @copydoc Dali::RenderSurfaceInterface::ReleaseLock()
149 void ReleaseLock() override;
152 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
154 void Initialize(Any surface) override;
157 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
159 void CreateRenderable() override;
162 * @copydoc Dali::Internal::Adaptor::PixmapRenderSurface::Initialize()
164 void UseExistingRenderable(unsigned int surfaceId) override;
168 * Get the surface id if the surface parameter is not empty
169 * @param surface Any containing a surface id, or can be empty
170 * @return surface id, or zero if surface is empty
172 unsigned int GetSurfaceId(Any surface) const;
175 static const int BUFFER_COUNT = 2;
176 GraphicsInterface* mGraphics; ///< Graphics interface
177 Dali::DisplayConnection* mDisplayConnection; ///< Display connection
178 PositionSize mPosition; ///< Position
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 ::Pixmap 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_WINDOW_SYSTEM_X11_PIXMAP_RENDER_SURFACE_H