File indexing completed on 2024-06-23 05:25:14

0001 /*
0002     KWin - the KDE window manager
0003     This file is part of the KDE project.
0004 
0005     SPDX-FileCopyrightText: 2016 Roman Gilg <subdiff@gmail.com>
0006     SPDX-FileCopyrightText: 2022 Xaver Hugl <xaver.hugl@gmail.com>
0007 
0008     SPDX-License-Identifier: GPL-2.0-or-later
0009 */
0010 #pragma once
0011 
0012 #include "drm_object.h"
0013 
0014 #include <QMap>
0015 #include <QPoint>
0016 #include <QSize>
0017 #include <memory>
0018 #include <qobjectdefs.h>
0019 
0020 namespace KWin
0021 {
0022 
0023 class DrmFramebuffer;
0024 class DrmCrtc;
0025 
0026 class DrmPlane : public DrmObject
0027 {
0028     Q_GADGET
0029 public:
0030     DrmPlane(DrmGpu *gpu, uint32_t planeId);
0031 
0032     bool updateProperties() override;
0033     void disable(DrmAtomicCommit *commit) override;
0034 
0035     bool isCrtcSupported(int pipeIndex) const;
0036     QMap<uint32_t, QList<uint64_t>> formats() const;
0037 
0038     std::shared_ptr<DrmFramebuffer> currentBuffer() const;
0039     void setCurrentBuffer(const std::shared_ptr<DrmFramebuffer> &b);
0040     void releaseCurrentBuffer();
0041 
0042     void set(DrmAtomicCommit *commit, const QPoint &srcPos, const QSize &srcSize, const QRect &dst);
0043 
0044     enum class TypeIndex : uint64_t {
0045         Overlay = 0,
0046         Primary = 1,
0047         Cursor = 2
0048     };
0049     enum class Transformation : uint32_t {
0050         Rotate0 = 1 << 0,
0051         Rotate90 = 1 << 1,
0052         Rotate180 = 1 << 2,
0053         Rotate270 = 1 << 3,
0054         ReflectX = 1 << 4,
0055         ReflectY = 1 << 5
0056     };
0057     Q_ENUM(Transformation)
0058     Q_DECLARE_FLAGS(Transformations, Transformation)
0059     enum class PixelBlendMode : uint64_t {
0060         None,
0061         PreMultiplied,
0062         Coverage
0063     };
0064     enum class ColorEncoding : uint64_t {
0065         BT601_YCbCr,
0066         BT709_YCbCr,
0067         BT2020_YCbCr
0068     };
0069     enum class ColorRange : uint64_t {
0070         Limited_YCbCr,
0071         Full_YCbCr
0072     };
0073 
0074     DrmEnumProperty<TypeIndex> type;
0075     DrmProperty srcX;
0076     DrmProperty srcY;
0077     DrmProperty srcW;
0078     DrmProperty srcH;
0079     DrmProperty crtcX;
0080     DrmProperty crtcY;
0081     DrmProperty crtcW;
0082     DrmProperty crtcH;
0083     DrmProperty fbId;
0084     DrmProperty crtcId;
0085     DrmEnumProperty<Transformations> rotation;
0086     DrmProperty inFormats;
0087     DrmProperty alpha;
0088     DrmEnumProperty<PixelBlendMode> pixelBlendMode;
0089     DrmEnumProperty<ColorEncoding> colorEncoding;
0090     DrmEnumProperty<ColorRange> colorRange;
0091     DrmProperty vmHotspotX;
0092     DrmProperty vmHotspotY;
0093     DrmProperty inFenceFd;
0094 
0095     static int32_t transformationToDegrees(Transformations transformation);
0096 
0097 private:
0098     std::shared_ptr<DrmFramebuffer> m_current;
0099 
0100     QMap<uint32_t, QList<uint64_t>> m_supportedFormats;
0101     uint32_t m_possibleCrtcs;
0102 };
0103 
0104 }
0105 
0106 Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::DrmPlane::Transformations)