/* KWin - the KDE window manager This file is part of the KDE project. SPDX-FileCopyrightText: 2019 Roman Gilg SPDX-FileCopyrightText: 2013, 2015 Martin Gräßlin SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include "core/outputlayer.h" #include "platformsupport/scenes/qpainter/qpainterbackend.h" #include "utils/damagejournal.h" #include #include #include namespace KWin { class Output; class GraphicsBufferAllocator; class QPainterSwapchainSlot; class QPainterSwapchain; namespace Wayland { class WaylandBackend; class WaylandDisplay; class WaylandOutput; class WaylandQPainterBackend; class WaylandQPainterPrimaryLayer : public OutputLayer { public: WaylandQPainterPrimaryLayer(WaylandOutput *output, WaylandQPainterBackend *backend); ~WaylandQPainterPrimaryLayer() override; std::optional doBeginFrame() override; bool doEndFrame(const QRegion &renderedRegion, const QRegion &damagedRegion, OutputFrame *frame) override; DrmDevice *scanoutDevice() const override; QHash> supportedDrmFormats() const override; void present(); QRegion accumulateDamage(int bufferAge) const; private: WaylandOutput *m_waylandOutput; WaylandQPainterBackend *m_backend; DamageJournal m_damageJournal; std::unique_ptr m_swapchain; std::shared_ptr m_back; std::unique_ptr m_renderTime; friend class WaylandQPainterBackend; }; class WaylandQPainterCursorLayer : public OutputLayer { Q_OBJECT public: WaylandQPainterCursorLayer(WaylandOutput *output, WaylandQPainterBackend *backend); ~WaylandQPainterCursorLayer() override; std::optional doBeginFrame() override; bool doEndFrame(const QRegion &renderedRegion, const QRegion &damagedRegion, OutputFrame *frame) override; DrmDevice *scanoutDevice() const override; QHash> supportedDrmFormats() const override; private: WaylandQPainterBackend *m_backend; std::unique_ptr m_swapchain; std::shared_ptr m_back; std::unique_ptr m_renderTime; }; class WaylandQPainterBackend : public QPainterBackend { Q_OBJECT public: explicit WaylandQPainterBackend(WaylandBackend *b); ~WaylandQPainterBackend() override; GraphicsBufferAllocator *graphicsBufferAllocator() const; bool present(Output *output, const std::shared_ptr &frame) override; OutputLayer *primaryLayer(Output *output) override; OutputLayer *cursorLayer(Output *output) override; private: void createOutput(Output *waylandOutput); struct Layers { std::unique_ptr primaryLayer; std::unique_ptr cursorLayer; }; WaylandBackend *m_backend; std::unique_ptr m_allocator; std::map m_outputs; }; } // namespace Wayland } // namespace KWin