File indexing completed on 2025-04-20 10:57:37
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #pragma once 0010 #include "drm_layer.h" 0011 0012 #include <QMap> 0013 #include <QPointer> 0014 #include <QRegion> 0015 #include <epoxy/egl.h> 0016 #include <optional> 0017 0018 namespace KWaylandServer 0019 { 0020 class SurfaceInterface; 0021 } 0022 0023 namespace KWin 0024 { 0025 0026 class GbmSurface; 0027 class GLTexture; 0028 class EglGbmBackend; 0029 class GbmBuffer; 0030 class DrmVirtualOutput; 0031 0032 class VirtualEglGbmLayer : public DrmOutputLayer 0033 { 0034 public: 0035 VirtualEglGbmLayer(EglGbmBackend *eglBackend, DrmVirtualOutput *output); 0036 0037 void aboutToStartPainting(const QRegion &damagedRegion) override; 0038 std::optional<OutputLayerBeginFrameInfo> beginFrame() override; 0039 bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; 0040 bool scanout(SurfaceItem *surfaceItem) override; 0041 0042 QRegion currentDamage() const override; 0043 std::shared_ptr<GLTexture> texture() const override; 0044 void releaseBuffers() override; 0045 0046 private: 0047 bool createGbmSurface(); 0048 bool doesGbmSurfaceFit(GbmSurface *surf) const; 0049 0050 QPointer<KWaylandServer::SurfaceInterface> m_scanoutSurface; 0051 std::shared_ptr<GbmBuffer> m_currentBuffer; 0052 QRegion m_currentDamage; 0053 std::shared_ptr<GbmSurface> m_gbmSurface; 0054 std::shared_ptr<GbmSurface> m_oldGbmSurface; 0055 0056 DrmVirtualOutput *const m_output; 0057 EglGbmBackend *const m_eglBackend; 0058 }; 0059 0060 }