Chromium Code Reviews| Index: src/gpu/GrAtlas.h |
| diff --git a/src/gpu/GrAtlas.h b/src/gpu/GrAtlas.h |
| index b2acaee8e277d35e0146745c41a4f7849d249424..27cda5b136678c276798162e807695d5b832b8bd 100644 |
| --- a/src/gpu/GrAtlas.h |
| +++ b/src/gpu/GrAtlas.h |
| @@ -6,8 +6,6 @@ |
| * found in the LICENSE file. |
| */ |
| - |
| - |
| #ifndef GrAtlas_DEFINED |
| #define GrAtlas_DEFINED |
| @@ -18,69 +16,79 @@ |
| class GrGpu; |
| class GrRectanizer; |
| class GrAtlasMgr; |
| +class GrAtlas; |
| -class GrAtlas { |
| +class GrPlot { |
| public: |
| - int getPlotX() const { return fPlot.fX; } |
| - int getPlotY() const { return fPlot.fY; } |
| + int getOffsetX() const { return fOffset.fX; } |
| + int getOffsetY() const { return fOffset.fY; } |
| GrTexture* texture() const { return fTexture; } |
| bool addSubImage(int width, int height, const void*, GrIPoint16*); |
| - static void FreeLList(GrAtlas* atlas) { |
| - while (NULL != atlas) { |
| - GrAtlas* next = atlas->fNext; |
| - delete atlas; |
| - atlas = next; |
| - } |
| - } |
| - |
| - static bool RemoveUnusedAtlases(GrAtlasMgr* atlasMgr, GrAtlas** startAtlas); |
| - |
| GrDrawTarget::DrawToken drawToken() const { return fDrawToken; } |
| void setDrawToken(GrDrawTarget::DrawToken draw) { fDrawToken = draw; } |
| private: |
| - GrAtlas(GrAtlasMgr*, int plotX, int plotY, int bpp); |
| - ~GrAtlas(); // does not try to delete the fNext field |
| + GrPlot(); |
| + ~GrPlot(); // does not try to delete the fNext field |
| // for recycling |
| GrDrawTarget::DrawToken fDrawToken; |
| - GrAtlas* fNext; |
| + GrPlot* fNext; |
| GrTexture* fTexture; |
| GrRectanizer* fRects; |
| GrAtlasMgr* fAtlasMgr; |
| - GrIPoint16 fPlot; |
| + GrIPoint16 fOffset; |
| int fBytesPerPixel; |
| friend class GrAtlasMgr; |
| }; |
| -class GrPlotMgr; |
| - |
| class GrAtlasMgr { |
| public: |
| GrAtlasMgr(GrGpu*, GrPixelConfig); |
| ~GrAtlasMgr(); |
| - GrAtlas* addToAtlas(GrAtlas**, int width, int height, const void*, GrIPoint16*); |
| - void deleteAtlas(GrAtlas* atlas) { delete atlas; } |
| - |
| + GrPlot* addToAtlas(GrAtlas*, int width, int height, const void*, GrIPoint16*); |
|
bsalomon
2013/09/27 18:42:55
This guy could really use a comment describing wha
jvanverth1
2013/09/27 19:12:54
Done.
|
| + bool removeUnusedPlots(GrAtlas* atlas); |
| + |
| + // to be called by ~GrAtlas() |
| + void deletePlotList(GrPlot* plot); |
| + |
| GrTexture* getTexture() const { |
| return fTexture; |
| } |
| - // to be called by ~GrAtlas() |
| - void freePlot(int x, int y); |
| - |
| private: |
| + GrPlot* allocPlot(); |
| + void freePlot(GrPlot* plot); |
| + |
| GrGpu* fGpu; |
| GrPixelConfig fPixelConfig; |
| GrTexture* fTexture; |
| - GrPlotMgr* fPlotMgr; |
| + |
| + // allocated array of GrPlots |
| + GrPlot* fPlots; |
| + // linked list of free GrPlots |
| + GrPlot* fFreePlots; |
| +}; |
| + |
| +class GrAtlas { |
| +public: |
| + GrAtlas(GrAtlasMgr* mgr) : fPlots(NULL), fAtlasMgr(mgr) { } |
| + ~GrAtlas() { fAtlasMgr->deletePlotList(fPlots); } |
| + |
| + bool isEmpty() { return NULL == fPlots; } |
| + |
| +private: |
| + GrPlot* fPlots; |
| + GrAtlasMgr* fAtlasMgr; |
| + |
| + friend class GrAtlasMgr; |
| }; |
| #endif |