effects: Make DeformEffect disable clipping if specified region is infinite
The Scene no longer clips window quads if the specified paint region is infinite. The infinite region is defined as (INT_MIN/2, INT_MIN/2, INT_MAX, INT_MAX). If you try to scale the infinite region, you will easily hit integer overflow. This change makes the DeformEffect disable geometry clipping if the given paint region is infinite region in order to avoid hitting integer overflow.
This commit is contained in:
parent
f07d6bd400
commit
2983727871
1 changed files with 14 additions and 5 deletions
|
@ -154,9 +154,6 @@ void DeformEffectPrivate::paint(EffectWindow *window, GLTexture *texture, const
|
|||
quads.makeInterleavedArrays(primitiveType, map, texture->matrix(NormalizedCoordinates));
|
||||
vbo->unmap();
|
||||
vbo->bindArrays();
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
const qreal rgb = data.brightness() * data.opacity();
|
||||
const qreal a = data.opacity();
|
||||
|
@ -169,12 +166,24 @@ void DeformEffectPrivate::paint(EffectWindow *window, GLTexture *texture, const
|
|||
shader->setUniform(GLShader::TextureWidth, texture->width());
|
||||
shader->setUniform(GLShader::TextureHeight, texture->height());
|
||||
|
||||
const bool clipping = region != infiniteRegion();
|
||||
const QRegion clipRegion = clipping ? effects->mapToRenderTarget(region) : infiniteRegion();
|
||||
|
||||
if (clipping) {
|
||||
glEnable(GL_SCISSOR_TEST);
|
||||
}
|
||||
|
||||
glEnable(GL_BLEND);
|
||||
glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
texture->bind();
|
||||
vbo->draw(effects->mapToRenderTarget(region), primitiveType, 0, verticesPerQuad * quads.count(), true);
|
||||
vbo->draw(clipRegion, primitiveType, 0, verticesPerQuad * quads.count(), clipping);
|
||||
texture->unbind();
|
||||
|
||||
glDisable(GL_BLEND);
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
if (clipping) {
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
}
|
||||
vbo->unbindArrays();
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue