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

Unified Diff: src/gpu/GrAtlas.cpp

Issue 355673002: Rename GrAtlasMgr to GrAtlas (and other cleanup) (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: update to ToT Created 6 years, 6 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 | « src/gpu/GrAtlas.h ('k') | src/gpu/GrBitmapTextContext.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrAtlas.cpp
diff --git a/src/gpu/GrAtlas.cpp b/src/gpu/GrAtlas.cpp
index ea5ad50a39e5d11e5c630ebb6d2f5c4914ab2fdc..30b4bac13938b5f48bafbb0e1a45e810902bdcaa 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);
« no previous file with comments | « src/gpu/GrAtlas.h ('k') | src/gpu/GrBitmapTextContext.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698