From dbb2cede087a136e3bd2df7138ab3ceee2644fd5 Mon Sep 17 00:00:00 2001 From: Roman Gilg Date: Tue, 27 Aug 2019 16:19:47 +0200 Subject: [PATCH] Get output pixel size from output device Summary: Get the pixel size directly from the always available output device interface instead of saving an additional copy in the backends. Test Plan: Nested Wayland, Drm, virtual backends tested. Reviewers: #kwin, davidedmundson Reviewed By: #kwin, davidedmundson Subscribers: kwin Tags: #kwin Maniphest Tasks: T11459 Differential Revision: https://phabricator.kde.org/D23495 --- abstract_wayland_output.cpp | 12 ++++++------ abstract_wayland_output.h | 2 +- plugins/platforms/drm/drm_output.cpp | 5 ----- plugins/platforms/drm/drm_output.h | 2 -- plugins/platforms/fbdev/fb_backend.cpp | 1 - plugins/platforms/fbdev/fb_backend.h | 6 ------ plugins/platforms/hwcomposer/hwcomposer_backend.cpp | 10 ++-------- plugins/platforms/virtual/virtual_output.cpp | 9 ++------- plugins/platforms/virtual/virtual_output.h | 4 ---- plugins/platforms/wayland/wayland_output.cpp | 7 +------ plugins/platforms/wayland/wayland_output.h | 3 --- .../platforms/x11/windowed/x11windowed_output.cpp | 7 +------ plugins/platforms/x11/windowed/x11windowed_output.h | 3 --- 13 files changed, 13 insertions(+), 58 deletions(-) diff --git a/abstract_wayland_output.cpp b/abstract_wayland_output.cpp index fb5c8b9ceb..5df90a00e4 100644 --- a/abstract_wayland_output.cpp +++ b/abstract_wayland_output.cpp @@ -54,12 +54,7 @@ QString AbstractWaylandOutput::name() const QRect AbstractWaylandOutput::geometry() const { - // TODO: This is inefficient on current KWayland since - // we loop over modes. -// const QSize size = m_waylandOutputDevice->pixelSize(); - const QSize size = pixelSize(); - - return QRect(globalPos(), size / scale()); + return QRect(globalPos(), pixelSize() / scale()); } QSize AbstractWaylandOutput::physicalSize() const @@ -93,6 +88,11 @@ void AbstractWaylandOutput::setGlobalPos(const QPoint &pos) } } +QSize AbstractWaylandOutput::pixelSize() const +{ + return orientateSize(m_waylandOutputDevice->pixelSize()); +} + qreal AbstractWaylandOutput::scale() const { return m_waylandOutputDevice->scaleF(); diff --git a/abstract_wayland_output.h b/abstract_wayland_output.h index 3b599ea5b8..d8606f0b64 100644 --- a/abstract_wayland_output.h +++ b/abstract_wayland_output.h @@ -64,7 +64,7 @@ public: return !m_waylandOutput.isNull(); } - virtual QSize pixelSize() const = 0; + QSize pixelSize() const; qreal scale() const override; /** diff --git a/plugins/platforms/drm/drm_output.cpp b/plugins/platforms/drm/drm_output.cpp index c609aae27d..e0003450bb 100644 --- a/plugins/platforms/drm/drm_output.cpp +++ b/plugins/platforms/drm/drm_output.cpp @@ -675,11 +675,6 @@ void DrmOutput::updateMode(int modeIndex) setWaylandMode(); } -QSize DrmOutput::pixelSize() const -{ - return orientateSize(QSize(m_mode.hdisplay, m_mode.vdisplay)); -} - void DrmOutput::setWaylandMode() { AbstractWaylandOutput::setWaylandMode(QSize(m_mode.hdisplay, m_mode.vdisplay), diff --git a/plugins/platforms/drm/drm_output.h b/plugins/platforms/drm/drm_output.h index ab7ceb8fd8..34dcbb05b9 100644 --- a/plugins/platforms/drm/drm_output.h +++ b/plugins/platforms/drm/drm_output.h @@ -60,8 +60,6 @@ public: bool present(DrmBuffer *buffer); void pageFlipped(); - QSize pixelSize() const override; - // These values are defined by the kernel enum class DpmsMode { On = DRM_MODE_DPMS_ON, diff --git a/plugins/platforms/fbdev/fb_backend.cpp b/plugins/platforms/fbdev/fb_backend.cpp index 2dccb334f7..01244f9ca3 100644 --- a/plugins/platforms/fbdev/fb_backend.cpp +++ b/plugins/platforms/fbdev/fb_backend.cpp @@ -39,7 +39,6 @@ namespace KWin void FramebufferOutput::init(const QSize &size) { - m_pixelSize = size; KWayland::Server::OutputDeviceInterface::Mode mode; mode.id = 0; mode.size = size; diff --git a/plugins/platforms/fbdev/fb_backend.h b/plugins/platforms/fbdev/fb_backend.h index c38e29ca0b..9b366bd28c 100644 --- a/plugins/platforms/fbdev/fb_backend.h +++ b/plugins/platforms/fbdev/fb_backend.h @@ -38,16 +38,10 @@ public: ~FramebufferOutput() override = default; void init(const QSize &size); - QSize pixelSize() const override { - return m_pixelSize; - } void setRawPhysicalSize(const QSize &set) { AbstractWaylandOutput::setRawPhysicalSize(set); } - -private: - QSize m_pixelSize; }; class KWIN_EXPORT FramebufferBackend : public Platform diff --git a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp index 115b61d779..17b5092ae9 100644 --- a/plugins/platforms/hwcomposer/hwcomposer_backend.cpp +++ b/plugins/platforms/hwcomposer/hwcomposer_backend.cpp @@ -506,7 +506,6 @@ HwcomposerOutput::HwcomposerOutput(hwc_composer_device_1_t *device) if (pixel.isEmpty()) { return; } - m_pixelSize = pixel; if (attr_values[2] != 0 && attr_values[3] != 0) { static const qreal factor = 25.4; @@ -531,7 +530,7 @@ HwcomposerOutput::HwcomposerOutput(hwc_composer_device_1_t *device) const auto outputGroup = kwinApp()->config()->group("HWComposerOutputs").group("0"); setScale(outputGroup.readEntry("Scale", 1)); - setWaylandMode(m_pixelSize, mode.refreshRate); + setWaylandMode(pixel, mode.refreshRate); } HwcomposerOutput::~HwcomposerOutput() @@ -539,14 +538,9 @@ HwcomposerOutput::~HwcomposerOutput() hwc_close_1(m_device); } -QSize HwcomposerOutput::pixelSize() const -{ - return m_pixelSize; -} - bool HwcomposerOutput::isValid() const { - return m_pixelSize.isValid(); + return isEnabled(); } void HwcomposerOutput::updateDpms(KWayland::Server::OutputInterface::DpmsMode mode) diff --git a/plugins/platforms/virtual/virtual_output.cpp b/plugins/platforms/virtual/virtual_output.cpp index 56a5d9bc01..4f55df8f04 100644 --- a/plugins/platforms/virtual/virtual_output.cpp +++ b/plugins/platforms/virtual/virtual_output.cpp @@ -46,15 +46,10 @@ void VirtualOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) setScale(1.); } -QSize VirtualOutput::pixelSize() const -{ - return m_pixelSize; -} - void VirtualOutput::setGeometry(const QRect &geo) { - m_pixelSize = geo.size(); - setRawPhysicalSize(m_pixelSize); + // TODO: set mode to have updated pixelSize + setRawPhysicalSize(geo.size()); setGlobalPos(geo.topLeft()); } diff --git a/plugins/platforms/virtual/virtual_output.h b/plugins/platforms/virtual/virtual_output.h index 995f296a0f..20f43fdb7d 100644 --- a/plugins/platforms/virtual/virtual_output.h +++ b/plugins/platforms/virtual/virtual_output.h @@ -39,8 +39,6 @@ public: void init(const QPoint &logicalPosition, const QSize &pixelSize); - QSize pixelSize() const override; - void setGeometry(const QRect &geo); int gammaRampSize() const override { @@ -55,8 +53,6 @@ private: Q_DISABLE_COPY(VirtualOutput); friend class VirtualBackend; - QSize m_pixelSize; - int m_gammaSize = 200; bool m_gammaResult = true; }; diff --git a/plugins/platforms/wayland/wayland_output.cpp b/plugins/platforms/wayland/wayland_output.cpp index 5e2304ac89..37d80b857e 100644 --- a/plugins/platforms/wayland/wayland_output.cpp +++ b/plugins/platforms/wayland/wayland_output.cpp @@ -69,14 +69,9 @@ void WaylandOutput::init(const QPoint &logicalPosition, const QSize &pixelSize) setScale(backend()->initialOutputScale()); } -QSize WaylandOutput::pixelSize() const -{ - return m_pixelSize; -} - void WaylandOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixelSize) { - m_pixelSize = pixelSize; + // TODO: set mode to have updated pixelSize setRawPhysicalSize(pixelSize); setGlobalPos(logicalPosition); } diff --git a/plugins/platforms/wayland/wayland_output.h b/plugins/platforms/wayland/wayland_output.h index 1dbcdca297..bce052af68 100644 --- a/plugins/platforms/wayland/wayland_output.h +++ b/plugins/platforms/wayland/wayland_output.h @@ -62,8 +62,6 @@ public: virtual bool pointerIsLocked() { return false; } - QSize pixelSize() const override; - /** * @brief defines the geometry of the output * @param logicalPosition top left position of the output in compositor space @@ -95,7 +93,6 @@ private: KWayland::Client::Surface *m_surface; WaylandBackend *m_backend; - QSize m_pixelSize; bool m_rendered = false; }; diff --git a/plugins/platforms/x11/windowed/x11windowed_output.cpp b/plugins/platforms/x11/windowed/x11windowed_output.cpp index 3c3c80b1b4..344be9ed66 100644 --- a/plugins/platforms/x11/windowed/x11windowed_output.cpp +++ b/plugins/platforms/x11/windowed/x11windowed_output.cpp @@ -134,14 +134,9 @@ void X11WindowedOutput::initXInputForWindow() #endif } -QSize X11WindowedOutput::pixelSize() const -{ - return m_pixelSize; -} - void X11WindowedOutput::setGeometry(const QPoint &logicalPosition, const QSize &pixelSize) { - m_pixelSize = pixelSize; + // TODO: set mode to have updated pixelSize // Physicial size must be adjusted, such that QPA calculates correct sizes of // internal elements. diff --git a/plugins/platforms/x11/windowed/x11windowed_output.h b/plugins/platforms/x11/windowed/x11windowed_output.h index 460a3298e7..aa4e2d20e8 100644 --- a/plugins/platforms/x11/windowed/x11windowed_output.h +++ b/plugins/platforms/x11/windowed/x11windowed_output.h @@ -59,8 +59,6 @@ public: void setWindowTitle(const QString &title); - QSize pixelSize() const override; - /** * @brief defines the geometry of the output * @param logicalPosition top left position of the output in compositor space @@ -75,7 +73,6 @@ private: NETWinInfo *m_winInfo = nullptr; QPoint m_hostPosition; - QSize m_pixelSize; X11WindowedBackend *m_backend; };