From 3dc22d7d8882b1035abf1140e92778611c835bfb Mon Sep 17 00:00:00 2001 From: David Edmundson Date: Fri, 22 Feb 2019 00:44:12 +0000 Subject: [PATCH] [platforms/hwcomposer] Add scaling support Summary: Despite plasma frameworks doing it's own scaling with fonts, it's been requested to use kwin/wayland scaling. Like DRM, when kscreen is not used, scale value is loaded from a config file. Config format is [HWComposerOutputs][0] Scale=N The 0 is to map similarly to DRM and support multi-screen, but with a screen index rather than a UUID based on EDID. Because we don't support multi screen this is always 0 for now. Test Plan: Ran with the config value unset and with the config value at Scale=3. Reviewers: #kwin, romangg Reviewed By: #kwin, romangg Subscribers: bshah, romangg, nicolasfella, zzag, kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D18810 --- .../hwcomposer/egl_hwcomposer_backend.cpp | 4 ++++ .../hwcomposer/hwcomposer_backend.cpp | 23 ++++++++++++++++++- .../platforms/hwcomposer/hwcomposer_backend.h | 6 ++--- 3 files changed, 29 insertions(+), 4 deletions(-) diff --git a/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp b/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp index 3c96db1185..5207545bdb 100644 --- a/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp +++ b/plugins/platforms/hwcomposer/egl_hwcomposer_backend.cpp @@ -130,6 +130,10 @@ bool EglHwcomposerBackend::makeContextCurrent() qCWarning(KWIN_HWCOMPOSER) << "Error occurred while creating context " << error; return false; } + + const QSize overall = m_backend->size(); + glViewport(0, 0, overall.width(), overall.height()); + return true; } diff --git a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp index 651d1e5756..da1ca11bdd 100644 --- a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp +++ b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp @@ -27,6 +27,8 @@ along with this program. If not, see . #include "wayland_server.h" // KWayland #include +// KDE +#include // Qt #include #include @@ -253,7 +255,7 @@ void HwcomposerBackend::init() setReady(true); } -QSize HwcomposerBackend::screenSize() const +QSize HwcomposerBackend::size() const { if (m_output) { return m_output->pixelSize(); @@ -261,6 +263,22 @@ QSize HwcomposerBackend::screenSize() const return QSize(); } +QSize HwcomposerBackend::screenSize() const +{ + if (m_output) { + return m_output->pixelSize() / m_output->scale(); + } + return QSize(); +} + +int HwcomposerBackend::scale() const + { + if (m_output) { + return m_output->scale(); + } + return 1; +} + void HwcomposerBackend::initLights() { hw_module_t *lightsModule = nullptr; @@ -510,6 +528,9 @@ HwcomposerOutput::HwcomposerOutput(hwc_composer_device_1_t *device) setInternal(true); setEnabled(true); setDpmsSupported(true); + + const auto outputGroup = kwinApp()->config()->group("HWComposerOutputs").group("0"); + setScale(outputGroup.readEntry("Scale", 1)); setWaylandMode(m_pixelSize, mode.refreshRate); } diff --git a/plugins/platforms/hwcomposer/hwcomposer_backend.h b/plugins/platforms/hwcomposer/hwcomposer_backend.h index 32d3dd7fc9..35fbfb7af2 100644 --- a/plugins/platforms/hwcomposer/hwcomposer_backend.h +++ b/plugins/platforms/hwcomposer/hwcomposer_backend.h @@ -80,11 +80,11 @@ public: Outputs outputs() const override; Outputs enabledOutputs() const override; - QSize size() const { - return screenSize(); - } + QSize size() const; QSize screenSize() const override; + int scale() const; + HwcomposerWindow *createSurface(); hwc_composer_device_1_t *device() const {