From 6db83e2584a30b1339adba18279fbfd527a10ce7 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 23 Sep 2019 10:33:20 +0200 Subject: [PATCH] Fix crash with gamma-corrected text blending disabled Change-Id: I7e3ca78278bf8bf2dda44711eb57d64aa6f455ce Reviewed-by: Eirik Aavitsland --- src/gui/painting/qdrawhelper.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/gui/painting/qdrawhelper.cpp b/src/gui/painting/qdrawhelper.cpp index 3d06a27d8e..e5f752b94e 100644 --- a/src/gui/painting/qdrawhelper.cpp +++ b/src/gui/painting/qdrawhelper.cpp @@ -5670,7 +5670,8 @@ static inline void alphamapblend_argb32(quint32 *dst, int coverage, QRgba64 srcL QRgb s = *dst; blend_pixel(s, src); // Then gamma-corrected blend with glyph shape - grayBlendPixel(dst, coverage, colorProfile->toLinear64(s), colorProfile); + QRgba64 s64 = colorProfile ? colorProfile->toLinear64(s) : QRgba64::fromArgb32(s); + grayBlendPixel(dst, coverage, s64, colorProfile); } } @@ -5711,7 +5712,9 @@ static inline void alphamapblend_generic(int coverage, QRgba64 *dest, int x, con QRgba64 s = dest[x]; blend_pixel(s, src); // Then gamma-corrected blend with glyph shape - grayBlendPixel(dest[x], coverage, colorProfile->toLinear(s), colorProfile); + if (colorProfile) + s = colorProfile->toLinear(s); + grayBlendPixel(dest[x], coverage, s, colorProfile); } } @@ -6053,7 +6056,8 @@ static inline void alphargbblend_argb32(quint32 *dst, uint coverage, const QRgba QRgb s = *dst; blend_pixel(s, src); // Then gamma-corrected blend with glyph shape - rgbBlendPixel(dst, coverage, colorProfile->toLinear64(s), colorProfile); + QRgba64 s64 = colorProfile ? colorProfile->toLinear64(s) : QRgba64::fromArgb32(s); + rgbBlendPixel(dst, coverage, s64, colorProfile); } } @@ -6084,7 +6088,9 @@ static inline void alphargbblend_generic(uint coverage, QRgba64 *dest, int x, co QRgba64 s = dest[x]; blend_pixel(s, src); // Then gamma-corrected blend with glyph shape - rgbBlendPixel(dest[x], coverage, colorProfile->toLinear(s), colorProfile); + if (colorProfile) + s = colorProfile->toLinear(s); + rgbBlendPixel(dest[x], coverage, s, colorProfile); } }