Chromium Code Reviews| Index: src/gpu/GrFontScaler.cpp |
| diff --git a/src/gpu/GrFontScaler.cpp b/src/gpu/GrFontScaler.cpp |
| index 84fd58133c634f4936a5aae256280cfeeb575b2d..a06de4f85aecf7e1ab1b53e74eb1eb27f209559b 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. |
|
robertphillips
2015/07/30 14:36:26
this->getPackedGlyphMaskFormat ?
|
| + 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 |
| @@ -118,7 +130,7 @@ bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig |
| if (SkMask::kBW_Format == glyph.fMaskFormat) { |
| // expand bits to our mask type |
| const uint8_t* bits = reinterpret_cast<const uint8_t*>(src); |
|
robertphillips
2015/07/30 14:36:26
what happened to the "this->" ?
|
| - switch (this->getMaskFormat()) { |
| + switch (getMaskFormat()) { |
| case kA8_GrMaskFormat:{ |
| uint8_t* bytes = reinterpret_cast<uint8_t*>(dst); |
| expand_bits(bytes, bits, width, height, dstRB, srcRB); |
| @@ -135,9 +147,9 @@ bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig |
| } else if (srcRB == dstRB) { |
| memcpy(dst, src, dstRB * height); |
| } else { |
|
robertphillips
2015/07/30 14:36:26
here too ?
|
| - const int bbp = GrMaskFormatBytesPerPixel(this->getMaskFormat()); |
| + const int bpp = GrMaskFormatBytesPerPixel(getMaskFormat()); |
| for (int y = 0; y < height; y++) { |
| - memcpy(dst, src, width * bbp); |
| + memcpy(dst, src, width * bpp); |
| src = (const char*)src + srcRB; |
| dst = (char*)dst + dstRB; |
| } |
| @@ -152,6 +164,7 @@ bool GrFontScaler::getPackedGlyphDFImage(const SkGlyph& glyph, int width, int he |
| if (NULL == image) { |
| return false; |
| } |
| + |
| // now generate the distance field |
| SkASSERT(dst); |
| SkMask::Format maskFormat = static_cast<SkMask::Format>(glyph.fMaskFormat); |