/* KWin - the KDE window manager This file is part of the KDE project. SPDX-FileCopyrightText: 2021 Xaver Hugl SPDX-License-Identifier: GPL-2.0-or-later */ #pragma once #include #include #include #include #include #include "drm_object_plane.h" #include "renderloop_p.h" #include "abstract_wayland_output.h" namespace KWin { class DrmGpu; class DrmConnector; class DrmCrtc; class DrmBuffer; class DrmDumbBuffer; class GammaRamp; class DrmPipeline { public: DrmPipeline(DrmGpu *gpu, DrmConnector *conn, DrmCrtc *crtc, DrmPlane *primaryPlane); ~DrmPipeline(); /** * Sets the necessary initial drm properties for the pipeline to work */ void setup(); /** * tests the pending commit first and commits it if the test passes * if the test fails, there is a guarantee for no lasting changes */ bool present(const QSharedPointer &buffer); bool modeset(int modeIndex); bool setCursor(const QSharedPointer &buffer, const QPoint &hotspot = QPoint()); bool setActive(bool enable); bool setGammaRamp(const GammaRamp &ramp); bool setTransformation(const DrmPlane::Transformations &transform); bool moveCursor(QPoint pos); bool setSyncMode(RenderLoopPrivate::SyncMode syncMode); bool setOverscan(uint32_t overscan); bool setRgbRange(AbstractWaylandOutput::RgbRange rgbRange); DrmPlane::Transformations transformation() const; bool isActive() const; bool isCursorVisible() const; QPoint cursorPos() const; DrmConnector *connector() const; DrmCrtc *crtc() const; DrmPlane *primaryPlane() const; void pageFlipped(); void printDebugInfo() const; QSize sourceSize() const; void updateProperties(); bool isFormatSupported(uint32_t drmFormat) const; QVector supportedModifiers(uint32_t drmFormat) const; void setOutput(DrmOutput *output); DrmOutput *output() const; enum class CommitMode { Test, Commit, CommitWithPageflipEvent }; Q_ENUM(CommitMode); static bool commitPipelines(const QVector &pipelines, CommitMode mode); private: bool populateAtomicValues(drmModeAtomicReq *req, uint32_t &flags); bool test(); bool atomicCommit(); bool presentLegacy(); bool checkTestBuffer(); bool setPendingTransformation(const DrmPlane::Transformations &transformation); DrmOutput *m_output = nullptr; DrmGpu *m_gpu = nullptr; DrmConnector *m_connector = nullptr; DrmCrtc *m_crtc = nullptr; DrmPlane *m_primaryPlane = nullptr; QSharedPointer m_primaryBuffer; QSharedPointer m_oldTestBuffer; bool m_legacyNeedsModeset = true; struct { QPoint pos; QPoint hotspot; QSharedPointer buffer; bool dirtyBo = true; bool dirtyPos = true; } m_cursor; QVector m_allObjects; QMap> m_formats; int m_lastFlags = 0; }; }