Ensure default SkPaints w/ dither don't get dithered

Skipping dithering of const paints was originally added in:

https://skia-review.googlesource.com/c/skia/+/19880/

Change-Id: Icebca1c3ef779bb103030deac12621619f5ce248
Reviewed-on: https://skia-review.googlesource.com/c/skia/+/437116
Reviewed-by: Florin Malita <fmalita@chromium.org>
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
This commit is contained in:
Robert Phillips 2021-08-05 16:15:19 -04:00 committed by SkCQ
parent 4cb0c37c96
commit 7386dc7941
2 changed files with 11 additions and 2 deletions

View File

@ -61,8 +61,8 @@ bool SkPaintPriv::ShouldDither(const SkPaint& p, SkColorType dstCT) {
} }
// Otherwise, dither is only needed for non-const paints. // Otherwise, dither is only needed for non-const paints.
return p.getImageFilter() || p.getMaskFilter() return p.getImageFilter() || p.getMaskFilter() ||
|| !p.getShader() || !as_SB(p.getShader())->isConstant(); (p.getShader() && !as_SB(p.getShader())->isConstant());
} }
// return true if the paint is just a single color (i.e. not a shader). If its // return true if the paint is just a single color (i.e. not a shader). If its

View File

@ -230,3 +230,12 @@ DEF_TEST(Font_getpos, r) {
} }
} }
} }
DEF_TEST(Paint_dither, reporter) {
SkPaint p;
p.setDither(true);
bool shouldDither = SkPaintPriv::ShouldDither(p, kBGRA_8888_SkColorType);
REPORTER_ASSERT(reporter, !shouldDither);
}