From b24505a447a992634380acc223aa617e670106ef Mon Sep 17 00:00:00 2001 From: Xaver Hugl Date: Thu, 21 Dec 2023 21:40:05 +0100 Subject: [PATCH] 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 --- src/backends/drm/drm_egl_layer_surface.cpp | 2 +- src/backends/drm/icc_shader.cpp | 8 ++++++-- src/backends/drm/icc_shader.h | 2 +- 3 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/backends/drm/drm_egl_layer_surface.cpp b/src/backends/drm/drm_egl_layer_surface.cpp index 8797f578ef..2de0121a15 100644 --- a/src/backends/drm/drm_egl_layer_surface.cpp +++ b/src/backends/drm/drm_egl_layer_surface.cpp @@ -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(); diff --git a/src/backends/drm/icc_shader.cpp b/src/backends/drm/icc_shader.cpp index 84c2e9f689..b33b533247 100644 --- a/src/backends/drm/icc_shader.cpp +++ b/src/backends/drm/icc_shader.cpp @@ -146,13 +146,17 @@ GLShader *IccShader::shader() const return m_shader.get(); } -void IccShader::setUniforms(const std::shared_ptr &profile, float sdrBrightness) +void IccShader::setUniforms(const std::shared_ptr &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) { diff --git a/src/backends/drm/icc_shader.h b/src/backends/drm/icc_shader.h index dccd56776f..8159c2241e 100644 --- a/src/backends/drm/icc_shader.h +++ b/src/backends/drm/icc_shader.h @@ -25,7 +25,7 @@ public: ~IccShader(); GLShader *shader() const; - void setUniforms(const std::shared_ptr &profile, float sdrBrightness); + void setUniforms(const std::shared_ptr &profile, float sdrBrightness, const QVector3D &channelFactors); private: bool setProfile(const std::shared_ptr &profile);