/* KWin - the KDE window manager This file is part of the KDE project. SPDX-FileCopyrightText: 2017 Martin Flöser SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include "kwin_export.h" #include "utils/filedescriptor.h" #include #include #include #include #include namespace KWin { class GraphicsBufferAllocator; class GraphicsBuffer; class GLFramebuffer; class GLTexture; class EglContext; class KWIN_EXPORT EglSwapchainSlot { public: EglSwapchainSlot(GraphicsBuffer *buffer, std::unique_ptr &&framebuffer, const std::shared_ptr &texture); ~EglSwapchainSlot(); GraphicsBuffer *buffer() const; std::shared_ptr texture() const; GLFramebuffer *framebuffer() const; int age() const; static std::shared_ptr create(EglContext *context, GraphicsBuffer *buffer); private: bool isBusy() const; GraphicsBuffer *m_buffer; std::unique_ptr m_framebuffer; std::shared_ptr m_texture; int m_age = 0; FileDescriptor m_releaseFd; friend class EglSwapchain; }; class KWIN_EXPORT EglSwapchain { public: EglSwapchain(GraphicsBufferAllocator *allocator, EglContext *context, const QSize &size, uint32_t format, uint64_t modifier, const std::shared_ptr &seed); ~EglSwapchain(); QSize size() const; uint32_t format() const; uint64_t modifier() const; std::shared_ptr acquire(); void release(std::shared_ptr slot, FileDescriptor &&releaseFence); static std::shared_ptr create(GraphicsBufferAllocator *allocator, EglContext *context, const QSize &size, uint32_t format, const QList &modifiers); private: GraphicsBufferAllocator *m_allocator; EglContext *m_context; QSize m_size; uint32_t m_format; uint64_t m_modifier; QList> m_slots; }; } // namespace KWin