Don't draw as sprite when alpha, CF, or MF are present
This makes SkCanvas::drawImage() consistent with the AutoLayerForImageFilter
that applies when the draw isn't a sprite, or if drawImageRect or drawRect
with an image-shader was used instead.
Bug: skia:9561
Change-Id: Ic395f580b06753706ddcaed832535ec4edb3bb5a
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/274507
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/src/core/SkCanvas.cpp b/src/core/SkCanvas.cpp
index e9b0af9..7d5a475 100644
--- a/src/core/SkCanvas.cpp
+++ b/src/core/SkCanvas.cpp
@@ -2467,6 +2467,11 @@
return false;
}
+ // The other paint effects need to be applied before the image filter, but the sprite draw
+ // applies the filter explicitly first.
+ if (paint.getAlphaf() < 1.f || paint.getColorFilter() || paint.getMaskFilter()) {
+ return false;
+ }
// Currently we can only use the filterSprite code if we are clipped to the bitmap's bounds.
// Once we can filter and the filter will return a result larger than itself, we should be
// able to remove this constraint.