Bitmap: Normalize rect passed to glState.scissorBox

glScissorBox doesn't like negative values.
This commit is contained in:
Jonas Kulla 2014-08-17 15:43:03 +02:00
parent b0eeb6d1bd
commit 7452331e04
1 changed files with 24 additions and 18 deletions

View File

@ -51,6 +51,27 @@
"Operation not supported for mega surfaces"); \ "Operation not supported for mega surfaces"); \
} }
/* Normalize (= ensure width and
* height are positive) */
static IntRect normalizedRect(const IntRect &rect)
{
IntRect norm = rect;
if (norm.w < 0)
{
norm.w = -norm.w;
norm.x -= norm.w;
}
if (norm.h < 0)
{
norm.h = -norm.h;
norm.y -= norm.h;
}
return norm;
}
struct BitmapPrivate struct BitmapPrivate
{ {
Bitmap *self; Bitmap *self;
@ -108,23 +129,8 @@ struct BitmapPrivate
} }
void addTaintedArea(const IntRect &rect) void addTaintedArea(const IntRect &rect)
{ {
/* Normalize (= ensure width and IntRect norm = normalizedRect(rect);
* height are positive) */
IntRect norm = rect;
if (norm.w < 0)
{
norm.x += norm.w;
norm.w = -norm.w;
}
if (norm.h < 0)
{
norm.y += norm.h;
norm.h = -norm.h;
}
pixman_region_union_rect pixman_region_union_rect
(&tainted, &tainted, norm.x, norm.y, norm.w, norm.h); (&tainted, &tainted, norm.x, norm.y, norm.w, norm.h);
} }
@ -191,7 +197,7 @@ struct BitmapPrivate
bindFBO(); bindFBO();
glState.scissorTest.pushSet(true); glState.scissorTest.pushSet(true);
glState.scissorBox.pushSet(rect); glState.scissorBox.pushSet(normalizedRect(rect));
glState.clearColor.pushSet(color); glState.clearColor.pushSet(color);
FBO::clear(); FBO::clear();