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

Unified Diff: src/gpu/GrLayerCache.cpp

Issue 630173002: Fix some incorrect assumptions in GrLayerCache.cpp (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/gpu/GrLayerCache.cpp
diff --git a/src/gpu/GrLayerCache.cpp b/src/gpu/GrLayerCache.cpp
index 6ec07580c85485dfe98ceb52ad10af8a907aed09..f90ab55a5eb9b44989ea378ae160e911e1fe8849 100644
--- a/src/gpu/GrLayerCache.cpp
+++ b/src/gpu/GrLayerCache.cpp
@@ -14,7 +14,7 @@ DECLARE_SKMESSAGEBUS_MESSAGE(GrPictureDeletedMessage);
#ifdef SK_DEBUG
void GrCachedLayer::validate(const GrTexture* backingTexture) const {
SkASSERT(SK_InvalidGenID != fKey.pictureID());
- SkASSERT(fKey.start() > 0);
+ SkASSERT(fKey.start() >= 0);
if (fTexture) {
@@ -121,7 +121,7 @@ GrCachedLayer* GrLayerCache::createLayer(uint32_t pictureID,
int start, int stop,
const SkMatrix& ctm,
const SkPaint* paint) {
- SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0);
+ SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0);
GrCachedLayer* layer = SkNEW_ARGS(GrCachedLayer, (pictureID, start, stop, ctm, paint));
fLayerHash.add(layer);
@@ -139,7 +139,7 @@ GrCachedLayer* GrLayerCache::findLayerOrCreate(uint32_t pictureID,
int start, int stop,
const SkMatrix& ctm,
const SkPaint* paint) {
- SkASSERT(pictureID != SK_InvalidGenID && start > 0 && stop > 0);
+ SkASSERT(pictureID != SK_InvalidGenID && start >= 0 && stop > 0);
GrCachedLayer* layer = fLayerHash.find(GrCachedLayer::Key(pictureID, start, ctm));
if (NULL == layer) {
layer = this->createLayer(pictureID, start, stop, ctm, paint);
@@ -369,18 +369,20 @@ void GrLayerCache::purgePlot(GrPlot* plot) {
for (int i = 0; i < toBeRemoved.count(); ++i) {
SkASSERT(!toBeRemoved[i]->locked());
- GrPictureInfo* pictInfo = fPictureHash.find(toBeRemoved[i]->pictureID());
- SkASSERT(pictInfo);
-
- GrAtlas::RemovePlot(&pictInfo->fPlotUsage, plot);
+ uint32_t pictureIDToRemove = toBeRemoved[i]->pictureID();
- // Aggressively remove layers and, if now totally uncached, picture info
+ // Aggressively remove layers and, if it becomes totally uncached, delete the picture info
fLayerHash.remove(GrCachedLayer::GetKey(*toBeRemoved[i]));
SkDELETE(toBeRemoved[i]);
- if (pictInfo->fPlotUsage.isEmpty()) {
- fPictureHash.remove(pictInfo->fPictureID);
- SkDELETE(pictInfo);
+ GrPictureInfo* pictInfo = fPictureHash.find(pictureIDToRemove);
+ if (pictInfo) {
+ GrAtlas::RemovePlot(&pictInfo->fPlotUsage, plot);
+
+ if (pictInfo->fPlotUsage.isEmpty()) {
+ fPictureHash.remove(pictInfo->fPictureID);
+ SkDELETE(pictInfo);
+ }
}
}
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698