From 91a026ea650c7bc794fc984592e1fe74b1a6773c Mon Sep 17 00:00:00 2001 From: Moonchild Date: Wed, 28 May 2025 12:27:24 +0200 Subject: [PATCH] No issue - Set device contrast to an acceptable value if OOB. On Mac and Win+DW, enhanced device contrast can possibly not be set. This throws Skia for a loop by passing in an OOB scalar to its init. Work around this by setting an accepted average value that helps prevent font wash-out while not causing fringing. --- gfx/skia/skia/src/core/SkScalerContext.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gfx/skia/skia/src/core/SkScalerContext.h b/gfx/skia/skia/src/core/SkScalerContext.h index 48ec0624cf..b1748bd0ee 100644 --- a/gfx/skia/skia/src/core/SkScalerContext.h +++ b/gfx/skia/skia/src/core/SkScalerContext.h @@ -73,8 +73,11 @@ struct SkScalerContextRec { return SkIntToScalar(fContrast) / ((1 << 8) - 1); } void setContrast(SkScalar c) { - SkASSERT(0 <= c && c <= SK_Scalar1); - fContrast = SkScalarRoundToInt(c * ((1 << 8) - 1)); + if (0 <= c && c <= SK_Scalar1) { + fContrast = SkScalarRoundToInt(c * ((1 << 8) - 1)); + } else { + fContrast = SkScalarRoundToInt(0.5f * ((1 << 8) - 1)); + } } /**