File indexing completed on 2025-04-20 10:57:33

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2021 Xaver Hugl <xaver.hugl@gmail.com>
0006 
0007     SPDX-License-Identifier: GPL-2.0-or-later
0008 */
0009 
0010 #pragma once
0011 
0012 #include "utils/damagejournal.h"
0013 
0014 #include <QImage>
0015 #include <QSize>
0016 #include <QVector>
0017 #include <memory>
0018 
0019 namespace KWin
0020 {
0021 
0022 class DrmDumbBuffer;
0023 class DrmGpu;
0024 
0025 class DumbSwapchain
0026 {
0027 public:
0028     DumbSwapchain(DrmGpu *gpu, const QSize &size, uint32_t drmFormat);
0029 
0030     std::shared_ptr<DrmDumbBuffer> acquireBuffer(QRegion *needsRepaint = nullptr);
0031     std::shared_ptr<DrmDumbBuffer> currentBuffer() const;
0032     void releaseBuffer(const std::shared_ptr<DrmDumbBuffer> &buffer, const QRegion &damage = {});
0033 
0034     qsizetype slotCount() const;
0035     QSize size() const;
0036     bool isEmpty() const;
0037     uint32_t drmFormat() const;
0038 
0039 private:
0040     struct Slot
0041     {
0042         std::shared_ptr<DrmDumbBuffer> buffer;
0043         int age = 0;
0044     };
0045 
0046     QSize m_size;
0047     int index = 0;
0048     uint32_t m_format;
0049     QVector<Slot> m_slots;
0050     DamageJournal m_damageJournal;
0051 };
0052 
0053 }