File indexing completed on 2024-11-10 04:56:30
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 #include "utils/damagejournal.h" 0012 0013 #include <QMap> 0014 #include <QPointer> 0015 #include <QRegion> 0016 #include <epoxy/egl.h> 0017 #include <optional> 0018 0019 namespace KWin 0020 { 0021 0022 class EglSwapchain; 0023 class EglSwapchainSlot; 0024 class GraphicsBuffer; 0025 class GLTexture; 0026 class EglGbmBackend; 0027 class DrmVirtualOutput; 0028 class GLRenderTimeQuery; 0029 class SurfaceInterface; 0030 0031 class VirtualEglGbmLayer : public DrmOutputLayer 0032 { 0033 public: 0034 VirtualEglGbmLayer(EglGbmBackend *eglBackend, DrmVirtualOutput *output); 0035 ~VirtualEglGbmLayer() override; 0036 0037 std::optional<OutputLayerBeginFrameInfo> beginFrame() override; 0038 bool endFrame(const QRegion &renderedRegion, const QRegion &damagedRegion) override; 0039 bool scanout(SurfaceItem *surfaceItem) override; 0040 0041 QRegion currentDamage() const override; 0042 std::shared_ptr<GLTexture> texture() const override; 0043 void releaseBuffers() override; 0044 std::chrono::nanoseconds queryRenderTime() const override; 0045 0046 private: 0047 std::shared_ptr<EglSwapchain> createGbmSwapchain() const; 0048 bool doesGbmSwapchainFit(EglSwapchain *swapchain) const; 0049 0050 QPointer<SurfaceInterface> m_scanoutSurface; 0051 QPointer<GraphicsBuffer> m_scanoutBuffer; 0052 DamageJournal m_damageJournal; 0053 DamageJournal m_oldDamageJournal; 0054 QRegion m_currentDamage; 0055 std::shared_ptr<EglSwapchain> m_gbmSwapchain; 0056 std::shared_ptr<EglSwapchain> m_oldGbmSwapchain; 0057 std::shared_ptr<EglSwapchainSlot> m_currentSlot; 0058 std::unique_ptr<GLRenderTimeQuery> m_query; 0059 0060 DrmVirtualOutput *const m_output; 0061 EglGbmBackend *const m_eglBackend; 0062 }; 0063 0064 }