core/colorspace: normalize XYZ values before using them in calculations

Otherwise ICC profiles where the primaries are normalized to different values than what
KWin needs may cause too dark or bright results.

BUG: 481034
wilder/Plasma/6.2
Xaver Hugl 2 years ago
parent af4e12c5fc
commit dd53576fe2
  1. 7
      src/core/colorspace.cpp

@ -75,6 +75,11 @@ QMatrix4x4 Colorimetry::chromaticAdaptationMatrix(QVector2D sourceWhitepoint, QV
return inverseBradford * adaptation * bradford;
}
static QVector3D normalizeToY1(const QVector3D &vect)
{
return vect.y() == 0 ? vect : QVector3D(vect.x() / vect.y(), 1, vect.z() / vect.y());
}
QMatrix4x4 Colorimetry::calculateToXYZMatrix(QVector3D red, QVector3D green, QVector3D blue, QVector3D white)
{
const auto component_scale = (matrixFromColumns(red, green, blue)).inverted() * white;
@ -106,7 +111,7 @@ Colorimetry::Colorimetry(QVector3D red, QVector3D green, QVector3D blue, QVector
, m_green(xyzToXY(green))
, m_blue(xyzToXY(blue))
, m_white(xyzToXY(white))
, m_toXYZ(calculateToXYZMatrix(red, green, blue, white))
, m_toXYZ(calculateToXYZMatrix(normalizeToY1(red), normalizeToY1(green), normalizeToY1(blue), normalizeToY1(white)))
, m_fromXYZ(m_toXYZ.inverted())
{
}

Loading…
Cancel
Save