backends/{x11,wayland}: Avoid painting null cursor image
GLTexture(QImage()) may construct an invalid texture, which is going to make GLTexture::bind() and other requests fail.
This commit is contained in:
parent
89613d8673
commit
77570c0667
2 changed files with 38 additions and 30 deletions
|
@ -218,16 +218,18 @@ void WaylandOutput::renderCursorOpengl(WaylandEglBackend *backend, const QImage
|
|||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
if (!image.isNull()) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GLTexture texture(image);
|
||||
texture.bind();
|
||||
ShaderBinder binder(ShaderTrait::MapTexture);
|
||||
binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
|
||||
texture.render(cursorRect, beginInfo->renderTarget.devicePixelRatio());
|
||||
texture.unbind();
|
||||
glDisable(GL_BLEND);
|
||||
GLTexture texture(image);
|
||||
texture.bind();
|
||||
ShaderBinder binder(ShaderTrait::MapTexture);
|
||||
binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
|
||||
texture.render(cursorRect, beginInfo->renderTarget.devicePixelRatio());
|
||||
texture.unbind();
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
cursorLayer->endFrame(infiniteRegion(), infiniteRegion());
|
||||
}
|
||||
|
@ -250,12 +252,14 @@ void WaylandOutput::renderCursorQPainter(WaylandQPainterBackend *backend, const
|
|||
c->setDevicePixelRatio(scale());
|
||||
c->fill(Qt::transparent);
|
||||
|
||||
QPainter p;
|
||||
p.begin(c);
|
||||
p.setWorldTransform(logicalToNativeMatrix(cursorRect, 1, transform()).toTransform());
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
p.drawImage(QPoint(0, 0), image);
|
||||
p.end();
|
||||
if (!image.isNull()) {
|
||||
QPainter p;
|
||||
p.begin(c);
|
||||
p.setWorldTransform(logicalToNativeMatrix(cursorRect, 1, transform()).toTransform());
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
p.drawImage(QPoint(0, 0), image);
|
||||
p.end();
|
||||
}
|
||||
|
||||
cursorLayer->endFrame(infiniteRegion(), infiniteRegion());
|
||||
}
|
||||
|
|
|
@ -318,16 +318,18 @@ void X11WindowedOutput::renderCursorOpengl(X11WindowedEglBackend *backend, const
|
|||
glClearColor(0, 0, 0, 0);
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
if (!image.isNull()) {
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
GLTexture texture(image);
|
||||
texture.bind();
|
||||
ShaderBinder binder(ShaderTrait::MapTexture);
|
||||
binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
|
||||
texture.render(cursorRect, beginInfo->renderTarget.devicePixelRatio());
|
||||
texture.unbind();
|
||||
glDisable(GL_BLEND);
|
||||
GLTexture texture(image);
|
||||
texture.bind();
|
||||
ShaderBinder binder(ShaderTrait::MapTexture);
|
||||
binder.shader()->setUniform(GLShader::ModelViewProjectionMatrix, mvp);
|
||||
texture.render(cursorRect, beginInfo->renderTarget.devicePixelRatio());
|
||||
texture.unbind();
|
||||
glDisable(GL_BLEND);
|
||||
}
|
||||
|
||||
cursorLayer->endFrame(infiniteRegion(), infiniteRegion());
|
||||
}
|
||||
|
@ -349,12 +351,14 @@ void X11WindowedOutput::renderCursorQPainter(X11WindowedQPainterBackend *backend
|
|||
c->setDevicePixelRatio(scale());
|
||||
c->fill(Qt::transparent);
|
||||
|
||||
QPainter p;
|
||||
p.begin(c);
|
||||
p.setWorldTransform(logicalToNativeMatrix(cursorRect, 1, transform()).toTransform());
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
p.drawImage(QPoint(0, 0), image);
|
||||
p.end();
|
||||
if (!image.isNull()) {
|
||||
QPainter p;
|
||||
p.begin(c);
|
||||
p.setWorldTransform(logicalToNativeMatrix(cursorRect, 1, transform()).toTransform());
|
||||
p.setRenderHint(QPainter::SmoothPixmapTransform);
|
||||
p.drawImage(QPoint(0, 0), image);
|
||||
p.end();
|
||||
}
|
||||
|
||||
cursorLayer->endFrame(infiniteRegion(), infiniteRegion());
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue