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 #ifndef GrBatchFontCache_DEFINED | 8 #ifndef GrBatchFontCache_DEFINED |
9 #define GrBatchFontCache_DEFINED | 9 #define GrBatchFontCache_DEFINED |
10 | 10 |
(...skipping 22 matching lines...) Expand all Loading... |
33 | 33 |
34 inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed, | 34 inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed, |
35 GrFontScaler* scaler) { | 35 GrFontScaler* scaler) { |
36 GrGlyph* glyph = fCache.find(packed); | 36 GrGlyph* glyph = fCache.find(packed); |
37 if (NULL == glyph) { | 37 if (NULL == glyph) { |
38 glyph = this->generateGlyph(skGlyph, packed, scaler); | 38 glyph = this->generateGlyph(skGlyph, packed, scaler); |
39 } | 39 } |
40 return glyph; | 40 return glyph; |
41 } | 41 } |
42 | 42 |
| 43 // This variant of the above function is called by TextBatch. At this point
, it is possible |
| 44 // that the maskformat of the glyph differs from what we expect. In these c
ases we will just |
| 45 // draw a clear square. |
| 46 // skbug:4143 crbug:510931 |
| 47 inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed, |
| 48 GrMaskFormat expectedMaskFormat, GrFontScaler* scal
er) { |
| 49 GrGlyph* glyph = fCache.find(packed); |
| 50 if (NULL == glyph) { |
| 51 glyph = this->generateGlyph(skGlyph, packed, scaler); |
| 52 glyph->fMaskFormat = expectedMaskFormat; |
| 53 } |
| 54 return glyph; |
| 55 } |
| 56 |
43 // returns true if glyph successfully added to texture atlas, false otherwis
e. If the glyph's | 57 // returns true if glyph successfully added to texture atlas, false otherwis
e. If the glyph's |
44 // mask format has changed, then addGlyphToAtlas will draw a clear box. Thi
s will almost never | 58 // mask format has changed, then addGlyphToAtlas will draw a clear box. Thi
s will almost never |
45 // happen. | 59 // happen. |
46 // TODO we can handle some of these cases if we really want to, but the long
term solution is to | 60 // TODO we can handle some of these cases if we really want to, but the long
term solution is to |
47 // get the actual glyph image itself when we get the glyph metrics. | 61 // get the actual glyph image itself when we get the glyph metrics. |
48 bool addGlyphToAtlas(GrBatchTarget*, GrGlyph*, GrFontScaler*, const SkGlyph&
, | 62 bool addGlyphToAtlas(GrBatchTarget*, GrGlyph*, GrFontScaler*, const SkGlyph&
, |
49 GrMaskFormat expectedMaskFormat); | 63 GrMaskFormat expectedMaskFormat); |
50 | 64 |
51 // testing | 65 // testing |
52 int countGlyphs() const { return fCache.count(); } | 66 int countGlyphs() const { return fCache.count(); } |
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
196 | 210 |
197 static void HandleEviction(GrBatchAtlas::AtlasID, void*); | 211 static void HandleEviction(GrBatchAtlas::AtlasID, void*); |
198 | 212 |
199 GrContext* fContext; | 213 GrContext* fContext; |
200 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache; | 214 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache; |
201 GrBatchAtlas* fAtlases[kMaskFormatCount]; | 215 GrBatchAtlas* fAtlases[kMaskFormatCount]; |
202 GrBatchTextStrike* fPreserveStrike; | 216 GrBatchTextStrike* fPreserveStrike; |
203 }; | 217 }; |
204 | 218 |
205 #endif | 219 #endif |
OLD | NEW |