Index: src/gpu/GrFontScaler.cpp |
diff --git a/src/gpu/GrFontScaler.cpp b/src/gpu/GrFontScaler.cpp |
index 84fd58133c634f4936a5aae256280cfeeb575b2d..a9d5abff4e72eefcc4ce79ca4751d6568115fead 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 |