| Index: src/gpu/GrLayerCache.cpp
|
| diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
|
| index 50f7abe830a2ad2140c61e28e88451451887209e..0481d144e585aa45758bfaa347446befbd2030dc 100644
|
| --- a/src/gpu/GrLayerCache.cpp
|
| +++ b/src/gpu/GrLayerCache.cpp
|
| @@ -153,12 +153,14 @@
|
|
|
| if (layer->locked()) {
|
| // This layer is already locked
|
| +#ifdef SK_DEBUG
|
| if (layer->isAtlased()) {
|
| - this->incPlotLock(layer->plot()->id());
|
| + // It claims to be atlased
|
| SkASSERT(!dontAtlas);
|
| SkASSERT(layer->rect().width() == desc.fWidth);
|
| SkASSERT(layer->rect().height() == desc.fHeight);
|
| }
|
| +#endif
|
| return false;
|
| }
|
|
|
| @@ -166,7 +168,7 @@
|
| // Hooray it is still in the atlas - make sure it stays there
|
| SkASSERT(!dontAtlas);
|
| layer->setLocked(true);
|
| - this->incPlotLock(layer->plot()->id());
|
| + fPlotLocks[layer->plot()->id()]++;
|
| return false;
|
| } else if (!dontAtlas && PlausiblyAtlasable(desc.fWidth, desc.fHeight)) {
|
| // Not in the atlas - will it fit?
|
| @@ -191,7 +193,7 @@
|
| layer->setTexture(fAtlas->getTexture(), bounds);
|
| layer->setPlot(plot);
|
| layer->setLocked(true);
|
| - this->incPlotLock(layer->plot()->id());
|
| + fPlotLocks[layer->plot()->id()]++;
|
| return true;
|
| }
|
|
|
| @@ -217,7 +219,7 @@
|
| void GrLayerCache::unlock(GrCachedLayer* layer) {
|
| SkDEBUGCODE(GrAutoValidateLayer avl(fAtlas->getTexture(), layer);)
|
|
|
| - if (NULL == layer) {
|
| + if (NULL == layer || !layer->locked()) {
|
| // invalid or not locked
|
| return;
|
| }
|
| @@ -225,7 +227,8 @@
|
| if (layer->isAtlased()) {
|
| const int plotID = layer->plot()->id();
|
|
|
| - this->decPlotLock(plotID);
|
| + SkASSERT(fPlotLocks[plotID] > 0);
|
| + fPlotLocks[plotID]--;
|
| // At this point we could aggressively clear out un-locked plots but
|
| // by delaying we may be able to reuse some of the atlased layers later.
|
| #if DISABLE_CACHING
|
| @@ -250,6 +253,9 @@
|
|
|
| #ifdef SK_DEBUG
|
| void GrLayerCache::validate() const {
|
| + int plotLocks[kNumPlotsX * kNumPlotsY];
|
| + memset(plotLocks, 0, sizeof(plotLocks));
|
| +
|
| SkTDynamicHash<GrCachedLayer, GrCachedLayer::Key>::ConstIter iter(&fLayerHash);
|
| for (; !iter.done(); ++iter) {
|
| const GrCachedLayer* layer = &(*iter);
|
| @@ -264,7 +270,7 @@
|
| SkASSERT(!pictInfo->fPlotUsage.isEmpty());
|
| #endif
|
| } else {
|
| - // If there is no picture info for this picture then all of its
|
| + // If there is no picture info for this layer then all of its
|
| // layers should be non-atlased.
|
| SkASSERT(!layer->isAtlased());
|
| }
|
| @@ -276,9 +282,13 @@
|
| SkASSERT(pictInfo->fPlotUsage.contains(layer->plot()));
|
|
|
| if (layer->locked()) {
|
| - SkASSERT(fPlotLocks[layer->plot()->id()] > 0);
|
| + plotLocks[layer->plot()->id()]++;
|
| }
|
| }
|
| + }
|
| +
|
| + for (int i = 0; i < kNumPlotsX*kNumPlotsY; ++i) {
|
| + SkASSERT(plotLocks[i] == fPlotLocks[i]);
|
| }
|
| }
|
|
|
|
|