When setting paint color/alpha, pin alpha to [0,1]
We used to just assert, but it turns out that Android has tests that explicitly set out-of-range alpha values (and disable our asserts). Bug: skia:11942 Bug: b/186543004 Change-Id: I167de7aba261ca3df579f9a0bddb0d90605e0094 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/465381 Reviewed-by: Greg Daniel <egdaniel@google.com> Commit-Queue: Brian Osman <brianosman@google.com>
This commit is contained in:
parent
378e4aecfe
commit
0dfb2d9679
@ -128,17 +128,14 @@ void SkPaint::setColor(SkColor color) {
|
||||
}
|
||||
|
||||
void SkPaint::setColor(const SkColor4f& color, SkColorSpace* colorSpace) {
|
||||
SkASSERT(fColor4f.fA >= 0 && fColor4f.fA <= 1.0f);
|
||||
|
||||
SkColorSpaceXformSteps steps{colorSpace, kUnpremul_SkAlphaType,
|
||||
sk_srgb_singleton(), kUnpremul_SkAlphaType};
|
||||
fColor4f = color;
|
||||
fColor4f = {color.fR, color.fG, color.fB, SkTPin(color.fA, 0.0f, 1.0f)};
|
||||
steps.apply(fColor4f.vec());
|
||||
}
|
||||
|
||||
void SkPaint::setAlphaf(float a) {
|
||||
SkASSERT(a >= 0 && a <= 1.0f);
|
||||
fColor4f.fA = a;
|
||||
fColor4f.fA = SkTPin(a, 0.0f, 1.0f);
|
||||
}
|
||||
|
||||
void SkPaint::setARGB(U8CPU a, U8CPU r, U8CPU g, U8CPU b) {
|
||||
|
Loading…
Reference in New Issue
Block a user