Removed unused useCache param in GrYUVProvider

The function was only ever called in one spot and always passed in true
for this value.

Bug: skia:
Change-Id: Ie22c01d13da5e34664cb67b7b1c900da6d92bb45
Reviewed-on: https://skia-review.googlesource.com/90402
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Greg Daniel <egdaniel@google.com>
This commit is contained in:
Greg Daniel 2018-01-04 10:27:29 -05:00 committed by Skia Commit-Bot
parent 48ef021df8
commit 1445da6c03
3 changed files with 22 additions and 48 deletions

View File

@ -20,31 +20,13 @@
#include "effects/GrSRGBEffect.h"
#include "effects/GrYUVtoRGBEffect.h"
namespace {
/**
* Helper class to manage the resources used for storing the YUV planar data. Depending on the
* useCache option, we may find (and lock) the data in our ResourceCache, or we may have allocated
* it in scratch storage.
*/
class YUVScoper {
public:
bool init(GrYUVProvider*, SkYUVPlanesCache::Info*, void* planes[3], bool useCache);
sk_sp<SkCachedData> init_provider(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo,
void* planes[3]) {
sk_sp<SkCachedData> data;
data.reset(SkYUVPlanesCache::FindAndRef(provider->onGetID(), yuvInfo));
private:
// we only use one or the other of these
sk_sp<SkCachedData> fCachedData;
SkAutoMalloc fStorage;
};
}
bool YUVScoper::init(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo, void* planes[3],
bool useCache) {
if (useCache) {
fCachedData.reset(SkYUVPlanesCache::FindAndRef(provider->onGetID(), yuvInfo));
}
if (fCachedData.get()) {
planes[0] = (void*)fCachedData->data();
if (data.get()) {
planes[0] = (void*)data->data();
planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] *
yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
planes[2] = (uint8_t*)planes[1] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kU] *
@ -52,7 +34,7 @@ bool YUVScoper::init(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo, v
} else {
// Fetch yuv plane sizes for memory allocation.
if (!provider->onQueryYUV8(&yuvInfo->fSizeInfo, &yuvInfo->fColorSpace)) {
return false;
return nullptr;
}
// Allocate the memory for YUV
@ -60,13 +42,8 @@ bool YUVScoper::init(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo, v
for (int i = 0; i < 3; i++) {
totalSize += yuvInfo->fSizeInfo.fWidthBytes[i] * yuvInfo->fSizeInfo.fSizes[i].fHeight;
}
if (useCache) {
fCachedData.reset(SkResourceCache::NewCachedData(totalSize));
planes[0] = fCachedData->writable_data();
} else {
fStorage.reset(totalSize);
planes[0] = fStorage.get();
}
data.reset(SkResourceCache::NewCachedData(totalSize));
planes[0] = data->writable_data();
planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] *
yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
planes[2] = (uint8_t*)planes[1] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kU] *
@ -74,25 +51,23 @@ bool YUVScoper::init(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo, v
// Get the YUV planes.
if (!provider->onGetYUV8Planes(yuvInfo->fSizeInfo, planes)) {
return false;
return nullptr;
}
if (useCache) {
// Decoding is done, cache the resulting YUV planes
SkYUVPlanesCache::Add(provider->onGetID(), fCachedData.get(), yuvInfo);
}
// Decoding is done, cache the resulting YUV planes
SkYUVPlanesCache::Add(provider->onGetID(), data.get(), yuvInfo);
}
return true;
return data;
}
sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrSurfaceDesc& desc,
bool useCache,
const SkColorSpace* srcColorSpace,
const SkColorSpace* dstColorSpace) {
SkYUVPlanesCache::Info yuvInfo;
void* planes[3];
YUVScoper scoper;
if (!scoper.init(this, &yuvInfo, planes, useCache)) {
sk_sp<SkCachedData> dataStorage = init_provider(this, &yuvInfo, planes);
if (!dataStorage) {
return nullptr;
}

View File

@ -30,15 +30,14 @@ public:
/**
* On success, this returns a texture proxy that has converted the YUV data from the provider
* into a form that is supported by the GPU (typically transformed into RGB). If useCache
* is true, then the texture will automatically have a key added, so it can be retrieved
* from the cache (assuming it is requested by a provider w/ the same genID). If srcColorSpace
* and dstColorSpace are specified, then a color conversion from src to dst will be applied to
* the pixels.
* into a form that is supported by the GPU (typically transformed into RGB). The texture will
* automatically have a key added, so it can be retrieved from the cache (assuming it is
* requested by a provider w/ the same genID). If srcColorSpace and dstColorSpace are
* specified, then a color conversion from src to dst will be applied to the pixels.
*
* On failure (e.g. the provider had no data), this returns NULL.
*/
sk_sp<GrTextureProxy> refAsTextureProxy(GrContext*, const GrSurfaceDesc&, bool useCache,
sk_sp<GrTextureProxy> refAsTextureProxy(GrContext*, const GrSurfaceDesc&,
const SkColorSpace* srcColorSpace,
const SkColorSpace* dstColorSpace);

View File

@ -816,7 +816,7 @@ sk_sp<GrTextureProxy> SkImage_Lazy::lockTextureProxy(GrContext* ctx,
// TODO: Update to create the mipped surface in the YUV generator and draw the base layer
// directly into the mipped surface.
proxy = provider.refAsTextureProxy(ctx, desc, true, generatorColorSpace, thisColorSpace);
proxy = provider.refAsTextureProxy(ctx, desc, generatorColorSpace, thisColorSpace);
if (proxy) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
kLockTexturePathCount);