Accept SkFilterQuality in SkImageFilters::Shader
This is needed to help ease the migration from SkImageFilters::Paint,
until image shaders always force you to embed sampling options.
Change-Id: Id8dc8c3196a7935073677a5fbb8d35c3bd22f9ba
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/333757
Auto-Submit: Michael Ludwig <michaelludwig@google.com>
Reviewed-by: Mike Reed <reed@google.com>
Commit-Queue: Michael Ludwig <michaelludwig@google.com>
diff --git a/include/effects/SkImageFilters.h b/include/effects/SkImageFilters.h
index 0295c0d..f2dc34a 100644
--- a/include/effects/SkImageFilters.h
+++ b/include/effects/SkImageFilters.h
@@ -312,9 +312,16 @@
* Like Image() and Picture(), this is a leaf filter that can be used to introduce inputs to
* a complex filter graph, but should generally be combined with a filter that as at least
* one null input to use the implicit source image.
- * @param shader The shader that
+ * @param shader The shader that fills the result image
*/
- static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, const CropRect& cropRect = {});
+ static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, const CropRect& cropRect = {}) {
+ return Shader(std::move(shader), kNone_SkFilterQuality, cropRect);
+ }
+ // As above, but the filter quality defines what is used in image shaders that defer to the
+ // quality stored on an SkPaint. NOTE: this default behavior is deprecated, so prefer creating
+ // image shaders with explicit sampling parameters and call the 2-arg Shader() factory instead.
+ static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, SkFilterQuality filterQuality,
+ const CropRect& cropRect = {});
/**
* Create a tile image filter.
diff --git a/src/effects/imagefilters/SkImageFilters.cpp b/src/effects/imagefilters/SkImageFilters.cpp
index bb5c9a0..a33abe0 100644
--- a/src/effects/imagefilters/SkImageFilters.cpp
+++ b/src/effects/imagefilters/SkImageFilters.cpp
@@ -194,10 +194,13 @@
return SkPictureImageFilter::Make(std::move(pic), targetRect);
}
-sk_sp<SkImageFilter> SkImageFilters::Shader(sk_sp<SkShader> shader, const CropRect& cropRect) {
+sk_sp<SkImageFilter> SkImageFilters::Shader(sk_sp<SkShader> shader, SkFilterQuality filterQuality,
+ const CropRect& cropRect) {
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
SkPaint paint;
paint.setShader(std::move(shader));
+ // For SkImage::makeShader() shaders using SkImageShader::kInheritFromPaint sampling options
+ paint.setFilterQuality(filterQuality);
return SkPaintImageFilter::Make(paint, &r);
}