Commit 3dc22d7d authored by David Edmundson's avatar David Edmundson

[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
parent d6f98d1e
......@@ -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;
}
......
......@@ -27,6 +27,8 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
#include "wayland_server.h"
// KWayland
#include <KWayland/Server/output_interface.h>
// KDE
#include <KConfigGroup>
// Qt
#include <QKeyEvent>
#include <QDBusConnection>
......@@ -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);
}
......
......@@ -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 {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment