backends/drm: fix night color with ICC profiles

Until night color is dealt with properly by adjusting the output whitepoint,
the channel factors have to be multiplied in with the color transformation
matrix manually

BUG: 413134
This commit is contained in:
Xaver Hugl 2023-12-21 21:40:05 +01:00
parent 8b1fddffbe
commit b24505a447
3 changed files with 8 additions and 4 deletions

View file

@ -153,7 +153,7 @@ bool EglGbmLayerSurface::endRendering(const QRegion &damagedRegion)
GLFramebuffer::pushFramebuffer(fbo);
ShaderBinder binder = m_surface->iccShader ? ShaderBinder(m_surface->iccShader->shader()) : ShaderBinder(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace);
if (m_surface->iccShader) {
m_surface->iccShader->setUniforms(m_surface->iccProfile, m_surface->intermediaryColorDescription.sdrBrightness());
m_surface->iccShader->setUniforms(m_surface->iccProfile, m_surface->intermediaryColorDescription.sdrBrightness(), m_surface->channelFactors);
} else {
QMatrix3x3 ctm;
ctm(0, 0) = m_surface->channelFactors.x();

View file

@ -146,13 +146,17 @@ GLShader *IccShader::shader() const
return m_shader.get();
}
void IccShader::setUniforms(const std::shared_ptr<IccProfile> &profile, float sdrBrightness)
void IccShader::setUniforms(const std::shared_ptr<IccProfile> &profile, float sdrBrightness, const QVector3D &channelFactors)
{
// this failing can be silently ignored, it should only happen with GPU resets and gets corrected later
setProfile(profile);
QMatrix3x3 nightColor;
nightColor(0, 0) = channelFactors.x();
nightColor(1, 1) = channelFactors.y();
nightColor(2, 2) = channelFactors.z();
m_shader->setUniform(m_locations.matrix1, m_matrix1 * nightColor);
m_shader->setUniform(m_locations.sdrBrightness, sdrBrightness);
m_shader->setUniform(m_locations.matrix1, m_matrix1);
glActiveTexture(GL_TEXTURE1);
if (m_B) {

View file

@ -25,7 +25,7 @@ public:
~IccShader();
GLShader *shader() const;
void setUniforms(const std::shared_ptr<IccProfile> &profile, float sdrBrightness);
void setUniforms(const std::shared_ptr<IccProfile> &profile, float sdrBrightness, const QVector3D &channelFactors);
private:
bool setProfile(const std::shared_ptr<IccProfile> &profile);