diff options
author | robertphillips <robertphillips@google.com> | 2014-06-24 15:08:49 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-06-24 15:08:49 -0700 |
commit | 1d86ee8363018d71245d23573619473ae7e7d1c9 (patch) | |
tree | 0a9536323974a03dbb1b05e509398df3e3349abb /src/gpu/GrAtlas.cpp | |
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.cpp')
-rw-r--r-- | src/gpu/GrAtlas.cpp | 51 |
1 files changed, 23 insertions, 28 deletions
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp index ea5ad50a39..30b4bac139 100644 --- a/src/gpu/GrAtlas.cpp +++ b/src/gpu/GrAtlas.cpp @@ -23,7 +23,7 @@ static int g_UploadCount = 0; GrPlot::GrPlot() : fDrawToken(NULL, 0) , fTexture(NULL) , fRects(NULL) - , fAtlasMgr(NULL) + , fAtlas(NULL) , fBytesPerPixel(1) , fDirty(false) , fBatchUploads(false) @@ -37,10 +37,10 @@ GrPlot::~GrPlot() { delete fRects; } -void GrPlot::init(GrAtlasMgr* mgr, int offX, int offY, int width, int height, size_t bpp, +void GrPlot::init(GrAtlas* atlas, int offX, int offY, int width, int height, size_t bpp, bool batchUploads) { fRects = GrRectanizer::Factory(width, height); - fAtlasMgr = mgr; + fAtlas = atlas; fOffset.set(offX * width, offY * height); fBytesPerPixel = bpp; fPlotData = NULL; @@ -146,9 +146,9 @@ void GrPlot::resetRects() { /////////////////////////////////////////////////////////////////////////////// -GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config, - const SkISize& backingTextureSize, - int numPlotsX, int numPlotsY, bool batchUploads) { +GrAtlas::GrAtlas(GrGpu* gpu, GrPixelConfig config, + const SkISize& backingTextureSize, + int numPlotsX, int numPlotsY, bool batchUploads) { fGpu = SkRef(gpu); fPixelConfig = config; fBackingTextureSize = backingTextureSize; @@ -185,7 +185,7 @@ GrAtlasMgr::GrAtlasMgr(GrGpu* gpu, GrPixelConfig config, } } -GrAtlasMgr::~GrAtlasMgr() { +GrAtlas::~GrAtlas() { SkSafeUnref(fTexture); SkDELETE_ARRAY(fPlotArray); @@ -195,7 +195,7 @@ GrAtlasMgr::~GrAtlasMgr() { #endif } -void GrAtlasMgr::moveToHead(GrPlot* plot) { +void GrAtlas::makeMRU(GrPlot* plot) { if (fPlotList.head() == plot) { return; } @@ -204,15 +204,15 @@ void GrAtlasMgr::moveToHead(GrPlot* plot) { fPlotList.addToHead(plot); }; -GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, - int width, int height, const void* image, - SkIPoint16* loc) { +GrPlot* GrAtlas::addToAtlas(ClientPlotUsage* usage, + int width, int height, const void* image, + SkIPoint16* loc) { // iterate through entire plot list for this atlas, see if we can find a hole // last one was most recently added and probably most empty - for (int i = atlas->fPlots.count()-1; i >= 0; --i) { - GrPlot* plot = atlas->fPlots[i]; + for (int i = usage->fPlots.count()-1; i >= 0; --i) { + GrPlot* plot = usage->fPlots[i]; if (plot->addSubImage(width, height, image, loc)) { - this->moveToHead(plot); + this->makeMRU(plot); return plot; } } @@ -240,9 +240,10 @@ GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, // make sure texture is set for quick lookup plot->fTexture = fTexture; if (plot->addSubImage(width, height, image, loc)) { - this->moveToHead(plot); + this->makeMRU(plot); // new plot for atlas, put at end of array - *(atlas->fPlots.append()) = plot; + SkASSERT(!usage->fPlots.contains(plot)); + *(usage->fPlots.append()) = plot; return plot; } plotIter.next(); @@ -252,21 +253,15 @@ GrPlot* GrAtlasMgr::addToAtlas(GrAtlas* atlas, return NULL; } -bool GrAtlasMgr::removePlot(GrAtlas* atlas, const GrPlot* plot) { - // iterate through plot list for this atlas - int count = atlas->fPlots.count(); - for (int i = 0; i < count; ++i) { - if (plot == atlas->fPlots[i]) { - atlas->fPlots.remove(i); - return true; - } +void GrAtlas::removePlot(ClientPlotUsage* usage, const GrPlot* plot) { + int index = usage->fPlots.find(const_cast<GrPlot*>(plot)); + if (index >= 0) { + usage->fPlots.remove(index); } - - return false; } // get a plot that's not being used by the current draw -GrPlot* GrAtlasMgr::getUnusedPlot() { +GrPlot* GrAtlas::getUnusedPlot() { GrPlotList::Iter plotIter; plotIter.init(fPlotList, GrPlotList::Iter::kTail_IterStart); GrPlot* plot; @@ -280,7 +275,7 @@ GrPlot* GrAtlasMgr::getUnusedPlot() { return NULL; } -void GrAtlasMgr::uploadPlotsToTexture() { +void GrAtlas::uploadPlotsToTexture() { if (fBatchUploads) { GrPlotList::Iter plotIter; plotIter.init(fPlotList, GrPlotList::Iter::kHead_IterStart); |