diff options
author | senorblanco <senorblanco@chromium.org> | 2016-01-12 07:49:15 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2016-01-12 07:49:15 -0800 |
commit | 05dcb4c7a9fe350af495e4cc53f8ad0cc9b79052 (patch) | |
tree | 2415b8f6e2f81cc934197cf36b73ee22747492af | |
parent | c63a0f8fe534eef8d52abc2066126729be9b497c (diff) |
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
-rw-r--r-- | src/effects/SkTileImageFilter.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
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); } |