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

Unified Diff: src/gpu/GrBatchFontCache.h

Issue 1087203004: Store pointers to GrGlyph directly in BitmapTextBlob (Closed) Base URL: https://skia.googlesource.com/skia.git@atdfopt2
Patch Set: adding comment Created 5 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrBatchFontCache.h
diff --git a/src/gpu/GrBatchFontCache.h b/src/gpu/GrBatchFontCache.h
index 6aa14e69daf271fd05f049c9acbb76fb820c78c4..f60e2c8ebfbb1b204d7fd85b9c363ab37123d374 100644
--- a/src/gpu/GrBatchFontCache.h
+++ b/src/gpu/GrBatchFontCache.h
@@ -24,7 +24,7 @@ class GrGpu;
* is abstracted by GrGlyph, and indexed by a PackedID and GrFontScaler. The GrFontScaler is what
* actually creates the mask.
*/
-class GrBatchTextStrike {
+class GrBatchTextStrike : public SkNVRefCnt<GrBatchTextStrike> {
public:
GrBatchTextStrike(GrBatchFontCache*, const GrFontDescKey* fontScalerKey);
~GrBatchTextStrike();
@@ -52,6 +52,9 @@ public:
// remove any references to this plot
void removeID(GrBatchAtlas::AtlasID);
+ // If a TextStrike is abandoned by the cache, then the caller must get a new strike
+ bool isAbandoned() const { return fIsAbandoned; }
+
static const GrFontDescKey& GetKey(const GrBatchTextStrike& ts) {
return *(ts.fFontScalerKey);
}
@@ -66,6 +69,7 @@ private:
GrBatchFontCache* fBatchFontCache;
int fAtlasedGlyphs;
+ bool fIsAbandoned;
GrGlyph* generateGlyph(GrGlyph::PackedID packed, GrFontScaler* scaler);
@@ -84,7 +88,10 @@ class GrBatchFontCache {
public:
GrBatchFontCache(GrContext*);
~GrBatchFontCache();
-
+ // The user of the cache may hold a long-lived ref to the returned strike. However, actions by
+ // another client of the cache may cause the strike to be purged while it is still reffed.
+ // Therefore, the caller must check GrBatchTextStrike::isAbandoned() if there are other
+ // interactions with the cache since the strike was received.
inline GrBatchTextStrike* getStrike(GrFontScaler* scaler) {
GrBatchTextStrike* strike = fCache.find(*(scaler->getKey()));
if (NULL == strike) {
« no previous file with comments | « src/gpu/GrAtlasTextContext.cpp ('k') | src/gpu/GrBatchFontCache.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698