Changeset View
Changeset View
Standalone View
Standalone View
plugins/platforms/drm/drm_output.cpp
Show First 20 Lines • Show All 47 Lines • ▼ Show 20 Line(s) | |||||
48 | #include <QMatrix4x4> | 48 | #include <QMatrix4x4> | ||
49 | #include <QCryptographicHash> | 49 | #include <QCryptographicHash> | ||
50 | #include <QPainter> | 50 | #include <QPainter> | ||
51 | // drm | 51 | // drm | ||
52 | #include <xf86drm.h> | 52 | #include <xf86drm.h> | ||
53 | #include <xf86drmMode.h> | 53 | #include <xf86drmMode.h> | ||
54 | #include <libdrm/drm_mode.h> | 54 | #include <libdrm/drm_mode.h> | ||
55 | 55 | | |||
56 | #include <cmath> | ||||
56 | 57 | | |||
57 | namespace KWin | 58 | namespace KWin | ||
58 | { | 59 | { | ||
59 | 60 | | |||
60 | DrmOutput::DrmOutput(DrmBackend *backend) | 61 | DrmOutput::DrmOutput(DrmBackend *backend) | ||
61 | : QObject() | 62 | : QObject() | ||
62 | , m_backend(backend) | 63 | , m_backend(backend) | ||
63 | { | 64 | { | ||
▲ Show 20 Lines • Show All 735 Lines • ▼ Show 20 Line(s) | 798 | if (m_xdgOutput) { | |||
799 | m_xdgOutput->done(); | 800 | m_xdgOutput->done(); | ||
800 | } | 801 | } | ||
801 | } | 802 | } | ||
802 | 803 | | |||
803 | void DrmOutput::setScale(qreal scale) | 804 | void DrmOutput::setScale(qreal scale) | ||
804 | { | 805 | { | ||
805 | m_scale = scale; | 806 | m_scale = scale; | ||
806 | if (m_waylandOutput) { | 807 | if (m_waylandOutput) { | ||
807 | m_waylandOutput->setScale(scale); | 808 | // this is the scale that clients will ideally use for their buffers | ||
809 | // this has to be an int which is fine | ||||
810 | | ||||
811 | // I don't know whether we want to round or ceil | ||||
812 | // or maybe even set this to 3 when we're scaling to 1.5 | ||||
813 | // don't treat this like it's chosen deliberately | ||||
814 | m_waylandOutput->setScale(std::ceil(scale)); | ||||
romangg: I think we want to ceil. Otherwise you might upscale the client buffers for example from 1 to 1. | |||||
Quite probably. I'd like to see it tested on your relevant device. Also a big regret from my x scaling is I think I want to allow steps of 8ths instead of 10ths. In binary they're much more nice round numbers which will always be represented correctly in a double. davidedmundson: Quite probably. I'd like to see it tested on your relevant device.
Also a big regret from my… | |||||
808 | } | 815 | } | ||
zzag: Formatting nitpick: put a whitespace between `//` and text. | |||||
809 | if (m_waylandOutputDevice) { | 816 | if (m_waylandOutputDevice) { | ||
810 | m_waylandOutputDevice->setScale(scale); | 817 | m_waylandOutputDevice->setScaleF(scale); | ||
811 | } | 818 | } | ||
812 | if (m_xdgOutput) { | 819 | if (m_xdgOutput) { | ||
813 | m_xdgOutput->setLogicalSize(pixelSize() / m_scale); | 820 | m_xdgOutput->setLogicalSize(pixelSize() / m_scale); | ||
814 | m_xdgOutput->done(); | 821 | m_xdgOutput->done(); | ||
815 | } | 822 | } | ||
816 | } | 823 | } | ||
817 | 824 | | |||
818 | void DrmOutput::setChanges(KWayland::Server::OutputChangeSet *changes) | 825 | void DrmOutput::setChanges(KWayland::Server::OutputChangeSet *changes) | ||
Show All 24 Lines | 833 | { | |||
843 | } | 850 | } | ||
844 | if (m_changeset->positionChanged()) { | 851 | if (m_changeset->positionChanged()) { | ||
845 | qCDebug(KWIN_DRM) << "Server setting position: " << m_changeset->position(); | 852 | qCDebug(KWIN_DRM) << "Server setting position: " << m_changeset->position(); | ||
846 | setGlobalPos(m_changeset->position()); | 853 | setGlobalPos(m_changeset->position()); | ||
847 | // may just work already! | 854 | // may just work already! | ||
848 | } | 855 | } | ||
849 | if (m_changeset->scaleChanged()) { | 856 | if (m_changeset->scaleChanged()) { | ||
850 | qCDebug(KWIN_DRM) << "Setting scale:" << m_changeset->scale(); | 857 | qCDebug(KWIN_DRM) << "Setting scale:" << m_changeset->scale(); | ||
851 | setScale(m_changeset->scale()); | 858 | setScale(m_changeset->scaleF()); | ||
852 | } | 859 | } | ||
853 | return true; | 860 | return true; | ||
854 | } | 861 | } | ||
855 | 862 | | |||
856 | void DrmOutput::transform(KWayland::Server::OutputDeviceInterface::Transform transform) | 863 | void DrmOutput::transform(KWayland::Server::OutputDeviceInterface::Transform transform) | ||
857 | { | 864 | { | ||
858 | m_waylandOutputDevice->setTransform(transform); | 865 | m_waylandOutputDevice->setTransform(transform); | ||
859 | using KWayland::Server::OutputDeviceInterface; | 866 | using KWayland::Server::OutputDeviceInterface; | ||
▲ Show 20 Lines • Show All 462 Lines • Show Last 20 Lines |
I think we want to ceil. Otherwise you might upscale the client buffers for example from 1 to 1.4 and get blurriness. With ceil you always downscale.
I would have liked to multiply, but a scale of e.g. 1.1 then would result in a scale factor of 10, what is quite many pixels to draw.