New approach for GPU font atlas
In the previous code, each GrTextStrike had exclusive access to one or more GrPlots in the texture atlas. This led to poor packing when only a few glyphs were used. This change allows GrTextStrikes to share GrPlots, thereby getting much better utilization of the entire texture.
BUG=skia:2224
R=robertphillips@google.com, bsalomon@google.com
Author: jvanverth@google.com
Review URL: https://codereview.chromium.org/177463003
git-svn-id: http://skia.googlecode.com/svn/trunk@13636 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/src/gpu/GrTextStrike.h b/src/gpu/GrTextStrike.h
index 17dcec6..784ea91 100644
--- a/src/gpu/GrTextStrike.h
+++ b/src/gpu/GrTextStrike.h
@@ -37,7 +37,7 @@
GrMaskFormat getMaskFormat() const { return fMaskFormat; }
inline GrGlyph* getGlyph(GrGlyph::PackedID, GrFontScaler*);
- bool getGlyphAtlas(GrGlyph*, GrFontScaler*);
+ bool addGlyphToAtlas(GrGlyph*, GrFontScaler*);
SkISize getAtlasSize() const { return fAtlas.getSize(); }
@@ -47,11 +47,11 @@
return fCache.getArray()[index];
}
- // returns true if a plot was removed
- bool removeUnusedPlots();
+ // remove any references to this plot
+ void removePlot(const GrPlot* plot);
public:
- // for LRU
+ // for easy removal from list
GrTextStrike* fPrev;
GrTextStrike* fNext;
@@ -88,10 +88,8 @@
void freeAll();
- void purgeExceptFor(GrTextStrike*);
-
- // remove an unused plot and its strike (if necessary)
- void freePlotExceptFor(GrTextStrike*);
+ // make an unused plot available
+ bool freeUnusedPlot(GrTextStrike* preserveStrike);
// testing
int countStrikes() const { return fCache.getArray().count(); }