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 "GrFontAtlasSizes.h" | 9 #include "GrFontAtlasSizes.h" |
10 #include "GrGpu.h" | 10 #include "GrGpu.h" |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
195 while (!iter.done()) { | 195 while (!iter.done()) { |
196 if (id == (*iter).fID) { | 196 if (id == (*iter).fID) { |
197 (*iter).fID = GrBatchAtlas::kInvalidAtlasID; | 197 (*iter).fID = GrBatchAtlas::kInvalidAtlasID; |
198 fAtlasedGlyphs--; | 198 fAtlasedGlyphs--; |
199 SkASSERT(fAtlasedGlyphs >= 0); | 199 SkASSERT(fAtlasedGlyphs >= 0); |
200 } | 200 } |
201 ++iter; | 201 ++iter; |
202 } | 202 } |
203 } | 203 } |
204 | 204 |
205 bool GrBatchTextStrike::glyphTooLargeForAtlas(GrGlyph* glyph) { | |
206 int width = glyph->fBounds.width(); | |
207 int height = glyph->fBounds.height(); | |
208 bool useDistanceField = | |
209 (GrGlyph::kDistance_MaskStyle == GrGlyph::UnpackMaskStyle(glyph->fPa
ckedID)); | |
210 int pad = useDistanceField ? 2 * SK_DistanceFieldPad : 0; | |
211 int plotWidth = (kA8_GrMaskFormat == glyph->fMaskFormat) ? GR_FONT_ATLAS_A8_
PLOT_WIDTH | |
212 : GR_FONT_ATLAS_PLO
T_WIDTH; | |
213 if (width + pad > plotWidth) { | |
214 return true; | |
215 } | |
216 if (height + pad > GR_FONT_ATLAS_PLOT_HEIGHT) { | |
217 return true; | |
218 } | |
219 | |
220 return false; | |
221 } | |
222 | |
223 bool GrBatchTextStrike::addGlyphToAtlas(GrBatchTarget* batchTarget, GrGlyph* gly
ph, | 205 bool GrBatchTextStrike::addGlyphToAtlas(GrBatchTarget* batchTarget, GrGlyph* gly
ph, |
224 GrFontScaler* scaler) { | 206 GrFontScaler* scaler) { |
225 SkASSERT(glyph); | 207 SkASSERT(glyph); |
226 SkASSERT(scaler); | 208 SkASSERT(scaler); |
227 SkASSERT(fCache.find(glyph->fPackedID)); | 209 SkASSERT(fCache.find(glyph->fPackedID)); |
228 SkASSERT(NULL == glyph->fPlot); | 210 SkASSERT(NULL == glyph->fPlot); |
229 | 211 |
230 SkAutoUnref ar(SkSafeRef(scaler)); | 212 SkAutoUnref ar(SkSafeRef(scaler)); |
231 | 213 |
232 int bytesPerPixel = GrMaskFormatBytesPerPixel(glyph->fMaskFormat); | 214 int bytesPerPixel = GrMaskFormatBytesPerPixel(glyph->fMaskFormat); |
(...skipping 17 matching lines...) Expand all Loading... |
250 } | 232 } |
251 | 233 |
252 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, g
lyph->fMaskFormat, | 234 bool success = fBatchFontCache->addToAtlas(this, &glyph->fID, batchTarget, g
lyph->fMaskFormat, |
253 glyph->width(), glyph->height(), | 235 glyph->width(), glyph->height(), |
254 storage.get(), &glyph->fAtlasLoca
tion); | 236 storage.get(), &glyph->fAtlasLoca
tion); |
255 if (success) { | 237 if (success) { |
256 fAtlasedGlyphs++; | 238 fAtlasedGlyphs++; |
257 } | 239 } |
258 return success; | 240 return success; |
259 } | 241 } |
OLD | NEW |