Fix local matrix for crop rects in backdrop image filters
Bug: chromium:955467
Change-Id: I1c4cae2499db926aa6b629e8d730fcc8cb45be6d
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/212030
Reviewed-by: Robert Phillips <robertphillips@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index e021fb5..1df0f72 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -938,13 +938,17 @@
draw.fMatrix = &SkMatrix::I();
draw.fRC = &rc;
- SkPaint p;
- if (filter) {
- p.setImageFilter(filter->makeWithLocalMatrix(ctm));
- }
-
int x = src->getOrigin().x() - dstOrigin.x();
int y = src->getOrigin().y() - dstOrigin.y();
+
+ SkPaint p;
+ if (filter) {
+ SkMatrix actm = ctm;
+ // Account for the origin offset in the local matrix
+ actm.postTranslate(x, y);
+ p.setImageFilter(filter->makeWithLocalMatrix(actm));
+ }
+
auto special = src->snapSpecial();
if (special) {
dst->drawSpecial(special.get(), x, y, p, nullptr, SkMatrix::I());