screencasting: Polish region case

- By scaling: make sure we are scaling by the feed size rather than the
output size, which is irrelevant in this case.
- By positioning: properly position the outputs on the feed if the feed
scale is != 1
This commit is contained in:
Aleix Pol 2022-11-02 19:50:14 +01:00
parent eb7f93002c
commit ea4741cbcc

View file

@ -45,25 +45,21 @@ void RegionScreenCastSource::updateOutput(Output *output)
if (m_renderedTexture) {
const std::shared_ptr<GLTexture> outputTexture = Compositor::self()->scene()->textureForOutput(output);
const auto outputGeometry = output->geometry();
const auto outputScale = output->scale();
if (!outputTexture || !m_region.intersects(output->geometry())) {
return;
}
GLFramebuffer::pushFramebuffer(m_target.get());
const QRect geometry({0, 0}, m_target->size());
ShaderBinder shaderBinder(ShaderTrait::MapTexture);
QMatrix4x4 projectionMatrix;
projectionMatrix.ortho(m_region);
const QPoint pos = outputGeometry.topLeft();
projectionMatrix.translate(pos.x() * outputScale, pos.y() * outputScale);
projectionMatrix.translate(outputGeometry.left() / m_scale, (m_region.bottom() - outputGeometry.bottom()) / m_scale);
shaderBinder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, projectionMatrix);
outputTexture->bind();
outputTexture->render(output->geometry(), outputScale);
outputTexture->render(output->geometry(), 1 / m_scale);
outputTexture->unbind();
GLFramebuffer::popFramebuffer();
}