[drm] Code cleanup in DrmOutput class
Summary: Removes unneeded includes and reorders the code in a sensible way. Reviewers: #kwin Subscribers: davidedmundson, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D16792
This commit is contained in:
parent
93f78c2d23
commit
0af57d6366
1 changed files with 67 additions and 72 deletions
|
@ -33,12 +33,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "screens_drm.h"
|
||||
#include "wayland_server.h"
|
||||
// KWayland
|
||||
#include <KWayland/Server/display.h>
|
||||
#include <KWayland/Server/output_interface.h>
|
||||
#include <KWayland/Server/outputchangeset.h>
|
||||
#include <KWayland/Server/outputmanagement_interface.h>
|
||||
#include <KWayland/Server/outputconfiguration_interface.h>
|
||||
#include <KWayland/Server/xdgoutput_interface.h>
|
||||
// KF5
|
||||
#include <KConfigGroup>
|
||||
#include <KLocalizedString>
|
||||
|
@ -177,49 +172,6 @@ void DrmOutput::moveCursor(const QPoint &globalPos)
|
|||
drmModeMoveCursor(m_backend->fd(), m_crtc->id(), p.x(), p.y());
|
||||
}
|
||||
|
||||
QSize DrmOutput::pixelSize() const
|
||||
{
|
||||
auto orient = orientation();
|
||||
if (orient == Qt::PortraitOrientation || orient == Qt::InvertedPortraitOrientation) {
|
||||
return QSize(m_mode.vdisplay, m_mode.hdisplay);
|
||||
}
|
||||
return QSize(m_mode.hdisplay, m_mode.vdisplay);
|
||||
}
|
||||
|
||||
static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode)
|
||||
{
|
||||
using namespace KWayland::Server;
|
||||
switch (mode) {
|
||||
case DrmOutput::DpmsMode::On:
|
||||
return OutputInterface::DpmsMode::On;
|
||||
case DrmOutput::DpmsMode::Standby:
|
||||
return OutputInterface::DpmsMode::Standby;
|
||||
case DrmOutput::DpmsMode::Suspend:
|
||||
return OutputInterface::DpmsMode::Suspend;
|
||||
case DrmOutput::DpmsMode::Off:
|
||||
return OutputInterface::DpmsMode::Off;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
static DrmOutput::DpmsMode fromWaylandDpmsMode(KWayland::Server::OutputInterface::DpmsMode wlMode)
|
||||
{
|
||||
using namespace KWayland::Server;
|
||||
switch (wlMode) {
|
||||
case OutputInterface::DpmsMode::On:
|
||||
return DrmOutput::DpmsMode::On;
|
||||
case OutputInterface::DpmsMode::Standby:
|
||||
return DrmOutput::DpmsMode::Standby;
|
||||
case OutputInterface::DpmsMode::Suspend:
|
||||
return DrmOutput::DpmsMode::Suspend;
|
||||
case OutputInterface::DpmsMode::Off:
|
||||
return DrmOutput::DpmsMode::Off;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
static QHash<int, QByteArray> s_connectorNames = {
|
||||
{DRM_MODE_CONNECTOR_Unknown, QByteArrayLiteral("Unknown")},
|
||||
{DRM_MODE_CONNECTOR_VGA, QByteArrayLiteral("VGA")},
|
||||
|
@ -596,6 +548,21 @@ bool DrmOutput::initCursorPlane() // TODO: Add call in init (but needs lay
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DrmOutput::initCursor(const QSize &cursorSize)
|
||||
{
|
||||
auto createCursor = [this, cursorSize] (int index) {
|
||||
m_cursor[index] = m_backend->createBuffer(cursorSize);
|
||||
if (!m_cursor[index]->map(QImage::Format_ARGB32_Premultiplied)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (!createCursor(0) || !createCursor(1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void DrmOutput::initDpms(drmModeConnector *connector)
|
||||
{
|
||||
for (int i = 0; i < connector->count_props; ++i) {
|
||||
|
@ -610,6 +577,40 @@ void DrmOutput::initDpms(drmModeConnector *connector)
|
|||
}
|
||||
}
|
||||
|
||||
static DrmOutput::DpmsMode fromWaylandDpmsMode(KWayland::Server::OutputInterface::DpmsMode wlMode)
|
||||
{
|
||||
using namespace KWayland::Server;
|
||||
switch (wlMode) {
|
||||
case OutputInterface::DpmsMode::On:
|
||||
return DrmOutput::DpmsMode::On;
|
||||
case OutputInterface::DpmsMode::Standby:
|
||||
return DrmOutput::DpmsMode::Standby;
|
||||
case OutputInterface::DpmsMode::Suspend:
|
||||
return DrmOutput::DpmsMode::Suspend;
|
||||
case OutputInterface::DpmsMode::Off:
|
||||
return DrmOutput::DpmsMode::Off;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode)
|
||||
{
|
||||
using namespace KWayland::Server;
|
||||
switch (mode) {
|
||||
case DrmOutput::DpmsMode::On:
|
||||
return OutputInterface::DpmsMode::On;
|
||||
case DrmOutput::DpmsMode::Standby:
|
||||
return OutputInterface::DpmsMode::Standby;
|
||||
case DrmOutput::DpmsMode::Suspend:
|
||||
return OutputInterface::DpmsMode::Suspend;
|
||||
case DrmOutput::DpmsMode::Off:
|
||||
return OutputInterface::DpmsMode::Off;
|
||||
default:
|
||||
Q_UNREACHABLE();
|
||||
}
|
||||
}
|
||||
|
||||
void DrmOutput::updateDpms(KWayland::Server::OutputInterface::DpmsMode mode)
|
||||
{
|
||||
if (m_dpms.isNull()) {
|
||||
|
@ -685,15 +686,6 @@ void DrmOutput::dpmsOffHandler()
|
|||
m_backend->outputWentOff();
|
||||
}
|
||||
|
||||
int DrmOutput::currentRefreshRate() const
|
||||
{
|
||||
auto wlOutput = waylandOutput();
|
||||
if (!wlOutput) {
|
||||
return 60000;
|
||||
}
|
||||
return wlOutput->refreshRate();
|
||||
}
|
||||
|
||||
void DrmOutput::transform(KWayland::Server::OutputDeviceInterface::Transform transform)
|
||||
{
|
||||
waylandOutputDevice()->setTransform(transform);
|
||||
|
@ -789,6 +781,24 @@ void DrmOutput::updateMode(int modeIndex)
|
|||
setWaylandMode();
|
||||
}
|
||||
|
||||
int DrmOutput::currentRefreshRate() const
|
||||
{
|
||||
auto wlOutput = waylandOutput();
|
||||
if (!wlOutput) {
|
||||
return 60000;
|
||||
}
|
||||
return wlOutput->refreshRate();
|
||||
}
|
||||
|
||||
QSize DrmOutput::pixelSize() const
|
||||
{
|
||||
auto orient = orientation();
|
||||
if (orient == Qt::PortraitOrientation || orient == Qt::InvertedPortraitOrientation) {
|
||||
return QSize(m_mode.vdisplay, m_mode.hdisplay);
|
||||
}
|
||||
return QSize(m_mode.hdisplay, m_mode.vdisplay);
|
||||
}
|
||||
|
||||
void DrmOutput::setWaylandMode()
|
||||
{
|
||||
AbstractOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay),
|
||||
|
@ -1106,21 +1116,6 @@ bool DrmOutput::atomicReqModesetPopulate(drmModeAtomicReq *req, bool enable)
|
|||
return ret;
|
||||
}
|
||||
|
||||
bool DrmOutput::initCursor(const QSize &cursorSize)
|
||||
{
|
||||
auto createCursor = [this, cursorSize] (int index) {
|
||||
m_cursor[index] = m_backend->createBuffer(cursorSize);
|
||||
if (!m_cursor[index]->map(QImage::Format_ARGB32_Premultiplied)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
};
|
||||
if (!createCursor(0) || !createCursor(1)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
bool DrmOutput::supportsTransformations() const
|
||||
{
|
||||
if (!m_primaryPlane) {
|
||||
|
|
Loading…
Reference in a new issue