зеркало из https://github.com/mozilla/gecko-dev.git
Bug 641426. Part 2.5: Make gfxBlur bail out in all cases where the blur rect is empty. r=tnikkel
This commit is contained in:
Родитель
629c1b7e18
Коммит
8498002a49
|
@ -66,9 +66,6 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect,
|
|||
rect.Outset(aBlurRadius + aSpreadRadius);
|
||||
rect.RoundOut();
|
||||
|
||||
if (rect.IsEmpty())
|
||||
return nsnull;
|
||||
|
||||
if (aDirtyRect) {
|
||||
// If we get passed a dirty rect from layout, we can minimize the
|
||||
// shadow size and make painting faster.
|
||||
|
@ -81,6 +78,12 @@ gfxAlphaBoxBlur::Init(const gfxRect& aRect,
|
|||
mHasDirtyRect = PR_FALSE;
|
||||
}
|
||||
|
||||
// Check rect empty after accounting for aDirtyRect, since that may have
|
||||
// make the rectangle empty. BoxBlurVertical and BoxBlurHorizontal require
|
||||
// that we have a nonzero number of rows and columns.
|
||||
if (rect.IsEmpty())
|
||||
return nsnull;
|
||||
|
||||
if (aSkipRect) {
|
||||
// If we get passed a skip rect, we can lower the amount of
|
||||
// blurring/spreading we need to do. We convert it to nsIntRect to avoid
|
||||
|
@ -138,6 +141,8 @@ BoxBlurHorizontal(unsigned char* aInput,
|
|||
PRInt32 aRows,
|
||||
const nsIntRect& aSkipRect)
|
||||
{
|
||||
NS_ASSERTION(aWidth > 0, "Can't handle zero width here");
|
||||
|
||||
PRInt32 boxSize = aLeftLobe + aRightLobe + 1;
|
||||
PRBool skipRectCoversWholeRow = 0 >= aSkipRect.x &&
|
||||
aWidth <= aSkipRect.XMost();
|
||||
|
@ -156,6 +161,8 @@ BoxBlurHorizontal(unsigned char* aInput,
|
|||
PRInt32 alphaSum = 0;
|
||||
for (PRInt32 i = 0; i < boxSize; i++) {
|
||||
PRInt32 pos = i - aLeftLobe;
|
||||
// See assertion above; if aWidth is zero, then we would have no
|
||||
// valid position to clamp to.
|
||||
pos = NS_MAX(pos, 0);
|
||||
pos = NS_MIN(pos, aWidth - 1);
|
||||
alphaSum += aInput[aWidth * y + pos];
|
||||
|
@ -174,6 +181,8 @@ BoxBlurHorizontal(unsigned char* aInput,
|
|||
alphaSum = 0;
|
||||
for (PRInt32 i = 0; i < boxSize; i++) {
|
||||
PRInt32 pos = x + i - aLeftLobe;
|
||||
// See assertion above; if aWidth is zero, then we would have no
|
||||
// valid position to clamp to.
|
||||
pos = NS_MAX(pos, 0);
|
||||
pos = NS_MIN(pos, aWidth - 1);
|
||||
alphaSum += aInput[aWidth * y + pos];
|
||||
|
@ -205,6 +214,8 @@ BoxBlurVertical(unsigned char* aInput,
|
|||
PRInt32 aRows,
|
||||
const nsIntRect& aSkipRect)
|
||||
{
|
||||
NS_ASSERTION(aRows > 0, "Can't handle zero rows here");
|
||||
|
||||
PRInt32 boxSize = aTopLobe + aBottomLobe + 1;
|
||||
PRBool skipRectCoversWholeColumn = 0 >= aSkipRect.y &&
|
||||
aRows <= aSkipRect.YMost();
|
||||
|
@ -220,6 +231,8 @@ BoxBlurVertical(unsigned char* aInput,
|
|||
PRInt32 alphaSum = 0;
|
||||
for (PRInt32 i = 0; i < boxSize; i++) {
|
||||
PRInt32 pos = i - aTopLobe;
|
||||
// See assertion above; if aRows is zero, then we would have no
|
||||
// valid position to clamp to.
|
||||
pos = NS_MAX(pos, 0);
|
||||
pos = NS_MIN(pos, aRows - 1);
|
||||
alphaSum += aInput[aWidth * pos + x];
|
||||
|
@ -234,6 +247,8 @@ BoxBlurVertical(unsigned char* aInput,
|
|||
alphaSum = 0;
|
||||
for (PRInt32 i = 0; i < boxSize; i++) {
|
||||
PRInt32 pos = y + i - aTopLobe;
|
||||
// See assertion above; if aRows is zero, then we would have no
|
||||
// valid position to clamp to.
|
||||
pos = NS_MAX(pos, 0);
|
||||
pos = NS_MIN(pos, aRows - 1);
|
||||
alphaSum += aInput[aWidth * pos + x];
|
||||
|
|
Загрузка…
Ссылка в новой задаче