[colorcorrection] Set gamma through Output class
Summary: With the new Output class we can set the gamma directly here. This is also a stepping stone to adjust individual output gamma adjustment later on. This means any future backend, which aims to support the color correction frontend needs to use the Output class. Test Plan: Night Color test still passes. Reviewers: #kwin Subscribers: kwin Tags: #kwin Differential Revision: https://phabricator.kde.org/D11803icc-effect-5.14.5
parent
b22c362bd5
commit
9cf2730f8d
|
@ -45,6 +45,10 @@ class XdgOutputInterface;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
namespace ColorCorrect {
|
||||
struct GammaRamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Generic output representation in a Wayland session
|
||||
**/
|
||||
|
@ -90,6 +94,14 @@ public:
|
|||
return m_waylandOutput;
|
||||
}
|
||||
|
||||
virtual int getGammaRampSize() const {
|
||||
return 0;
|
||||
}
|
||||
virtual bool setGammaRamp(const ColorCorrect::GammaRamp &gamma) {
|
||||
Q_UNUSED(gamma);
|
||||
return false;
|
||||
}
|
||||
|
||||
protected:
|
||||
QPointer<KWayland::Server::OutputChangeSet> changes() const {
|
||||
return m_changeset;
|
||||
|
|
|
@ -25,6 +25,7 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
|
||||
#include <main.h>
|
||||
#include <platform.h>
|
||||
#include <abstract_output.h>
|
||||
#include <screens.h>
|
||||
#include <workspace.h>
|
||||
#include <logind.h>
|
||||
|
@ -509,10 +510,10 @@ int Manager::currentTargetTemp() const
|
|||
|
||||
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 @@ void Manager::commitGammaRamps(int temperature)
|
|||
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
|
||||
|
|
11
platform.h
11
platform.h
|
@ -42,7 +42,6 @@ namespace KWin
|
|||
{
|
||||
namespace ColorCorrect {
|
||||
class Manager;
|
||||
struct GammaRamp;
|
||||
}
|
||||
|
||||
class AbstractOutput;
|
||||
|
@ -413,16 +412,6 @@ public:
|
|||
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;
|
||||
}
|
||||
|
||||
// outputs with connections (org_kde_kwin_outputdevice)
|
||||
virtual Outputs outputs() const {
|
||||
return Outputs();
|
||||
|
|
|
@ -31,7 +31,6 @@ along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|||
#include "screens_drm.h"
|
||||
#include "udev.h"
|
||||
#include "wayland_server.h"
|
||||
#include <colorcorrection/gammaramp.h>
|
||||
#if HAVE_GBM
|
||||
#include "egl_gbm_backend.h"
|
||||
#include <gbm.h>
|
||||
|
@ -780,22 +779,6 @@ QVector<CompositingType> DrmBackend::supportedCompositors() const
|
|||
#endif
|
||||
}
|
||||
|
||||
int DrmBackend::gammaRampSize(int screen) const
|
||||
{
|
||||
if (m_outputs.size() <= screen) {
|
||||
return 0;
|
||||
}
|
||||
return m_outputs.at(screen)->m_crtc->getGammaRampSize();
|
||||
}
|
||||
|
||||
bool DrmBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma)
|
||||
{
|
||||
if (m_outputs.size() <= screen) {
|
||||
return false;
|
||||
}
|
||||
return m_outputs.at(screen)->m_crtc->setGammaRamp(gamma);
|
||||
}
|
||||
|
||||
QString DrmBackend::supportInformation() const
|
||||
{
|
||||
QString supportInfo;
|
||||
|
|
|
@ -56,10 +56,6 @@ class OutputManagementInterface;
|
|||
namespace KWin
|
||||
{
|
||||
|
||||
namespace ColorCorrect {
|
||||
struct GammaRamp;
|
||||
}
|
||||
|
||||
class Udev;
|
||||
class UdevMonitor;
|
||||
|
||||
|
@ -128,8 +124,6 @@ public:
|
|||
gbm_device *gbmDevice() const {
|
||||
return m_gbmDevice;
|
||||
}
|
||||
int gammaRampSize(int screen) const override;
|
||||
bool setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) override;
|
||||
|
||||
QVector<CompositingType> supportedCompositors() const override;
|
||||
|
||||
|
|
|
@ -112,7 +112,7 @@ bool DrmCrtc::blank()
|
|||
return false;
|
||||
}
|
||||
|
||||
bool DrmCrtc::setGammaRamp(ColorCorrect::GammaRamp &gamma) {
|
||||
bool DrmCrtc::setGammaRamp(const ColorCorrect::GammaRamp &gamma) {
|
||||
bool isError = drmModeCrtcSetGamma(m_backend->fd(), m_id, gamma.size,
|
||||
gamma.red, gamma.green, gamma.blue);
|
||||
return !isError;
|
||||
|
|
|
@ -70,7 +70,7 @@ public:
|
|||
int getGammaRampSize() const {
|
||||
return m_gammaRampSize;
|
||||
}
|
||||
bool setGammaRamp(ColorCorrect::GammaRamp &gamma);
|
||||
bool setGammaRamp(const ColorCorrect::GammaRamp &gamma);
|
||||
|
||||
private:
|
||||
int m_resIndex;
|
||||
|
|
|
@ -1282,4 +1282,14 @@ void DrmOutput::automaticRotation()
|
|||
emit screens()->changed();
|
||||
}
|
||||
|
||||
int DrmOutput::getGammaRampSize() const
|
||||
{
|
||||
return m_crtc->getGammaRampSize();
|
||||
}
|
||||
|
||||
bool DrmOutput::setGammaRamp(const ColorCorrect::GammaRamp &gamma)
|
||||
{
|
||||
return m_crtc->setGammaRamp(gamma);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -140,6 +140,9 @@ private:
|
|||
void transform(KWayland::Server::OutputDeviceInterface::Transform transform);
|
||||
void automaticRotation();
|
||||
|
||||
int getGammaRampSize() const override;
|
||||
bool setGammaRamp(const ColorCorrect::GammaRamp &gamma) override;
|
||||
|
||||
DrmBackend *m_backend;
|
||||
DrmConnector *m_conn = nullptr;
|
||||
DrmCrtc *m_crtc = nullptr;
|
||||
|
|
|
@ -148,13 +148,4 @@ void VirtualBackend::setVirtualOutputs(int count, QVector<QRect> geometries)
|
|||
emit virtualOutputsSet(countChanged);
|
||||
}
|
||||
|
||||
int VirtualBackend::gammaRampSize(int screen) const {
|
||||
return m_outputs[screen]->m_gammaSize;
|
||||
}
|
||||
|
||||
bool VirtualBackend::setGammaRamp(int screen, ColorCorrect::GammaRamp &gamma) {
|
||||
Q_UNUSED(gamma);
|
||||
return m_outputs[screen]->m_gammaResult;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -72,8 +72,6 @@ public:
|
|||
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<CompositingType> supportedCompositors() const override {
|
||||
return QVector<CompositingType>{OpenGLCompositing, QPainterCompositing};
|
||||
|
|
|
@ -41,6 +41,14 @@ public:
|
|||
|
||||
void setGeometry(const QRect &geo);
|
||||
|
||||
int getGammaRampSize() const override {
|
||||
return m_gammaSize;
|
||||
}
|
||||
bool setGammaRamp(const ColorCorrect::GammaRamp &gamma) override {
|
||||
Q_UNUSED(gamma);
|
||||
return m_gammaResult;
|
||||
}
|
||||
|
||||
private:
|
||||
Q_DISABLE_COPY(VirtualOutput);
|
||||
friend class VirtualBackend;
|
||||
|
|
Loading…
Reference in New Issue