File indexing completed on 2025-04-20 10:57:36
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 enum class PropertyIndex : uint32_t { 0033 Type = 0, 0034 SrcX, 0035 SrcY, 0036 SrcW, 0037 SrcH, 0038 CrtcX, 0039 CrtcY, 0040 CrtcW, 0041 CrtcH, 0042 FbId, 0043 CrtcId, 0044 Rotation, 0045 In_Formats, 0046 Count 0047 }; 0048 Q_ENUM(PropertyIndex) 0049 0050 enum class TypeIndex : uint32_t { 0051 Overlay = 0, 0052 Primary, 0053 Cursor, 0054 Count 0055 }; 0056 Q_ENUM(TypeIndex) 0057 0058 enum class Transformation : uint32_t { 0059 Rotate0 = 1 << 0, 0060 Rotate90 = 1 << 1, 0061 Rotate180 = 1 << 2, 0062 Rotate270 = 1 << 3, 0063 ReflectX = 1 << 4, 0064 ReflectY = 1 << 5 0065 }; 0066 Q_ENUM(Transformation) 0067 Q_DECLARE_FLAGS(Transformations, Transformation) 0068 0069 bool init() override; 0070 void disable() override; 0071 TypeIndex type() const; 0072 0073 bool isCrtcSupported(int pipeIndex) const; 0074 QMap<uint32_t, QVector<uint64_t>> formats() const; 0075 0076 std::shared_ptr<DrmFramebuffer> current() const; 0077 std::shared_ptr<DrmFramebuffer> next() const; 0078 void setCurrent(const std::shared_ptr<DrmFramebuffer> &b); 0079 void setNext(const std::shared_ptr<DrmFramebuffer> &b); 0080 void flipBuffer(); 0081 0082 void setBuffer(DrmFramebuffer *buffer); 0083 void set(const QPoint &srcPos, const QSize &srcSize, const QRect &dst); 0084 0085 Transformations transformation(); 0086 Transformations supportedTransformations() const; 0087 0088 void releaseBuffers(); 0089 0090 private: 0091 std::shared_ptr<DrmFramebuffer> m_current; 0092 std::shared_ptr<DrmFramebuffer> m_next; 0093 0094 QMap<uint32_t, QVector<uint64_t>> m_supportedFormats; 0095 uint32_t m_possibleCrtcs; 0096 Transformations m_supportedTransformations = Transformation::Rotate0; 0097 }; 0098 0099 } 0100 0101 Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::DrmPlane::Transformations)