aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Edmundson <[email protected]>2016-11-14 18:30:29 +0000
committerDavid Edmundson <[email protected]>2017-03-29 20:53:22 +0100
commit0dac5d6bfe8c6eab58f315fc0219646c3acc59d6 (patch)
tree50735438becb85672f2cc6fefafd3307ecf9665a
parent584dc1d2d4ae356094d63482e8243a40a282188e (diff)
Add scaling to DRM backend
Test Plan: For the first time, actually plugged in my high DPI laptop. Tested both 1x and 2x windows on 2 real displays one high DPI, one normal Reviewers: #plasma Subscribers: plasma-devel, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D3498
-rw-r--r--plugins/platforms/drm/drm_backend.cpp3
-rw-r--r--plugins/platforms/drm/drm_output.cpp26
-rw-r--r--plugins/platforms/drm/drm_output.h10
-rw-r--r--plugins/platforms/drm/scene_qpainter_drm_backend.cpp2
-rw-r--r--plugins/platforms/drm/screens_drm.cpp11
-rw-r--r--plugins/platforms/drm/screens_drm.h1
6 files changed, 44 insertions, 9 deletions
diff --git a/plugins/platforms/drm/drm_backend.cpp b/plugins/platforms/drm/drm_backend.cpp
index bb6b821..0fc8fef 100644
--- a/plugins/platforms/drm/drm_backend.cpp
+++ b/plugins/platforms/drm/drm_backend.cpp
@@ -443,7 +443,8 @@ void DrmBackend::readOutputsConfiguration()
const auto outputConfig = configGroup.group((*it)->uuid());
(*it)->setGlobalPos(outputConfig.readEntry<QPoint>("Position", pos));
// TODO: add mode
- pos.setX(pos.x() + (*it)->size().width());
+ (*it)->setScale(outputConfig.readEntry("Scale", 1.0));
+ pos.setX(pos.x() + (*it)->geometry().width());
}
}
diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp
index 8e9fc92..937e02b 100644
--- a/plugins/platforms/drm/drm_output.cpp
+++ b/plugins/platforms/drm/drm_output.cpp
@@ -112,16 +112,22 @@ void DrmOutput::moveCursor(const QPoint &globalPos)
drmModeMoveCursor(m_backend->fd(), m_crtcId, p.x(), p.y());
}
-QSize DrmOutput::size() const
+QSize DrmOutput::pixelSize() const
{
return QSize(m_mode.hdisplay, m_mode.vdisplay);
}
QRect DrmOutput::geometry() const
{
- return QRect(m_globalPos, size());
+ return QRect(m_globalPos, pixelSize() / scale());
}
+qreal DrmOutput::scale() const
+{
+ return m_scale;
+}
+
+
static KWayland::Server::OutputInterface::DpmsMode toWaylandDpmsMode(DrmOutput::DpmsMode mode)
{
using namespace KWayland::Server;
@@ -633,6 +639,17 @@ void DrmOutput::setGlobalPos(const QPoint &pos)
}
}
+void DrmOutput::setScale(qreal scale)
+{
+ m_scale = scale;
+ if (m_waylandOutput) {
+ m_waylandOutput->setScale(scale);
+ }
+ if (m_waylandOutputDevice) {
+ m_waylandOutputDevice->setScale(scale);
+ }
+}
+
void DrmOutput::setChanges(KWayland::Server::OutputChangeSet *changes)
{
m_changeset = changes;
@@ -674,8 +691,7 @@ bool DrmOutput::commitChanges()
}
if (m_changeset->scaleChanged()) {
qCDebug(KWIN_DRM) << "Setting scale:" << m_changeset->scale();
- m_waylandOutputDevice->setScale(m_changeset->scale());
- // FIXME: implement for wl_output
+ setScale(m_changeset->scale());
}
return true;
}
@@ -723,7 +739,7 @@ void DrmOutput::cleanupBlackBuffer()
bool DrmOutput::blank()
{
if (!m_blackBuffer) {
- m_blackBuffer = m_backend->createBuffer(size());
+ m_blackBuffer = m_backend->createBuffer(pixelSize());
if (!m_blackBuffer->map()) {
cleanupBlackBuffer();
return false;
diff --git a/plugins/platforms/drm/drm_output.h b/plugins/platforms/drm/drm_output.h
index 20a9f66..064ca21 100644
--- a/plugins/platforms/drm/drm_output.h
+++ b/plugins/platforms/drm/drm_output.h
@@ -77,8 +77,14 @@ public:
void setChanges(KWayland::Server::OutputChangeSet *changeset);
bool commitChanges();
- QSize size() const;
+ QSize pixelSize() const;
+ qreal scale() const;
+
+ /*
+ * The geometry of this output in global compositor co-ordinates (i.e scaled)
+ */
QRect geometry() const;
+
QString name() const;
int currentRefreshRate() const;
// These values are defined by the kernel
@@ -112,6 +118,7 @@ private:
bool isCurrentMode(const drmModeModeInfo *mode) const;
void initUuid();
void setGlobalPos(const QPoint &pos);
+ void setScale(qreal scale);
void pageFlippedBufferRemover(DrmBuffer *oldbuffer, DrmBuffer *newbuffer);
bool initPrimaryPlane();
@@ -120,6 +127,7 @@ private:
DrmBackend *m_backend;
QPoint m_globalPos;
+ qreal m_scale = 1;
quint32 m_crtcId = 0;
quint32 m_connector = 0;
quint32 m_lastStride = 0;
diff --git a/plugins/platforms/drm/scene_qpainter_drm_backend.cpp b/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
index ec975a3..bf5a000 100644
--- a/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
+++ b/plugins/platforms/drm/scene_qpainter_drm_backend.cpp
@@ -64,7 +64,7 @@ void DrmQPainterBackend::initOutput(DrmOutput *output)
{
Output o;
auto initBuffer = [&o, output, this] (int index) {
- o.buffer[index] = m_backend->createBuffer(output->size());
+ o.buffer[index] = m_backend->createBuffer(output->pixelSize());
o.buffer[index]->map();
o.buffer[index]->image()->fill(Qt::black);
};
diff --git a/plugins/platforms/drm/screens_drm.cpp b/plugins/platforms/drm/screens_drm.cpp
index 8714bf0..17c6155 100644
--- a/plugins/platforms/drm/screens_drm.cpp
+++ b/plugins/platforms/drm/screens_drm.cpp
@@ -50,13 +50,22 @@ QRect DrmScreens::geometry(int screen) const
return outputs.at(screen)->geometry();
}
+qreal DrmScreens::scale(int screen) const
+{
+ const auto outputs = m_backend->outputs();
+ if (screen >= outputs.size()) {
+ return 1;
+ }
+ return outputs.at(screen)->scale();
+}
+
QSize DrmScreens::size(int screen) const
{
const auto outputs = m_backend->outputs();
if (screen >= outputs.size()) {
return QSize();
}
- return outputs.at(screen)->size();
+ return outputs.at(screen)->geometry().size();
}
void DrmScreens::updateCount()
diff --git a/plugins/platforms/drm/screens_drm.h b/plugins/platforms/drm/screens_drm.h
index 0cd2b3d..9418e74 100644
--- a/plugins/platforms/drm/screens_drm.h
+++ b/plugins/platforms/drm/screens_drm.h
@@ -34,6 +34,7 @@ public:
void init() override;
QRect geometry(int screen) const override;
int number(const QPoint &pos) const override;
+ qreal scale(int screen) const override;
QSize size(int screen) const override;
void updateCount() override;
QString name(int screen) const override;