OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2015 Google Inc. | 2 * Copyright 2015 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "GrBatchFontCache.h" | 8 #include "GrBatchFontCache.h" |
9 #include "GrContext.h" | 9 #include "GrContext.h" |
10 #include "GrFontAtlasSizes.h" | 10 #include "GrFontAtlasSizes.h" |
(...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
194 ++iter; | 194 ++iter; |
195 } | 195 } |
196 } | 196 } |
197 | 197 |
198 bool GrBatchTextStrike::addGlyphToAtlas(GrBatchTarget* batchTarget, GrGlyph* gly
ph, | 198 bool GrBatchTextStrike::addGlyphToAtlas(GrBatchTarget* batchTarget, GrGlyph* gly
ph, |
199 GrFontScaler* scaler, const SkGlyph& skG
lyph, | 199 GrFontScaler* scaler, const SkGlyph& skG
lyph, |
200 GrMaskFormat expectedMaskFormat) { | 200 GrMaskFormat expectedMaskFormat) { |
201 SkASSERT(glyph); | 201 SkASSERT(glyph); |
202 SkASSERT(scaler); | 202 SkASSERT(scaler); |
203 SkASSERT(fCache.find(glyph->fPackedID)); | 203 SkASSERT(fCache.find(glyph->fPackedID)); |
204 SkASSERT(NULL == glyph->fPlot); | |
205 | 204 |
206 SkAutoUnref ar(SkSafeRef(scaler)); | 205 SkAutoUnref ar(SkSafeRef(scaler)); |
207 | 206 |
208 int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat); | 207 int bytesPerPixel = GrMaskFormatBytesPerPixel(expectedMaskFormat); |
209 | 208 |
210 size_t size = glyph->fBounds.area() * bytesPerPixel; | 209 size_t size = glyph->fBounds.area() * bytesPerPixel; |
211 SkAutoSMalloc<1024> storage(size); | 210 SkAutoSMalloc<1024> storage(size); |
212 | 211 |
213 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI
D)) { | 212 if (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPackedI
D)) { |
214 if (!scaler->getPackedGlyphDFImage(skGlyph, glyph->width(), glyph->heigh
t(), | 213 if (!scaler->getPackedGlyphDFImage(skGlyph, glyph->width(), glyph->heigh
t(), |
215 storage.get())) { | 214 storage.get())) { |
216 return false; | 215 return false; |
217 } | 216 } |
218 } else { | 217 } else { |
219 if (!scaler->getPackedGlyphImage(skGlyph, glyph->width(), glyph->height(
), | 218 if (!scaler->getPackedGlyphImage(skGlyph, glyph->width(), glyph->height(
), |
220 glyph->width() * bytesPerPixel, expecte
dMaskFormat, | 219 glyph->width() * bytesPerPixel, expecte
dMaskFormat, |
221 storage.get())) { | 220 storage.get())) { |
222 return false; | 221 return false; |
223 } | 222 } |
224 } | 223 } |
225 | 224 |
226 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, e
xpectedMaskFormat, | 225 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, e
xpectedMaskFormat, |
227 glyph->width(), glyph->height(), | 226 glyph->width(), glyph->height(), |
228 storage.get(), &glyph->fAtlasLoca
tion); | 227 storage.get(), &glyph->fAtlasLoca
tion); |
229 if (success) { | 228 if (success) { |
230 fAtlasedGlyphs++; | 229 fAtlasedGlyphs++; |
231 } | 230 } |
232 return success; | 231 return success; |
233 } | 232 } |
OLD | NEW |