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

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

Issue 1286043004: Make GrVertexBatch objects hold their own draws during GrDrawTarget flush (Closed) Base URL: https://skia.googlesource.com/skia.git@m
Patch Set: forward decl 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/GrBatchFlushState.cpp ('k') | 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
11 #include "GrBatchAtlas.h" 11 #include "GrBatchAtlas.h"
12 #include "GrFontScaler.h" 12 #include "GrFontScaler.h"
13 #include "GrGlyph.h" 13 #include "GrGlyph.h"
14 #include "SkGlyph.h" 14 #include "SkGlyph.h"
15 #include "SkTDynamicHash.h" 15 #include "SkTDynamicHash.h"
16 #include "SkVarAlloc.h" 16 #include "SkVarAlloc.h"
17 17
18 class GrBatchFontCache; 18 class GrBatchFontCache;
19 class GrBatchTarget;
20 class GrGpu; 19 class GrGpu;
21 20
22 /** 21 /**
23 * The GrBatchTextStrike manages a pool of CPU backing memory for GrGlyphs. Th is backing memory 22 * The GrBatchTextStrike manages a pool of CPU backing memory for GrGlyphs. Th is backing memory
24 * is indexed by a PackedID and GrFontScaler. The GrFontScaler is what actuall y creates the mask. 23 * is indexed by a PackedID and GrFontScaler. The GrFontScaler is what actuall y creates the mask.
25 */ 24 */
26 class GrBatchTextStrike : public SkNVRefCnt<GrBatchTextStrike> { 25 class GrBatchTextStrike : public SkNVRefCnt<GrBatchTextStrike> {
27 public: 26 public:
28 GrBatchTextStrike(GrBatchFontCache*, const GrFontDescKey* fontScalerKey); 27 GrBatchTextStrike(GrBatchFontCache*, const GrFontDescKey* fontScalerKey);
29 ~GrBatchTextStrike(); 28 ~GrBatchTextStrike();
(...skipping 22 matching lines...) Expand all
52 glyph->fMaskFormat = expectedMaskFormat; 51 glyph->fMaskFormat = expectedMaskFormat;
53 } 52 }
54 return glyph; 53 return glyph;
55 } 54 }
56 55
57 // returns true if glyph successfully added to texture atlas, false otherwis e. If the glyph's 56 // returns true if glyph successfully added to texture atlas, false otherwis e. If the glyph's
58 // mask format has changed, then addGlyphToAtlas will draw a clear box. Thi s will almost never 57 // mask format has changed, then addGlyphToAtlas will draw a clear box. Thi s will almost never
59 // happen. 58 // happen.
60 // TODO we can handle some of these cases if we really want to, but the long term solution is to 59 // TODO we can handle some of these cases if we really want to, but the long term solution is to
61 // get the actual glyph image itself when we get the glyph metrics. 60 // get the actual glyph image itself when we get the glyph metrics.
62 bool addGlyphToAtlas(GrBatchTarget*, GrGlyph*, GrFontScaler*, const SkGlyph& , 61 bool addGlyphToAtlas(GrDrawBatch::Target*, GrGlyph*, GrFontScaler*, const Sk Glyph&,
63 GrMaskFormat expectedMaskFormat); 62 GrMaskFormat expectedMaskFormat);
64 63
65 // testing 64 // testing
66 int countGlyphs() const { return fCache.count(); } 65 int countGlyphs() const { return fCache.count(); }
67 66
68 // remove any references to this plot 67 // remove any references to this plot
69 void removeID(GrBatchAtlas::AtlasID); 68 void removeID(GrBatchAtlas::AtlasID);
70 69
71 // If a TextStrike is abandoned by the cache, then the caller must get a new strike 70 // If a TextStrike is abandoned by the cache, then the caller must get a new strike
72 bool isAbandoned() const { return fIsAbandoned; } 71 bool isAbandoned() const { return fIsAbandoned; }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 } 126 }
128 return NULL; 127 return NULL;
129 } 128 }
130 129
131 bool hasGlyph(GrGlyph* glyph) { 130 bool hasGlyph(GrGlyph* glyph) {
132 SkASSERT(glyph); 131 SkASSERT(glyph);
133 return this->getAtlas(glyph->fMaskFormat)->hasID(glyph->fID); 132 return this->getAtlas(glyph->fMaskFormat)->hasID(glyph->fID);
134 } 133 }
135 134
136 // To ensure the GrBatchAtlas does not evict the Glyph Mask from its texture backing store, 135 // To ensure the GrBatchAtlas does not evict the Glyph Mask from its texture backing store,
137 // the client must pass in the currentToken from the GrBatchTarget along wit h the GrGlyph. 136 // the client must pass in the current batch token along with the GrGlyph.
138 // A BulkUseTokenUpdater is used to manage bulk last use token updating in t he Atlas. 137 // A BulkUseTokenUpdater is used to manage bulk last use token updating in t he Atlas.
139 // For convenience, this function will also set the use token for the curren t glyph if required 138 // For convenience, this function will also set the use token for the curren t glyph if required
140 // NOTE: the bulk uploader is only valid if the subrun has a valid atlasGene ration 139 // NOTE: the bulk uploader is only valid if the subrun has a valid atlasGene ration
141 void addGlyphToBulkAndSetUseToken(GrBatchAtlas::BulkUseTokenUpdater* updater , 140 void addGlyphToBulkAndSetUseToken(GrBatchAtlas::BulkUseTokenUpdater* updater ,
142 GrGlyph* glyph, GrBatchAtlas::BatchToken t oken) { 141 GrGlyph* glyph, GrBatchToken token) {
143 SkASSERT(glyph); 142 SkASSERT(glyph);
144 updater->add(glyph->fID); 143 updater->add(glyph->fID);
145 this->getAtlas(glyph->fMaskFormat)->setLastUseToken(glyph->fID, token); 144 this->getAtlas(glyph->fMaskFormat)->setLastUseToken(glyph->fID, token);
146 } 145 }
147 146
148 void setUseTokenBulk(const GrBatchAtlas::BulkUseTokenUpdater& updater, 147 void setUseTokenBulk(const GrBatchAtlas::BulkUseTokenUpdater& updater,
149 GrBatchAtlas::BatchToken token, 148 GrBatchToken token,
150 GrMaskFormat format) { 149 GrMaskFormat format) {
151 this->getAtlas(format)->setLastUseTokenBulk(updater, token); 150 this->getAtlas(format)->setLastUseTokenBulk(updater, token);
152 } 151 }
153 152
154 // add to texture atlas that matches this format 153 // add to texture atlas that matches this format
155 bool addToAtlas(GrBatchTextStrike* strike, GrBatchAtlas::AtlasID* id, 154 bool addToAtlas(GrBatchTextStrike* strike, GrBatchAtlas::AtlasID* id,
156 GrBatchTarget* batchTarget, 155 GrDrawBatch::Target* target,
157 GrMaskFormat format, int width, int height, const void* imag e, 156 GrMaskFormat format, int width, int height, const void* imag e,
158 SkIPoint16* loc) { 157 SkIPoint16* loc) {
159 fPreserveStrike = strike; 158 fPreserveStrike = strike;
160 return this->getAtlas(format)->addToAtlas(id, batchTarget, width, height , image, loc); 159 return this->getAtlas(format)->addToAtlas(id, target, width, height, ima ge, loc);
161 } 160 }
162 161
163 // Some clients may wish to verify the integrity of the texture backing stor e of the 162 // Some clients may wish to verify the integrity of the texture backing stor e of the
164 // GrBatchAtlas. The atlasGeneration returned below is a monitonically incr easing number which 163 // GrBatchAtlas. The atlasGeneration returned below is a monitonically incr easing number which
165 // changes everytime something is removed from the texture backing store. 164 // changes everytime something is removed from the texture backing store.
166 uint64_t atlasGeneration(GrMaskFormat format) const { 165 uint64_t atlasGeneration(GrMaskFormat format) const {
167 return this->getAtlas(format)->atlasGeneration(); 166 return this->getAtlas(format)->atlasGeneration();
168 } 167 }
169 168
170 void dump() const; 169 void dump() const;
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 209
211 static void HandleEviction(GrBatchAtlas::AtlasID, void*); 210 static void HandleEviction(GrBatchAtlas::AtlasID, void*);
212 211
213 GrContext* fContext; 212 GrContext* fContext;
214 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache; 213 SkTDynamicHash<GrBatchTextStrike, GrFontDescKey> fCache;
215 GrBatchAtlas* fAtlases[kMaskFormatCount]; 214 GrBatchAtlas* fAtlases[kMaskFormatCount];
216 GrBatchTextStrike* fPreserveStrike; 215 GrBatchTextStrike* fPreserveStrike;
217 }; 216 };
218 217
219 #endif 218 #endif
OLDNEW
« no previous file with comments | « src/gpu/GrBatchFlushState.cpp ('k') | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698