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

Unified Diff: src/gpu/SkGr.cpp

Issue 900943002: No more caching volatile bitmaps (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Use optionalKey instead of a cache bool Created 5 years, 10 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/SkGr.cpp
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp
index 2a153af5be2b338bd41b1f41dbcbdc11f8388108..f4d51b38bef8274a21f92b1237a9cb937e064417 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -324,12 +324,16 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrContentKey& optionalK
return NULL;
}
+ const bool useCache = optionalKey.isValid();
SkYUVPlanesCache::Info yuvInfo;
- SkAutoTUnref<SkCachedData> cachedData(
- SkYUVPlanesCache::FindAndRef(pixelRef->getGenerationID(), &yuvInfo));
+ SkAutoTUnref<SkCachedData> cachedData;
+ SkAutoMalloc storage;
+ if (useCache) {
+ cachedData.reset(SkYUVPlanesCache::FindAndRef(pixelRef->getGenerationID(), &yuvInfo));
+ }
void* planes[3];
- if (cachedData && cachedData->data()) {
+ if (cachedData.get()) {
planes[0] = (void*)cachedData->data();
planes[1] = (uint8_t*)planes[0] + yuvInfo.fSizeInMemory[0];
planes[2] = (uint8_t*)planes[1] + yuvInfo.fSizeInMemory[1];
@@ -347,8 +351,13 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrContentKey& optionalK
yuvInfo.fSizeInMemory[i] = yuvInfo.fRowBytes[i] * yuvInfo.fSize[i].fHeight;
totalSize += yuvInfo.fSizeInMemory[i];
}
- cachedData.reset(SkResourceCache::NewCachedData(totalSize));
- planes[0] = cachedData->writable_data();
+ if (useCache) {
+ cachedData.reset(SkResourceCache::NewCachedData(totalSize));
+ planes[0] = cachedData->writable_data();
+ } else {
+ storage.reset(totalSize);
+ planes[0] = storage.get();
+ }
planes[1] = (uint8_t*)planes[0] + yuvInfo.fSizeInMemory[0];
planes[2] = (uint8_t*)planes[1] + yuvInfo.fSizeInMemory[1];
@@ -358,8 +367,10 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrContentKey& optionalK
return NULL;
}
- // Decoding is done, cache the resulting YUV planes
- SkYUVPlanesCache::Add(pixelRef->getGenerationID(), cachedData, &yuvInfo);
+ if (useCache) {
+ // Decoding is done, cache the resulting YUV planes
+ SkYUVPlanesCache::Add(pixelRef->getGenerationID(), cachedData, &yuvInfo);
+ }
}
GrSurfaceDesc yuvDesc;
« 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