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
This commit is contained in:
Roman Gilg 2019-08-27 16:19:47 +02:00
parent 819609a8a6
commit dbb2cede08
13 changed files with 13 additions and 58 deletions

View file

@ -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();

View file

@ -64,7 +64,7 @@ public:
return !m_waylandOutput.isNull();
}
virtual QSize pixelSize() const = 0;
QSize pixelSize() const;
qreal scale() const override;
/**

View file

@ -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),

View file

@ -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,

View file

@ -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;

View file

@ -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

View file

@ -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)

View file

@ -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());
}

View file

@ -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;
};

View file

@ -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);
}

View file

@ -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;
};

View file

@ -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.

View file

@ -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;
};