diff options
author | 2014-06-24 15:08:49 -0700 | |
---|---|---|
committer | 2014-06-24 15:08:49 -0700 | |
commit | 1d86ee8363018d71245d23573619473ae7e7d1c9 (patch) | |
tree | 0a9536323974a03dbb1b05e509398df3e3349abb /src/gpu/GrAtlas.h | |
parent | 20fa0c323838bcca8ec58f96ec189e3b70c4e97e (diff) |
Rename GrAtlasMgr to GrAtlas (and other cleanup)
This CL also renames the old GrAtlas to ClientPlotUsage and moves it into the new GrAtlas.
R=jvanverth@google.com
Author: robertphillips@google.com
Review URL: https://codereview.chromium.org/355673002
Diffstat (limited to 'src/gpu/GrAtlas.h')
-rw-r--r-- | src/gpu/GrAtlas.h | 52 |
1 files changed, 25 insertions, 27 deletions
diff --git a/src/gpu/GrAtlas.h b/src/gpu/GrAtlas.h index 47048a81c7..49a7bacf27 100644 --- a/src/gpu/GrAtlas.h +++ b/src/gpu/GrAtlas.h @@ -16,18 +16,17 @@ class GrGpu; class GrRectanizer; -class GrAtlasMgr; class GrAtlas; // The backing GrTexture for a set of GrAtlases is broken into a spatial grid of GrPlots. When // a GrAtlas needs space on the texture, it requests a GrPlot. Each GrAtlas can claim one // or more GrPlots. The GrPlots keep track of subimage placement via their GrRectanizer. Once a // GrPlot is "full" (i.e. there is no room for the new subimage according to the GrRectanizer), the -// GrAtlas can request a new GrPlot via GrAtlasMgr::addToAtlas(). +// GrAtlas can request a new GrPlot via GrAtlas::addToAtlas(). // // If all GrPlots are allocated, the replacement strategy is up to the client. The drawToken is // available to ensure that all draw calls are finished for that particular GrPlot. -// GrAtlasMgr::removeUnusedPlots() will free up any finished plots for a given GrAtlas. +// GrAtlas::removeUnusedPlots() will free up any finished plots for a given GrAtlas. class GrPlot { public: @@ -47,7 +46,7 @@ public: private: GrPlot(); ~GrPlot(); // does not try to delete the fNext field - void init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, size_t bpp, + void init(GrAtlas* atlas, int offX, int offY, int width, int height, size_t bpp, bool batchUploads); // for recycling @@ -56,30 +55,42 @@ private: unsigned char* fPlotData; GrTexture* fTexture; GrRectanizer* fRects; - GrAtlasMgr* fAtlasMgr; + GrAtlas* fAtlas; SkIPoint16 fOffset; // the offset of the plot in the backing texture size_t fBytesPerPixel; SkIRect fDirtyRect; bool fDirty; bool fBatchUploads; - friend class GrAtlasMgr; + friend class GrAtlas; }; typedef SkTInternalLList<GrPlot> GrPlotList; -class GrAtlasMgr { +class GrAtlas { public: - GrAtlasMgr(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize, - int numPlotsX, int numPlotsY, bool batchUploads); - ~GrAtlasMgr(); + // This class allows each client to independently track the GrPlots in + // which its data is stored. + class ClientPlotUsage { + public: + bool isEmpty() const { return 0 == fPlots.count(); } + + private: + SkTDArray<GrPlot*> fPlots; + + friend class GrAtlas; + }; + + GrAtlas(GrGpu*, GrPixelConfig, const SkISize& backingTextureSize, + int numPlotsX, int numPlotsY, bool batchUploads); + ~GrAtlas(); // add subimage of width, height dimensions to atlas // returns the containing GrPlot and location relative to the backing texture - GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, SkIPoint16*); + GrPlot* addToAtlas(ClientPlotUsage*, int width, int height, const void*, SkIPoint16*); // remove reference to this plot - bool removePlot(GrAtlas* atlas, const GrPlot* plot); + void removePlot(ClientPlotUsage* usage, const GrPlot* plot); // get a plot that's not being used by the current draw // this allows us to overwrite this plot without flushing @@ -92,7 +103,7 @@ public: void uploadPlotsToTexture(); private: - void moveToHead(GrPlot* plot); + void makeMRU(GrPlot* plot); GrGpu* fGpu; GrPixelConfig fPixelConfig; @@ -104,21 +115,8 @@ private: // allocated array of GrPlots GrPlot* fPlotArray; - // LRU list of GrPlots + // LRU list of GrPlots (MRU at head - LRU at tail) GrPlotList fPlotList; }; -class GrAtlas { -public: - GrAtlas() { } - ~GrAtlas() { } - - bool isEmpty() { return 0 == fPlots.count(); } - -private: - SkTDArray<GrPlot*> fPlots; - - friend class GrAtlasMgr; -}; - #endif |