From 4f19ca325e8d0122e0a04345272d17e674460806 Mon Sep 17 00:00:00 2001 From: joshualitt Date: Thu, 30 Jul 2015 07:59:20 -0700 Subject: Dont try to draw glyphs with unexpected mask formats BUG=510931 Review URL: https://codereview.chromium.org/1269743003 --- src/gpu/GrFontScaler.cpp | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) (limited to 'src/gpu/GrFontScaler.cpp') diff --git a/src/gpu/GrFontScaler.cpp b/src/gpu/GrFontScaler.cpp index 84fd58133c..a9d5abff4e 100644 --- a/src/gpu/GrFontScaler.cpp +++ b/src/gpu/GrFontScaler.cpp @@ -103,7 +103,7 @@ void expand_bits(INT_TYPE* dst, } bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int height, int dstRB, - void* dst) { + GrMaskFormat expectedMaskFormat, void* dst) { SkASSERT(glyph.fWidth == width); SkASSERT(glyph.fHeight == height); const void* src = fStrike->findImage(glyph); @@ -111,6 +111,18 @@ bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig return false; } + // crbug:510931 + // Retrieving the image from the cache can actually change the mask format. This case is very + // uncommon so for now we just draw a clear box for these glyphs. + if (getPackedGlyphMaskFormat(glyph) != expectedMaskFormat) { + const int bpp = GrMaskFormatBytesPerPixel(expectedMaskFormat); + for (int y = 0; y < height; y++) { + sk_bzero(dst, width * bpp); + dst = (char*)dst + dstRB; + } + return true; + } + int srcRB = glyph.rowBytes(); // The windows font host sometimes has BW glyphs in a non-BW strike. So it is important here to // check the glyph's format, not the strike's format, and to be able to convert to any of the -- cgit v1.2.3