plugins/screencast: Prefer glReadnPixels() and glGetnTexImage()

They should prevent potentially writing texture data outside the bounds
of the memfd buffer.
This commit is contained in:
Vlad Zahorodnii 2024-07-04 14:01:38 +03:00
parent b452a5a5fb
commit 74d7c33a97

View file

@ -57,12 +57,14 @@ static void doGrabTexture(GLTexture *texture, QImage *target)
if (context->isOpenGLES() || context->glPlatform()->driver() == Driver_NVidia) {
GLFramebuffer fbo(texture);
GLFramebuffer::pushFramebuffer(&fbo);
glReadPixels(0, 0, size.width(), size.height(), closestGLType(target->format()), GL_UNSIGNED_BYTE, target->bits());
context->glReadnPixels(0, 0, size.width(), size.height(), closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits());
GLFramebuffer::popFramebuffer();
} else if (context->openglVersion() >= Version(4, 5)) {
glGetTextureImage(texture->texture(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits());
} else {
glGetTexImage(texture->target(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->bits());
if (context->openglVersion() >= Version(4, 5)) {
glGetnTexImage(texture->target(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->sizeInBytes(), target->bits());
} else {
glGetTexImage(texture->target(), 0, closestGLType(target->format()), GL_UNSIGNED_BYTE, target->bits());
}
}
if (invertNeededAndSupported) {