From 05dcb4c7a9fe350af495e4cc53f8ad0cc9b79052 Mon Sep 17 00:00:00 2001 From: senorblanco Date: Tue, 12 Jan 2016 07:49:15 -0800 Subject: Optimize SkTileImageFilter in an offset filter when possible. If the srcRect and dstRect have the same size, tiling will have the same effect as an offset filter cropped to the intersection of srcRect and dstRect. So do that instead. BUG=569950 GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1578983002 Review URL: https://codereview.chromium.org/1578983002 --- src/effects/SkTileImageFilter.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp index ca4c15d419..844895c6d8 100644 --- a/src/effects/SkTileImageFilter.cpp +++ b/src/effects/SkTileImageFilter.cpp @@ -9,6 +9,7 @@ #include "SkBitmap.h" #include "SkCanvas.h" #include "SkDevice.h" +#include "SkOffsetImageFilter.h" #include "SkReadBuffer.h" #include "SkWriteBuffer.h" #include "SkMatrix.h" @@ -21,6 +22,16 @@ SkImageFilter* SkTileImageFilter::Create(const SkRect& srcRect, const SkRect& ds if (!SkIsValidRect(srcRect) || !SkIsValidRect(dstRect)) { return nullptr; } + if (srcRect.width() == dstRect.width() && srcRect.height() == dstRect.height()) { + SkRect ir = dstRect; + if (!ir.intersect(srcRect)) { + return SkSafeRef(input); + } + CropRect cropRect(ir); + return SkOffsetImageFilter::Create(dstRect.x() - srcRect.x(), + dstRect.y() - srcRect.y(), + input, &cropRect); + } return new SkTileImageFilter(srcRect, dstRect, input); } -- cgit v1.2.3