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
This commit is contained in:
sugoi 2015-02-04 10:53:03 -08:00 committed by Commit bot
parent f162012503
commit ba18f91b9f

View File

@ -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;