Index: src/gpu/GrBatchAtlas.cpp |
diff --git a/src/gpu/GrBatchAtlas.cpp b/src/gpu/GrBatchAtlas.cpp |
index 113025eac73a15f7e83cd2df8172054d766dceaf..3374e00a9f7080f143057c792abdca4dfe992ef6 100644 |
--- a/src/gpu/GrBatchAtlas.cpp |
+++ b/src/gpu/GrBatchAtlas.cpp |
@@ -10,6 +10,12 @@ |
#include "GrGpu.h" |
#include "GrRectanizer.h" |
#include "GrTracing.h" |
+ |
+// for testing |
+#define ATLAS_STATS 0 |
+#if ATLAS_STATS |
+static int g_UploadCount = 0; |
+#endif |
static inline void adjust_for_offset(SkIPoint16* loc, const SkIPoint16& offset) { |
loc->fX += offset.fX; |
@@ -67,6 +73,10 @@ |
adjust_for_offset(loc, fOffset); |
SkDEBUGCODE(fDirty = true;) |
+#if ATLAS_STATS |
+ ++g_UploadCount; |
+#endif |
+ |
return true; |
} |
@@ -76,15 +86,9 @@ |
// when we can evict a plot from the cache, ie if the last ref has already flushed through |
// the gpu then we can reuse the plot |
BatchToken lastUploadToken() const { return fLastUpload; } |
- BatchToken lastUseToken() const { return fLastUse; } |
- void setLastUploadToken(BatchToken batchToken) { |
- SkASSERT(batchToken >= fLastUpload); |
- fLastUpload = batchToken; |
- } |
- void setLastUseToken(BatchToken batchToken) { |
- SkASSERT(batchToken >= fLastUse); |
- fLastUse = batchToken; |
- } |
+ BatchToken lastRefToken() const { return fLastRef; } |
+ void setLastUploadToken(BatchToken batchToken) { fLastUpload = batchToken; } |
+ void setLastRefToken(BatchToken batchToken) { fLastRef = batchToken; } |
void uploadToTexture(GrBatchTarget::TextureUploader uploader) { |
// We should only be issuing uploads if we are in fact dirty |
@@ -123,7 +127,7 @@ |
private: |
BatchPlot() |
: fLastUpload(0) |
- , fLastUse(0) |
+ , fLastRef(0) |
, fIndex(-1) |
, fGenID(-1) |
, fID(0) |
@@ -173,7 +177,7 @@ |
} |
BatchToken fLastUpload; |
- BatchToken fLastUse; |
+ BatchToken fLastRef; |
uint32_t fIndex; |
uint32_t fGenID; |
@@ -225,7 +229,6 @@ |
, fPlotWidth(texture->width() / numPlotsX) |
, fPlotHeight(texture->height() / numPlotsY) |
, fAtlasGeneration(kInvalidAtlasGeneration + 1) { |
- SkASSERT(fNumPlotsX * fNumPlotsY <= BulkUseTokenUpdater::kMaxPlots); |
SkASSERT(fPlotWidth * fNumPlotsX == texture->width()); |
SkASSERT(fPlotHeight * fNumPlotsY == texture->height()); |
@@ -253,6 +256,10 @@ |
GrBatchAtlas::~GrBatchAtlas() { |
SkSafeUnref(fTexture); |
SkDELETE_ARRAY(fPlotArray); |
+ |
+#if ATLAS_STATS |
+ SkDebugf("Num uploads: %d\n", g_UploadCount); |
+#endif |
} |
void GrBatchAtlas::processEviction(AtlasID id) { |
@@ -306,7 +313,7 @@ |
plotIter.init(fPlotList, GrBatchPlotList::Iter::kTail_IterStart); |
plot = plotIter.get(); |
SkASSERT(plot); |
- if (batchTarget->isIssued(plot->lastUseToken())) { |
+ if (batchTarget->isIssued(plot->lastRefToken())) { |
this->processEviction(plot->id()); |
plot->resetRects(); |
SkDEBUGCODE(bool verify = )plot->addSubImage(width, height, image, loc, fBPP * width); |
@@ -322,7 +329,7 @@ |
// off the plot(ie let the batch target manage it) and create a new plot in its place in our |
// array. If it is equal to the currentToken, then the caller has to flush draws to the batch |
// target so we can spin off the plot |
- if (plot->lastUseToken() == batchTarget->currentToken()) { |
+ if (plot->lastRefToken() == batchTarget->currentToken()) { |
return false; |
} |
@@ -352,24 +359,14 @@ |
} |
bool GrBatchAtlas::hasID(AtlasID id) { |
- int index = GetIndexFromID(id); |
+ int index = this->getIndexFromID(id); |
SkASSERT(index < fNumPlotsX * fNumPlotsY); |
- return fPlotArray[index]->genID() == GetGenerationFromID(id); |
-} |
- |
-void GrBatchAtlas::setLastUseToken(AtlasID id, BatchToken batchToken) { |
+ return fPlotArray[index]->genID() == this->getGenerationFromID(id); |
+} |
+ |
+void GrBatchAtlas::setLastRefToken(AtlasID id, BatchToken batchToken) { |
SkASSERT(this->hasID(id)); |
- int index = GetIndexFromID(id); |
- SkASSERT(index < fNumPlotsX * fNumPlotsY); |
+ int index = this->getIndexFromID(id); |
this->makeMRU(fPlotArray[index]); |
- fPlotArray[index]->setLastUseToken(batchToken); |
-} |
- |
-void GrBatchAtlas::setLastUseTokenBulk(const BulkUseTokenUpdater& updater, BatchToken batchToken) { |
- int plotsToUpdateCount = updater.fPlotsToUpdate.count(); |
- for (int i = 0; i < plotsToUpdateCount; i++) { |
- BatchPlot* plot = fPlotArray[updater.fPlotsToUpdate[i]]; |
- this->makeMRU(plot); |
- plot->setLastUseToken(batchToken); |
- } |
-} |
+ fPlotArray[index]->setLastRefToken(batchToken); |
+} |