Index: colorcorrection/manager.cpp =================================================================== --- colorcorrection/manager.cpp +++ colorcorrection/manager.cpp @@ -25,6 +25,7 @@ #include #include +#include #include #include #include @@ -509,10 +510,10 @@ void Manager::commitGammaRamps(int temperature) { - int nscreens = Screens::self()->count(); + const auto outs = kwinApp()->platform()->outputs(); - for (int screen = 0; screen < nscreens; screen++) { - int rampsize = kwinApp()->platform()->gammaRampSize(screen); + for (auto *o : outs) { + int rampsize = o->getGammaRampSize(); GammaRamp ramp(rampsize); /* @@ -542,13 +543,13 @@ ramp.blue[i] = (double)ramp.blue[i] / (UINT16_MAX+1) * whitePoint[2] * (UINT16_MAX+1); } - if (kwinApp()->platform()->setGammaRamp(screen, ramp)) { + if (o->setGammaRamp(ramp)) { m_currentTemp = temperature; m_failedCommitAttempts = 0; } else { m_failedCommitAttempts++; if (m_failedCommitAttempts < 10) { - qCWarning(KWIN_COLORCORRECTION).nospace() << "Committing Gamma Ramp failed for screen " << screen << + qCWarning(KWIN_COLORCORRECTION).nospace() << "Committing Gamma Ramp failed for output " << o->name() << ". Trying " << (10 - m_failedCommitAttempts) << " times more."; } else { // TODO: On multi monitor setups we could try to rollback earlier changes for already commited outputs Index: output.h =================================================================== --- output.h +++ output.h @@ -45,6 +45,10 @@ namespace KWin { +namespace ColorCorrect { +struct GammaRamp; +} + /** * Generic output representation in a Wayland session **/ @@ -89,6 +93,14 @@ return m_waylandOutput; } + virtual int getGammaRampSize() const { + return 0; + } + virtual bool setGammaRamp(ColorCorrect::GammaRamp &gamma) { + Q_UNUSED(gamma); + return false; + } + protected: QPointer changes() const { return m_changeset; Index: platform.h =================================================================== --- platform.h +++ platform.h @@ -42,7 +42,6 @@ { namespace ColorCorrect { class Manager; -struct GammaRamp; } class Output; @@ -402,16 +401,6 @@ return m_colorCorrect; } - virtual int gammaRampSize(int screen) const { - Q_UNUSED(screen); - return 0; - } - virtual bool setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) { - Q_UNUSED(screen); - Q_UNUSED(gamma); - return false; - } - /* * A string of information to include in kwin debug output * It should not be translated. Index: plugins/platforms/drm/drm_backend.h =================================================================== --- plugins/platforms/drm/drm_backend.h +++ plugins/platforms/drm/drm_backend.h @@ -55,10 +55,6 @@ namespace KWin { -namespace ColorCorrect { -struct GammaRamp; -} - class Udev; class UdevMonitor; @@ -118,8 +114,6 @@ gbm_device *gbmDevice() const { return m_gbmDevice; } - int gammaRampSize(int screen) const override; - bool setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) override; QVector supportedCompositors() const override; Index: plugins/platforms/drm/drm_backend.cpp =================================================================== --- plugins/platforms/drm/drm_backend.cpp +++ plugins/platforms/drm/drm_backend.cpp @@ -31,7 +31,6 @@ #include "screens_drm.h" #include "udev.h" #include "wayland_server.h" -#include #if HAVE_GBM #include "egl_gbm_backend.h" #include @@ -780,24 +779,6 @@ #endif } -int DrmBackend::gammaRampSize(int screen) const -{ - if (m_outputs.size() <= screen) { - return 0; - } - auto *o = static_cast(m_outputs.at(screen)); - return o->m_crtc->getGammaRampSize(); -} - -bool DrmBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) -{ - if (m_outputs.size() <= screen) { - return false; - } - auto *o = static_cast(m_outputs.at(screen)); - return o->m_crtc->setGammaRamp(gamma); -} - QString DrmBackend::supportInformation() const { QString supportInfo; Index: plugins/platforms/drm/drm_output.h =================================================================== --- plugins/platforms/drm/drm_output.h +++ plugins/platforms/drm/drm_output.h @@ -136,6 +136,9 @@ void transform(KWayland::Server::OutputDeviceInterface::Transform transform); void automaticRotation(); + int getGammaRampSize() const override; + bool setGammaRamp(ColorCorrect::GammaRamp &gamma) override; + DrmBackend *m_backend; DrmConnector *m_conn = nullptr; DrmCrtc *m_crtc = nullptr; Index: plugins/platforms/drm/drm_output.cpp =================================================================== --- plugins/platforms/drm/drm_output.cpp +++ plugins/platforms/drm/drm_output.cpp @@ -1264,4 +1264,14 @@ emit screens()->changed(); } +int DrmOutput::getGammaRampSize() const +{ + return m_crtc->getGammaRampSize(); +} + +bool DrmOutput::setGammaRamp(ColorCorrect::GammaRamp &gamma) +{ + return m_crtc->setGammaRamp(gamma); +} + } Index: plugins/platforms/virtual/virtual_backend.h =================================================================== --- plugins/platforms/virtual/virtual_backend.h +++ plugins/platforms/virtual/virtual_backend.h @@ -69,8 +69,6 @@ void setGbmDevice(gbm_device *device) { m_gbmDevice = device; } - virtual int gammaRampSize(int screen) const override; - virtual bool setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) override; QVector supportedCompositors() const override { return QVector{OpenGLCompositing, QPainterCompositing}; Index: plugins/platforms/virtual/virtual_backend.cpp =================================================================== --- plugins/platforms/virtual/virtual_backend.cpp +++ plugins/platforms/virtual/virtual_backend.cpp @@ -138,15 +138,4 @@ emit virtualOutputsSet(countChanged); } -int VirtualBackend::gammaRampSize(int screen) const { - auto *out = qobject_cast(m_outputs[screen]); - return out->m_gammaSize; -} - -bool VirtualBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) { - Q_UNUSED(gamma); - auto *out = qobject_cast(m_outputs[screen]); - return out->m_gammaResult; -} - } Index: plugins/platforms/virtual/virtual_output.h =================================================================== --- plugins/platforms/virtual/virtual_output.h +++ plugins/platforms/virtual/virtual_output.h @@ -41,6 +41,14 @@ void setGeometry(const QRect &geo); + int getGammaRampSize() const override { + return m_gammaSize; + } + bool setGammaRamp(ColorCorrect::GammaRamp &gamma) override { + Q_UNUSED(gamma); + return m_gammaResult; + } + private: Q_DISABLE_COPY(VirtualOutput); friend class VirtualBackend;