2020-08-02 22:22:19 +00:00
|
|
|
/*
|
|
|
|
KWin - the KDE window manager
|
|
|
|
This file is part of the KDE project.
|
2016-08-31 12:00:31 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-FileCopyrightText: 2016 Roman Gilg <subdiff@gmail.com>
|
2016-08-31 12:00:31 +00:00
|
|
|
|
2020-08-02 22:22:19 +00:00
|
|
|
SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
*/
|
2019-12-11 16:50:07 +00:00
|
|
|
#pragma once
|
2016-08-31 12:00:31 +00:00
|
|
|
|
|
|
|
#include "drm_object.h"
|
2019-12-11 16:50:07 +00:00
|
|
|
|
2020-07-26 16:37:55 +00:00
|
|
|
#include <qobjectdefs.h>
|
2016-08-31 12:00:31 +00:00
|
|
|
#include <xf86drmMode.h>
|
2021-03-22 14:46:09 +00:00
|
|
|
#include <QSharedPointer>
|
2016-08-31 12:00:31 +00:00
|
|
|
|
|
|
|
namespace KWin
|
|
|
|
{
|
|
|
|
|
|
|
|
class DrmBuffer;
|
|
|
|
|
|
|
|
class DrmPlane : public DrmObject
|
|
|
|
{
|
2020-07-26 16:37:55 +00:00
|
|
|
Q_GADGET
|
2016-08-31 12:00:31 +00:00
|
|
|
public:
|
2021-04-01 11:21:37 +00:00
|
|
|
DrmPlane(DrmGpu *gpu, uint32_t planeId);
|
2016-08-31 12:00:31 +00:00
|
|
|
|
2021-03-10 21:04:32 +00:00
|
|
|
enum class PropertyIndex : uint32_t {
|
2016-08-31 12:00:31 +00:00
|
|
|
Type = 0,
|
|
|
|
SrcX,
|
|
|
|
SrcY,
|
|
|
|
SrcW,
|
|
|
|
SrcH,
|
|
|
|
CrtcX,
|
|
|
|
CrtcY,
|
|
|
|
CrtcW,
|
|
|
|
CrtcH,
|
|
|
|
FbId,
|
|
|
|
CrtcId,
|
2017-10-31 17:08:36 +00:00
|
|
|
Rotation,
|
2016-08-31 12:00:31 +00:00
|
|
|
Count
|
|
|
|
};
|
2020-07-26 16:37:55 +00:00
|
|
|
Q_ENUM(PropertyIndex)
|
2016-08-31 12:00:31 +00:00
|
|
|
|
2021-03-10 21:04:32 +00:00
|
|
|
enum class TypeIndex : uint32_t {
|
2019-12-11 17:16:13 +00:00
|
|
|
Overlay = 0,
|
|
|
|
Primary,
|
2016-08-31 12:00:31 +00:00
|
|
|
Cursor,
|
|
|
|
Count
|
|
|
|
};
|
2020-07-26 16:37:55 +00:00
|
|
|
Q_ENUM(TypeIndex)
|
2017-10-31 17:08:36 +00:00
|
|
|
|
2021-03-10 21:04:32 +00:00
|
|
|
enum class Transformation : uint32_t {
|
2019-12-11 16:50:07 +00:00
|
|
|
Rotate0 = 1 << 0,
|
|
|
|
Rotate90 = 1 << 1,
|
|
|
|
Rotate180 = 1 << 2,
|
|
|
|
Rotate270 = 1 << 3,
|
|
|
|
ReflectX = 1 << 4,
|
|
|
|
ReflectY = 1 << 5
|
2017-10-31 17:08:36 +00:00
|
|
|
};
|
2020-07-26 16:37:55 +00:00
|
|
|
Q_ENUM(Transformation)
|
2017-10-31 17:08:36 +00:00
|
|
|
Q_DECLARE_FLAGS(Transformations, Transformation);
|
|
|
|
|
2021-01-26 20:23:44 +00:00
|
|
|
bool init() override;
|
2016-08-31 12:00:31 +00:00
|
|
|
TypeIndex type();
|
|
|
|
|
2021-04-01 11:28:18 +00:00
|
|
|
bool isCrtcSupported(int pipeIndex) const {
|
|
|
|
return (m_possibleCrtcs & (1 << pipeIndex));
|
2017-05-09 19:29:10 +00:00
|
|
|
}
|
|
|
|
QVector<uint32_t> formats() const {
|
|
|
|
return m_formats;
|
|
|
|
}
|
|
|
|
|
2021-03-22 14:46:09 +00:00
|
|
|
QSharedPointer<DrmBuffer> current() const {
|
2016-08-31 12:00:31 +00:00
|
|
|
return m_current;
|
|
|
|
}
|
2021-03-22 14:46:09 +00:00
|
|
|
QSharedPointer<DrmBuffer> next() const {
|
2016-08-31 12:00:31 +00:00
|
|
|
return m_next;
|
|
|
|
}
|
2021-03-22 14:46:09 +00:00
|
|
|
void setCurrent(const QSharedPointer<DrmBuffer> &b) {
|
2016-08-31 12:00:31 +00:00
|
|
|
m_current = b;
|
|
|
|
}
|
2021-03-22 14:46:09 +00:00
|
|
|
void setNext(const QSharedPointer<DrmBuffer> &b);
|
2017-10-31 17:08:36 +00:00
|
|
|
void setTransformation(Transformations t);
|
2017-11-01 18:21:08 +00:00
|
|
|
Transformations transformation();
|
2016-08-31 12:00:31 +00:00
|
|
|
|
2017-05-09 19:29:10 +00:00
|
|
|
void flipBuffer();
|
2016-08-31 12:00:31 +00:00
|
|
|
|
2017-11-06 16:00:15 +00:00
|
|
|
Transformations supportedTransformations() const {
|
|
|
|
return m_supportedTransformations;
|
|
|
|
}
|
|
|
|
|
2016-08-31 12:00:31 +00:00
|
|
|
private:
|
2021-03-22 14:46:09 +00:00
|
|
|
QSharedPointer<DrmBuffer> m_current;
|
|
|
|
QSharedPointer<DrmBuffer> m_next;
|
2016-08-31 12:00:31 +00:00
|
|
|
|
|
|
|
// TODO: See weston drm_output_check_plane_format for future use of these member variables
|
|
|
|
QVector<uint32_t> m_formats; // Possible formats, which can be presented on this plane
|
|
|
|
|
|
|
|
// TODO: when using overlay planes in the future: restrict possible screens / crtcs of planes
|
|
|
|
uint32_t m_possibleCrtcs;
|
2017-11-03 17:35:13 +00:00
|
|
|
|
|
|
|
Transformations m_supportedTransformations = Transformation::Rotate0;
|
2016-08-31 12:00:31 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2017-10-31 17:08:36 +00:00
|
|
|
Q_DECLARE_OPERATORS_FOR_FLAGS(KWin::DrmPlane::Transformations)
|
|
|
|
|