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>
This commit is contained in:
Michael Ludwig 2020-11-10 16:33:11 -05:00 committed by Skia Commit-Bot
parent 6ba3be1d96
commit 4757a60871
2 changed files with 13 additions and 3 deletions

View File

@ -312,9 +312,16 @@ public:
* 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.

View File

@ -194,10 +194,13 @@ sk_sp<SkImageFilter> SkImageFilters::Picture(sk_sp<SkPicture> pic, const SkRect&
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);
}