plugins/screencast: Fix hidpi region screencasting

Currently hidpi region screencasting is broken because output textures
are inappropriately scaled.

The orthographic projection is set up with logical pixels, but the
remaining rendering code uses "1 / m_scale" scale factor, which is wrong.

In order to fix hidpi and also simplify rendering logic, this change
makes rendering code use logical coordinate system. It's okay to do in
screencasting because we don't need to worry about snapping to the pixel
grid.

BUG: 476858
BUG: 476859
This commit is contained in:
Vlad Zahorodnii 2023-11-27 13:30:10 +02:00
parent ff76c8581d
commit c8d4f26a9f

View file

@ -60,12 +60,12 @@ void RegionScreenCastSource::updateOutput(Output *output)
ShaderBinder shaderBinder(ShaderTrait::MapTexture | ShaderTrait::TransformColorspace);
QMatrix4x4 projectionMatrix;
projectionMatrix.ortho(m_region);
projectionMatrix.translate(outputGeometry.left() / m_scale, outputGeometry.top() / m_scale);
projectionMatrix.translate(outputGeometry.left(), outputGeometry.top());
shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
shaderBinder.shader()->setColorspaceUniformsToSRGB(colorDescription);
outputTexture->render(output->geometry().size(), 1 / m_scale);
outputTexture->render(outputGeometry.size(), 1);
GLFramebuffer::popFramebuffer();
}
}
@ -104,7 +104,7 @@ void RegionScreenCastSource::render(GLFramebuffer *target)
projectionMatrix.ortho(QRect(QPoint(), target->size()));
shader->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
m_renderedTexture->render(target->size(), m_scale);
m_renderedTexture->render(target->size(), 1);
ShaderManager::instance()->popShader();
GLFramebuffer::popFramebuffer();