Optimize SkTileImageFilter destination bitmap size.

The destination bitmap size was not being clipped by the clip bounds,
so tiled rendering (ie., clipping to a small region and rendering
a SkTileImageFilter with a large dstRect) was much slower than
non-tiled rendering.

Correctness is covered by unit test ImageFilterDrawTiled, and
performance by TileImageFilterBench.

BUG=skia:
GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1563873002

Review URL: https://codereview.chromium.org/1563873002
This commit is contained in:
senorblanco 2016-01-06 09:46:24 -08:00 committed by Commit bot
parent 5b1dec7cde
commit b50b97d70a

View File

@ -35,6 +35,12 @@ bool SkTileImageFilter::onFilterImage(Proxy* proxy, const SkBitmap& src,
SkRect dstRect;
ctx.ctm().mapRect(&dstRect, fDstRect);
#ifndef SK_DISABLE_TILE_IMAGE_FILTER_DEST_OPTIMIZATION
if (!dstRect.intersect(SkRect::Make(ctx.clipBounds()))) {
offset->fX = offset->fY = 0;
return true;
}
#endif
const SkIRect dstIRect = dstRect.roundOut();
int w = dstIRect.width();
int h = dstIRect.height();