Work around overzealous assertion in SkMaskFilter.

When drawing nine-patch filters, we assert that the source contains the
destination. However, at least on the new analytic rect blur path, we can get
0-width destinations, and a 0-width rectangle is considered empty and therefore
*not contained in any other rectangle*, even if the bounds are valid and
numerically properly contained.

This patch makes sure we don't try to draw any of the four corners if they
are of 0 width or height. (The assert doesn't exist on the other codepaths.)



git-svn-id: http://skia.googlecode.com/svn/trunk@8860 2bbb7eff-a529-9590-31e7-b0007b416f81
This commit is contained in:
tomhudson@google.com 2013-04-25 16:56:40 +00:00
parent f2bfd54de3
commit 3c0ecc588b

View File

@ -69,34 +69,42 @@ static void draw_nine_clipped(const SkMask& mask, const SkIRect& outerR,
m.fBounds = mask.fBounds; m.fBounds = mask.fBounds;
m.fBounds.fRight = cx; m.fBounds.fRight = cx;
m.fBounds.fBottom = cy; m.fBounds.fBottom = cy;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m); extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.left(), outerR.top()); m.fBounds.offsetTo(outerR.left(), outerR.top());
blitClippedMask(blitter, m, m.fBounds, clipR); blitClippedMask(blitter, m, m.fBounds, clipR);
}
// top-right // top-right
m.fBounds = mask.fBounds; m.fBounds = mask.fBounds;
m.fBounds.fLeft = cx + 1; m.fBounds.fLeft = cx + 1;
m.fBounds.fBottom = cy; m.fBounds.fBottom = cy;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m); extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.right() - m.fBounds.width(), outerR.top()); m.fBounds.offsetTo(outerR.right() - m.fBounds.width(), outerR.top());
blitClippedMask(blitter, m, m.fBounds, clipR); blitClippedMask(blitter, m, m.fBounds, clipR);
}
// bottom-left // bottom-left
m.fBounds = mask.fBounds; m.fBounds = mask.fBounds;
m.fBounds.fRight = cx; m.fBounds.fRight = cx;
m.fBounds.fTop = cy + 1; m.fBounds.fTop = cy + 1;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m); extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.left(), outerR.bottom() - m.fBounds.height()); m.fBounds.offsetTo(outerR.left(), outerR.bottom() - m.fBounds.height());
blitClippedMask(blitter, m, m.fBounds, clipR); blitClippedMask(blitter, m, m.fBounds, clipR);
}
// bottom-right // bottom-right
m.fBounds = mask.fBounds; m.fBounds = mask.fBounds;
m.fBounds.fLeft = cx + 1; m.fBounds.fLeft = cx + 1;
m.fBounds.fTop = cy + 1; m.fBounds.fTop = cy + 1;
if (m.fBounds.width() > 0 && m.fBounds.height() > 0) {
extractMaskSubset(mask, &m); extractMaskSubset(mask, &m);
m.fBounds.offsetTo(outerR.right() - m.fBounds.width(), m.fBounds.offsetTo(outerR.right() - m.fBounds.width(),
outerR.bottom() - m.fBounds.height()); outerR.bottom() - m.fBounds.height());
blitClippedMask(blitter, m, m.fBounds, clipR); blitClippedMask(blitter, m, m.fBounds, clipR);
}
SkIRect innerR; SkIRect innerR;
innerR.set(outerR.left() + cx - mask.fBounds.left(), innerR.set(outerR.left() + cx - mask.fBounds.left(),