File indexing completed on 2024-05-19 05:31:53
0001 /* 0002 KWin - the KDE window manager 0003 This file is part of the KDE project. 0004 0005 SPDX-FileCopyrightText: 2017 Martin Flöser <mgraesslin@kde.org> 0006 0007 SPDX-License-Identifier: GPL-2.0-or-later 0008 */ 0009 #pragma once 0010 0011 #include "kwin_export.h" 0012 0013 #include <QList> 0014 #include <QSize> 0015 0016 #include <cstdint> 0017 #include <epoxy/egl.h> 0018 #include <memory> 0019 0020 namespace KWin 0021 { 0022 0023 class GraphicsBufferAllocator; 0024 class GraphicsBuffer; 0025 class GLFramebuffer; 0026 class GLTexture; 0027 class EglContext; 0028 0029 class KWIN_EXPORT EglSwapchainSlot 0030 { 0031 public: 0032 EglSwapchainSlot(GraphicsBuffer *buffer, std::unique_ptr<GLFramebuffer> &&framebuffer, const std::shared_ptr<GLTexture> &texture); 0033 ~EglSwapchainSlot(); 0034 0035 GraphicsBuffer *buffer() const; 0036 std::shared_ptr<GLTexture> texture() const; 0037 GLFramebuffer *framebuffer() const; 0038 int age() const; 0039 0040 static std::shared_ptr<EglSwapchainSlot> create(EglContext *context, GraphicsBuffer *buffer); 0041 0042 private: 0043 GraphicsBuffer *m_buffer; 0044 std::unique_ptr<GLFramebuffer> m_framebuffer; 0045 std::shared_ptr<GLTexture> m_texture; 0046 int m_age = 0; 0047 friend class EglSwapchain; 0048 }; 0049 0050 class KWIN_EXPORT EglSwapchain 0051 { 0052 public: 0053 EglSwapchain(GraphicsBufferAllocator *allocator, EglContext *context, const QSize &size, uint32_t format, uint64_t modifier, const std::shared_ptr<EglSwapchainSlot> &seed); 0054 ~EglSwapchain(); 0055 0056 QSize size() const; 0057 uint32_t format() const; 0058 uint64_t modifier() const; 0059 0060 std::shared_ptr<EglSwapchainSlot> acquire(); 0061 void release(std::shared_ptr<EglSwapchainSlot> slot); 0062 0063 static std::shared_ptr<EglSwapchain> create(GraphicsBufferAllocator *allocator, EglContext *context, const QSize &size, uint32_t format, const QList<uint64_t> &modifiers); 0064 0065 private: 0066 GraphicsBufferAllocator *m_allocator; 0067 EglContext *m_context; 0068 QSize m_size; 0069 uint32_t m_format; 0070 uint64_t m_modifier; 0071 QList<std::shared_ptr<EglSwapchainSlot>> m_slots; 0072 }; 0073 0074 } // namespace KWin