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

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: 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 885b453df5f353c88b74ed9381241db01c4dc26a..df3dd04e039f268138c83ad14147ad8152f15fd7 100644
--- a/src/gpu/SkGr.cpp
+++ b/src/gpu/SkGr.cpp
@@ -315,7 +315,7 @@ static GrTexture *load_etc1_texture(GrContext* ctx, const GrContentKey& optional
#endif // SK_IGNORE_ETC1_SUPPORT
static GrTexture* load_yuv_texture(GrContext* ctx, const GrContentKey& optionalKey,
- const SkBitmap& bm, const GrSurfaceDesc& desc) {
+ const SkBitmap& bm, const GrSurfaceDesc& desc, bool cache) {
bsalomon 2015/02/04 17:19:33 We don't need the cache bool. optionalKey should a
sugoi1 2015/02/04 17:59:51 Done.
// Subsets are not supported, the whole pixelRef is loaded when using YUV decoding
SkPixelRef* pixelRef = bm.pixelRef();
if ((NULL == pixelRef) ||
@@ -325,11 +325,14 @@ static GrTexture* load_yuv_texture(GrContext* ctx, const GrContentKey& optionalK
}
SkYUVPlanesCache::Info yuvInfo;
- SkAutoTUnref<SkCachedData> cachedData(
- SkYUVPlanesCache::FindAndRef(pixelRef->getGenerationID(), &yuvInfo));
+ SkAutoTUnref<SkCachedData> cachedData;
+ SkAutoMalloc storage;
+ if (cache) {
+ 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 +350,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 (cache) {
+ 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 +366,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 (cache) {
+ // Decoding is done, cache the resulting YUV planes
+ SkYUVPlanesCache::Add(pixelRef->getGenerationID(), cachedData, &yuvInfo);
+ }
}
GrSurfaceDesc yuvDesc;
@@ -454,7 +464,8 @@ static GrTexture* create_unstretched_bitmap_texture(GrContext* ctx,
#endif // SK_IGNORE_ETC1_SUPPORT
else {
- GrTexture *texture = load_yuv_texture(ctx, optionalKey, *bitmap, desc);
+ GrTexture *texture = load_yuv_texture(ctx, optionalKey, *bitmap, desc,
+ !origBitmap.isVolatile());
if (texture) {
return texture;
}
« 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