Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(564)

Side by Side Diff: src/gpu/GrFontScaler.cpp

Issue 1269743003: Dont try to draw glyphs with unexpected mask formats (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: tweaks Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/gpu/GrFontScaler.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 1
2 /* 2 /*
3 * Copyright 2010 Google Inc. 3 * Copyright 2010 Google Inc.
4 * 4 *
5 * Use of this source code is governed by a BSD-style license that can be 5 * Use of this source code is governed by a BSD-style license that can be
6 * found in the LICENSE file. 6 * found in the LICENSE file.
7 */ 7 */
8 8
9 #include "GrFontScaler.h" 9 #include "GrFontScaler.h"
10 #include "SkDescriptor.h" 10 #include "SkDescriptor.h"
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
96 *d++ = (mask & (1 << i)) ? (INT_TYPE)(~0UL) : 0; 96 *d++ = (mask & (1 << i)) ? (INT_TYPE)(~0UL) : 0;
97 } 97 }
98 } 98 }
99 dst = reinterpret_cast<INT_TYPE*>(reinterpret_cast<intptr_t>(dst) + dstR owBytes); 99 dst = reinterpret_cast<INT_TYPE*>(reinterpret_cast<intptr_t>(dst) + dstR owBytes);
100 src += srcRowBytes; 100 src += srcRowBytes;
101 } 101 }
102 } 102 }
103 } 103 }
104 104
105 bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig ht, int dstRB, 105 bool GrFontScaler::getPackedGlyphImage(const SkGlyph& glyph, int width, int heig ht, int dstRB,
106 void* dst) { 106 GrMaskFormat expectedMaskFormat, void* ds t) {
107 SkASSERT(glyph.fWidth == width); 107 SkASSERT(glyph.fWidth == width);
108 SkASSERT(glyph.fHeight == height); 108 SkASSERT(glyph.fHeight == height);
109 const void* src = fStrike->findImage(glyph); 109 const void* src = fStrike->findImage(glyph);
110 if (NULL == src) { 110 if (NULL == src) {
111 return false; 111 return false;
112 } 112 }
113 113
114 // crbug:510931
115 // Retrieving the image from the cache can actually change the mask format. This case is very
116 // uncommon so for now we just draw a clear box for these glyphs.
117 if (getPackedGlyphMaskFormat(glyph) != expectedMaskFormat) {
118 const int bpp = GrMaskFormatBytesPerPixel(expectedMaskFormat);
119 for (int y = 0; y < height; y++) {
120 sk_bzero(dst, width * bpp);
121 dst = (char*)dst + dstRB;
122 }
123 return true;
124 }
125
114 int srcRB = glyph.rowBytes(); 126 int srcRB = glyph.rowBytes();
115 // The windows font host sometimes has BW glyphs in a non-BW strike. So it i s important here to 127 // The windows font host sometimes has BW glyphs in a non-BW strike. So it i s important here to
116 // check the glyph's format, not the strike's format, and to be able to conv ert to any of the 128 // check the glyph's format, not the strike's format, and to be able to conv ert to any of the
117 // GrMaskFormats. 129 // GrMaskFormats.
118 if (SkMask::kBW_Format == glyph.fMaskFormat) { 130 if (SkMask::kBW_Format == glyph.fMaskFormat) {
119 // expand bits to our mask type 131 // expand bits to our mask type
120 const uint8_t* bits = reinterpret_cast<const uint8_t*>(src); 132 const uint8_t* bits = reinterpret_cast<const uint8_t*>(src);
121 switch (this->getMaskFormat()) { 133 switch (this->getMaskFormat()) {
122 case kA8_GrMaskFormat:{ 134 case kA8_GrMaskFormat:{
123 uint8_t* bytes = reinterpret_cast<uint8_t*>(dst); 135 uint8_t* bytes = reinterpret_cast<uint8_t*>(dst);
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
176 188
177 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) { 189 const SkPath* GrFontScaler::getGlyphPath(const SkGlyph& glyph) {
178 return fStrike->findPath(glyph); 190 return fStrike->findPath(glyph);
179 } 191 }
180 192
181 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) { 193 const SkGlyph& GrFontScaler::grToSkGlyph(GrGlyph::PackedID id) {
182 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id), 194 return fStrike->getGlyphIDMetrics(GrGlyph::UnpackID(id),
183 GrGlyph::UnpackFixedX(id), 195 GrGlyph::UnpackFixedX(id),
184 GrGlyph::UnpackFixedY(id)); 196 GrGlyph::UnpackFixedY(id));
185 } 197 }
OLDNEW
« no previous file with comments | « src/gpu/GrFontScaler.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698