diff options
author | sugoi <sugoi@chromium.org> | 2015-02-04 10:53:03 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-02-04 10:53:04 -0800 |
commit | ba18f91b9f025dc53ab3cb19ea1407c55ad85937 (patch) | |
tree | e9ce1ce9dc8337751442f3df03f494dfbc315e70 /src | |
parent | f16201250315bd807e06547f1c412fcdc5c8805a (diff) |
No more caching volatile bitmaps
VideoFrames are always marked as volatile and load_yuv_texture() was caching everything, even volatile bitmaps. To solve this issue, we no longer cache volatile bitmaps' YUV planes in load_yuv_texture().
There is another issue which cause this to happen, related to how VideoImageGenerator::onGetYUV8Planes() is implemented, which is logged here: crbug.com/455235
BUG=450706, 450699
Review URL: https://codereview.chromium.org/900943002
Diffstat (limited to 'src')
-rw-r--r-- | src/gpu/SkGr.cpp | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/src/gpu/SkGr.cpp b/src/gpu/SkGr.cpp index 2a153af5be..f4d51b38be 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; |