Preserve dithering for SkImageFilters::Shader
Migrating chromium code to use SkImageFilters::Shader over SkPaintImageFilter requires dithering to be preserved for its gradient fills. I debated always forcing it to true, but dithering was never turned on for the turbulence filter and it's not necessary for const color shaders Given that, I opted to just make it a parameter to the filter factory, which seems okay since we're unlikely to embed dithering into SkShader itself, it's a shading-related parameter of SkPaint, and if we migrate to always dithering, then we can remove it. Bug: skia:9310 Change-Id: I86f14969e2446f3a84e71e687cb263bcd44cf9d9 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/338156 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:
parent
dd7783f4ce
commit
a2c40206c6
@ -6,6 +6,8 @@ This file includes a list of high level updates for each milestone release.
|
||||
|
||||
Milestone 89
|
||||
------------
|
||||
* Added dither control to the SkImageFilters::Shader factory.
|
||||
https://review.skia.org/338156
|
||||
|
||||
* Add MTLBinaryArchive parameter to GrMtlBackendContext. This allows
|
||||
Skia to cache PipelineStates in the given archive for faster
|
||||
|
@ -304,6 +304,11 @@ public:
|
||||
return Picture(std::move(pic), target);
|
||||
}
|
||||
|
||||
enum class Dither : bool {
|
||||
kNo = false,
|
||||
kYes = true
|
||||
};
|
||||
|
||||
/**
|
||||
* Create a filter that fills the output with the per-pixel evaluation of the SkShader. The
|
||||
* shader is defined in the image filter's local coordinate system, so will automatically
|
||||
@ -315,12 +320,17 @@ public:
|
||||
* @param shader The shader that fills the result image
|
||||
*/
|
||||
static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, const CropRect& cropRect = {}) {
|
||||
return Shader(std::move(shader), kNone_SkFilterQuality, cropRect);
|
||||
return Shader(std::move(shader), Dither::kNo, cropRect);
|
||||
}
|
||||
static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, Dither dither,
|
||||
const CropRect& cropRect = {}) {
|
||||
return Shader(std::move(shader), dither, 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,
|
||||
// image shaders with explicit sampling parameters and call the other Shader() factory instead.
|
||||
static sk_sp<SkImageFilter> Shader(sk_sp<SkShader> shader, Dither dither,
|
||||
SkFilterQuality filterQuality,
|
||||
const CropRect& cropRect = {});
|
||||
|
||||
/**
|
||||
|
@ -194,11 +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, SkFilterQuality filterQuality,
|
||||
sk_sp<SkImageFilter> SkImageFilters::Shader(sk_sp<SkShader> shader, Dither dither,
|
||||
SkFilterQuality filterQuality,
|
||||
const CropRect& cropRect) {
|
||||
SkImageFilter::CropRect r = to_legacy_crop_rect(cropRect);
|
||||
SkPaint paint;
|
||||
paint.setShader(std::move(shader));
|
||||
paint.setDither((bool) dither);
|
||||
// For SkImage::makeShader() shaders using SkImageShader::kInheritFromPaint sampling options
|
||||
paint.setFilterQuality(filterQuality);
|
||||
return SkPaintImageFilter::Make(paint, &r);
|
||||
|
Loading…
Reference in New Issue
Block a user