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

Side by Side Diff: src/gpu/GrBatchFontCache.h

Issue 1467133003: Remove unecessary GetGlyphIdMetrics call (Closed) Base URL: https://skia.googlesource.com/skia.git@temptext
Patch Set: added comment Created 5 years, 1 month 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 | « no previous file | src/gpu/GrBatchFontCache.cpp » ('j') | 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 * 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 25 matching lines...) Expand all
36 if (nullptr == glyph) { 36 if (nullptr == glyph) {
37 glyph = this->generateGlyph(skGlyph, packed, scaler); 37 glyph = this->generateGlyph(skGlyph, packed, scaler);
38 } 38 }
39 return glyph; 39 return glyph;
40 } 40 }
41 41
42 // This variant of the above function is called by TextBatch. At this point , it is possible 42 // This variant of the above function is called by TextBatch. At this point , it is possible
43 // that the maskformat of the glyph differs from what we expect. In these c ases we will just 43 // that the maskformat of the glyph differs from what we expect. In these c ases we will just
44 // draw a clear square. 44 // draw a clear square.
45 // skbug:4143 crbug:510931 45 // skbug:4143 crbug:510931
46 inline GrGlyph* getGlyph(const SkGlyph& skGlyph, GrGlyph::PackedID packed, 46 inline GrGlyph* getGlyph(GrGlyph::PackedID packed,
47 GrMaskFormat expectedMaskFormat, GrFontScaler* scal er) { 47 GrMaskFormat expectedMaskFormat,
48 GrFontScaler* scaler) {
48 GrGlyph* glyph = fCache.find(packed); 49 GrGlyph* glyph = fCache.find(packed);
49 if (nullptr == glyph) { 50 if (nullptr == glyph) {
51 // We could return this to the caller, but in practice it adds code complexity for
52 // potentially little benefit(ie, if the glyph is not in our font ca che, then its not
53 // in the atlas and we're going to be doing a texture upload anyways ).
54 const SkGlyph& skGlyph = scaler->grToSkGlyph(packed);
50 glyph = this->generateGlyph(skGlyph, packed, scaler); 55 glyph = this->generateGlyph(skGlyph, packed, scaler);
51 glyph->fMaskFormat = expectedMaskFormat; 56 glyph->fMaskFormat = expectedMaskFormat;
52 } 57 }
53 return glyph; 58 return glyph;
54 } 59 }
55 60
56 // returns true if glyph successfully added to texture atlas, false otherwis e. If the glyph's 61 // returns true if glyph successfully added to texture atlas, false otherwis e. If the glyph's
57 // mask format has changed, then addGlyphToAtlas will draw a clear box. Thi s will almost never 62 // mask format has changed, then addGlyphToAtlas will draw a clear box. Thi s will almost never
58 // happen. 63 // happen.
59 // TODO we can handle some of these cases if we really want to, but the long term solution is to 64 // TODO we can handle some of these cases if we really want to, but the long term solution is to
60 // get the actual glyph image itself when we get the glyph metrics. 65 // get the actual glyph image itself when we get the glyph metrics.
61 bool addGlyphToAtlas(GrDrawBatch::Target*, GrGlyph*, GrFontScaler*, const Sk Glyph&, 66 bool addGlyphToAtlas(GrDrawBatch::Target*, GrGlyph*, GrFontScaler*,
62 GrMaskFormat expectedMaskFormat); 67 GrMaskFormat expectedMaskFormat);
63 68
64 // testing 69 // testing
65 int countGlyphs() const { return fCache.count(); } 70 int countGlyphs() const { return fCache.count(); }
66 71
67 // remove any references to this plot 72 // remove any references to this plot
68 void removeID(GrBatchAtlas::AtlasID); 73 void removeID(GrBatchAtlas::AtlasID);
69 74
70 // If a TextStrike is abandoned by the cache, then the caller must get a new strike 75 // If a TextStrike is abandoned by the cache, then the caller must get a new strike
71 bool isAbandoned() const { return fIsAbandoned; } 76 bool isAbandoned() const { return fIsAbandoned; }
(...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after
214 static void HandleEviction(GrBatchAtlas::AtlasID, void*); 219 static void HandleEviction(GrBatchAtlas::AtlasID, void*);
215 220
216 GrContext* fContext; 221 GrContext* fContext;
217 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache; 222 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache;
218 GrBatchAtlas* fAtlases[kMaskFormatCount]; 223 GrBatchAtlas* fAtlases[kMaskFormatCount];
219 GrBatchTextStrike* fPreserveStrike; 224 GrBatchTextStrike* fPreserveStrike;
220 GrBatchAtlasConfig fAtlasConfigs[kMaskFormatCount]; 225 GrBatchAtlasConfig fAtlasConfigs[kMaskFormatCount];
221 }; 226 };
222 227
223 #endif 228 #endif
OLDNEW
« no previous file with comments | « no previous file | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698