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

Unified Diff: src/gpu/GrAtlas.h

Issue 177463003: New approach for GPU font atlas (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Remove unnecessary reference to GrAtlasMgr Created 6 years, 10 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 | « no previous file | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAtlas.h
diff --git a/src/gpu/GrAtlas.h b/src/gpu/GrAtlas.h
index e290822fe1216c99859cb1b5cbbb1ddbe450dbbe..ee4ead92a056bd7aa29a750ad18425feb5838bb6 100644
--- a/src/gpu/GrAtlas.h
+++ b/src/gpu/GrAtlas.h
@@ -31,6 +31,8 @@ class GrAtlas;
class GrPlot {
public:
+ SK_DECLARE_INTERNAL_LLIST_INTERFACE(GrPlot);
+
int getOffsetX() const { return fOffset.fX; }
int getOffsetY() const { return fOffset.fY; }
@@ -41,6 +43,8 @@ public:
GrDrawTarget::DrawToken drawToken() const { return fDrawToken; }
void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; }
+ void resetRects();
+
private:
GrPlot();
~GrPlot(); // does not try to delete the fNext field
@@ -48,8 +52,6 @@ private:
// for recycling
GrDrawTarget::DrawToken fDrawToken;
- GrPlot* fNext;
-
GrTexture* fTexture;
GrRectanizer* fRects;
GrAtlasMgr* fAtlasMgr;
@@ -59,6 +61,8 @@ private:
friend class GrAtlasMgr;
};
+typedef SkTInternalLList<GrPlot> GrPlotList;
+
class GrAtlasMgr {
public:
GrAtlasMgr(GrGpu*, GrPixelConfig);
@@ -68,42 +72,41 @@ public:
// returns the containing GrPlot and location relative to the backing texture
GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16*);
- // free up any plots that are not waiting on a draw call
- bool removeUnusedPlots(GrAtlas* atlas);
+ // remove reference to this plot
+ bool removePlot(GrAtlas* atlas, const GrPlot* plot);
- // to be called by ~GrAtlas()
- void deletePlotList(GrPlot* plot);
+ // get a plot that's not being used by the current draw
+ // this allows us to overwrite this plot without flushing
+ GrPlot* getUnusedPlot();
GrTexture* getTexture() const {
return fTexture;
}
private:
- GrPlot* allocPlot();
- void freePlot(GrPlot* plot);
+ void moveToHead(GrPlot* plot);
GrGpu* fGpu;
GrPixelConfig fPixelConfig;
GrTexture* fTexture;
// allocated array of GrPlots
- GrPlot* fPlots;
- // linked list of free GrPlots
- GrPlot* fFreePlots;
+ GrPlot* fPlotArray;
+ // LRU list of GrPlots
+ GrPlotList fPlotList;
};
class GrAtlas {
public:
- GrAtlas(GrAtlasMgr* mgr) : fPlots(NULL), fAtlasMgr(mgr) { }
- ~GrAtlas() { fAtlasMgr->deletePlotList(fPlots); }
+ GrAtlas() { }
+ ~GrAtlas() { }
- bool isEmpty() { return NULL == fPlots; }
+ bool isEmpty() { return 0 == fPlots.count(); }
SkISize getSize() const;
private:
- GrPlot* fPlots;
- GrAtlasMgr* fAtlasMgr;
+ SkTDArray<GrPlot*> fPlots;
friend class GrAtlasMgr;
};
« no previous file with comments | « no previous file | src/gpu/GrAtlas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698