Move output refresh rate getter into AbstractOutput

Summary:
The current refresh rate is stored in OutputInterface. Move the getter
therefore in the AbstractOutput class.

Reviewers: #kwin, davidedmundson

Reviewed By: #kwin, davidedmundson

Subscribers: kwin

Tags: #kwin

Differential Revision: https://phabricator.kde.org/D16793
This commit is contained in:
Roman Gilg 2018-11-09 23:17:27 +01:00
parent 0af57d6366
commit 6295d1e6a2
8 changed files with 24 additions and 21 deletions

View file

@ -65,6 +65,14 @@ QSize AbstractOutput::physicalSize() const
return m_physicalSize; return m_physicalSize;
} }
int AbstractOutput::refreshRate() const
{
if (!m_waylandOutput) {
return 60000;
}
return m_waylandOutput->refreshRate();
}
void AbstractOutput::setGlobalPos(const QPoint &pos) void AbstractOutput::setGlobalPos(const QPoint &pos)
{ {
m_globalPos = pos; m_globalPos = pos;

View file

@ -80,6 +80,11 @@ public:
return m_orientation; return m_orientation;
} }
/*
* Current refresh rate in 1/ms
*/
int refreshRate() const;
bool isInternal() const { bool isInternal() const {
return m_internal; return m_internal;
} }

View file

@ -93,6 +93,15 @@ QSizeF OutputScreens::physicalSize(int screen) const
return enOuts.at(screen)->physicalSize(); return enOuts.at(screen)->physicalSize();
} }
float OutputScreens::refreshRate(int screen) const
{
const auto enOuts = m_platform->enabledOutputs();
if (screen >= enOuts.size()) {
return Screens::refreshRate(screen);
}
return enOuts.at(screen)->refreshRate() / 1000.0f;
}
Qt::ScreenOrientation OutputScreens::orientation(int screen) const Qt::ScreenOrientation OutputScreens::orientation(int screen) const
{ {
const auto enOuts = m_platform->enabledOutputs(); const auto enOuts = m_platform->enabledOutputs();

View file

@ -42,7 +42,8 @@ public:
QRect geometry(int screen) const override; QRect geometry(int screen) const override;
QSize size(int screen) const override; QSize size(int screen) const override;
qreal scale(int screen) const override; qreal scale(int screen) const override;
Qt::ScreenOrientation orientation(int screen) const; float refreshRate(int screen) const override;
Qt::ScreenOrientation orientation(int screen) const override;
void updateCount() override; void updateCount() override;
int number(const QPoint &pos) const override; int number(const QPoint &pos) const override;

View file

@ -781,15 +781,6 @@ void DrmOutput::updateMode(int modeIndex)
setWaylandMode(); setWaylandMode();
} }
int DrmOutput::currentRefreshRate() const
{
auto wlOutput = waylandOutput();
if (!wlOutput) {
return 60000;
}
return wlOutput->refreshRate();
}
QSize DrmOutput::pixelSize() const QSize DrmOutput::pixelSize() const
{ {
auto orient = orientation(); auto orient = orientation();

View file

@ -67,7 +67,6 @@ public:
QSize pixelSize() const override; QSize pixelSize() const override;
int currentRefreshRate() const;
// These values are defined by the kernel // These values are defined by the kernel
enum class DpmsMode { enum class DpmsMode {
On = DRM_MODE_DPMS_ON, On = DRM_MODE_DPMS_ON,

View file

@ -34,15 +34,6 @@ DrmScreens::DrmScreens(DrmBackend *backend, QObject *parent)
DrmScreens::~DrmScreens() = default; DrmScreens::~DrmScreens() = default;
float DrmScreens::refreshRate(int screen) const
{
const auto enOuts = m_backend->drmEnabledOutputs();
if (screen >= enOuts.size()) {
return Screens::refreshRate(screen);
}
return enOuts.at(screen)->currentRefreshRate() / 1000.0f;
}
bool DrmScreens::supportsTransformations(int screen) const bool DrmScreens::supportsTransformations(int screen) const
{ {
const auto enOuts = m_backend->drmEnabledOutputs(); const auto enOuts = m_backend->drmEnabledOutputs();

View file

@ -32,7 +32,6 @@ public:
DrmScreens(DrmBackend *backend, QObject *parent = nullptr); DrmScreens(DrmBackend *backend, QObject *parent = nullptr);
virtual ~DrmScreens(); virtual ~DrmScreens();
float refreshRate(int screen) const override;
bool supportsTransformations(int screen) const override; bool supportsTransformations(int screen) const override;
DrmBackend *m_backend; DrmBackend *m_backend;