Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(327)

Unified Diff: src/effects/SkTileImageFilter.cpp

Issue 1578983002: Optimize SkTileImageFilter in an offset filter when possible. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix formatting. Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/effects/SkTileImageFilter.cpp
diff --git a/src/effects/SkTileImageFilter.cpp b/src/effects/SkTileImageFilter.cpp
index ca4c15d4191900fc644cdb3961096bcb8b4bf125..844895c6d827a9d103f6136293ec4a1f2d7db8cf 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);
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698