File indexing completed on 2024-11-10 04:56:56
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 SPDX-FileCopyrightText: 2023 Vlad Zahorodnii <vlad.zahorodnii@kde.org> 0007 0008 SPDX-License-Identifier: GPL-2.0-or-later 0009 */ 0010 0011 #pragma once 0012 0013 #include "kwin_export.h" 0014 0015 #include <QImage> 0016 #include <QList> 0017 #include <QSize> 0018 0019 #include <memory> 0020 0021 namespace KWin 0022 { 0023 0024 class GraphicsBuffer; 0025 class GraphicsBufferAllocator; 0026 class GraphicsBufferView; 0027 0028 class KWIN_EXPORT QPainterSwapchainSlot 0029 { 0030 public: 0031 QPainterSwapchainSlot(GraphicsBuffer *buffer); 0032 ~QPainterSwapchainSlot(); 0033 0034 GraphicsBuffer *buffer() const; 0035 GraphicsBufferView *view() const; 0036 int age() const; 0037 0038 private: 0039 GraphicsBuffer *m_buffer; 0040 std::unique_ptr<GraphicsBufferView> m_view; 0041 int m_age = 0; 0042 friend class QPainterSwapchain; 0043 }; 0044 0045 class KWIN_EXPORT QPainterSwapchain 0046 { 0047 public: 0048 QPainterSwapchain(GraphicsBufferAllocator *allocator, const QSize &size, uint32_t format); 0049 ~QPainterSwapchain(); 0050 0051 QSize size() const; 0052 uint32_t format() const; 0053 0054 std::shared_ptr<QPainterSwapchainSlot> acquire(); 0055 void release(std::shared_ptr<QPainterSwapchainSlot> slot); 0056 0057 private: 0058 GraphicsBufferAllocator *m_allocator; 0059 QList<std::shared_ptr<QPainterSwapchainSlot>> m_slots; 0060 QSize m_size; 0061 uint32_t m_format; 0062 }; 0063 0064 }