plugins/zoom: do colorspace conversions between the screen textures

Otherwise colors and especially brightness levels can be quite wrong when
the textures are used on a different screen

BUG: 488839
This commit is contained in:
Xaver Hugl 2024-06-21 01:17:36 +02:00
parent 2fb485d67d
commit 9293df2681
2 changed files with 5 additions and 2 deletions

View file

@ -277,6 +277,7 @@ ZoomEffect::OffscreenData *ZoomEffect::ensureOffscreenData(const RenderTarget &r
OffscreenData &data = m_offscreenData[effects->waylandDisplay() ? screen : nullptr];
data.viewport = rect;
data.color = renderTarget.colorDescription();
const GLenum textureFormat = renderTarget.colorDescription() == ColorDescription::sRGB ? GL_RGBA8 : GL_RGBA16F;
if (!data.texture || data.texture->size() != nativeSize || data.texture->internalFormat() != textureFormat) {
@ -390,7 +391,7 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
auto shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture);
auto shader = ShaderManager::instance()->pushShader(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace);
for (auto &[screen, offscreen] : m_offscreenData) {
QMatrix4x4 matrix;
matrix.translate(xTranslation * scale, yTranslation * scale);
@ -398,6 +399,7 @@ void ZoomEffect::paintScreen(const RenderTarget &renderTarget, const RenderViewp
matrix.translate(offscreen.viewport.x() * scale, offscreen.viewport.y() * scale);
shader->setUniform(GLShader::Mat4Uniform::ModelViewProjectionMatrix, viewport.projectionMatrix() * matrix);
shader->setColorspaceUniforms(offscreen.color, renderTarget.colorDescription());
offscreen.texture->render(offscreen.viewport.size() * scale);
}

View file

@ -9,9 +9,9 @@
*/
#pragma once
#include "config-kwin.h"
#include "core/colorspace.h"
#include "effect/effect.h"
#include <QTime>
#include <QTimeLine>
@ -95,6 +95,7 @@ private:
std::unique_ptr<GLTexture> texture;
std::unique_ptr<GLFramebuffer> framebuffer;
QRect viewport;
ColorDescription color = ColorDescription::sRGB;
};
GLTexture *ensureCursorTexture();