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/GrSRGBEffect.h"
#include "effects/GrYUVtoRGBEffect.h" #include "effects/GrYUVtoRGBEffect.h"
namespace { sk_sp<SkCachedData> init_provider(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo,
/** void* planes[3]) {
* Helper class to manage the resources used for storing the YUV planar data. Depending on the sk_sp<SkCachedData> data;
* useCache option, we may find (and lock) the data in our ResourceCache, or we may have allocated data.reset(SkYUVPlanesCache::FindAndRef(provider->onGetID(), yuvInfo));
* it in scratch storage.
*/
class YUVScoper {
public:
bool init(GrYUVProvider*, SkYUVPlanesCache::Info*, void* planes[3], bool useCache);
private: if (data.get()) {
// we only use one or the other of these planes[0] = (void*)data->data();
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();
planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] * planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] *
yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
planes[2] = (uint8_t*)planes[1] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kU] * 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 { } else {
// Fetch yuv plane sizes for memory allocation. // Fetch yuv plane sizes for memory allocation.
if (!provider->onQueryYUV8(&yuvInfo->fSizeInfo, &yuvInfo->fColorSpace)) { if (!provider->onQueryYUV8(&yuvInfo->fSizeInfo, &yuvInfo->fColorSpace)) {
return false; return nullptr;
} }
// Allocate the memory for YUV // 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++) { for (int i = 0; i < 3; i++) {
totalSize += yuvInfo->fSizeInfo.fWidthBytes[i] * yuvInfo->fSizeInfo.fSizes[i].fHeight; totalSize += yuvInfo->fSizeInfo.fWidthBytes[i] * yuvInfo->fSizeInfo.fSizes[i].fHeight;
} }
if (useCache) { data.reset(SkResourceCache::NewCachedData(totalSize));
fCachedData.reset(SkResourceCache::NewCachedData(totalSize)); planes[0] = data->writable_data();
planes[0] = fCachedData->writable_data();
} else {
fStorage.reset(totalSize);
planes[0] = fStorage.get();
}
planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] * planes[1] = (uint8_t*)planes[0] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kY] *
yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); yuvInfo->fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight);
planes[2] = (uint8_t*)planes[1] + (yuvInfo->fSizeInfo.fWidthBytes[SkYUVSizeInfo::kU] * 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. // Get the YUV planes.
if (!provider->onGetYUV8Planes(yuvInfo->fSizeInfo, planes)) { if (!provider->onGetYUV8Planes(yuvInfo->fSizeInfo, planes)) {
return false; return nullptr;
} }
if (useCache) { // Decoding is done, cache the resulting YUV planes
// Decoding is done, cache the resulting YUV planes SkYUVPlanesCache::Add(provider->onGetID(), data.get(), yuvInfo);
SkYUVPlanesCache::Add(provider->onGetID(), fCachedData.get(), yuvInfo);
}
} }
return true; return data;
} }
sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrSurfaceDesc& desc, sk_sp<GrTextureProxy> GrYUVProvider::refAsTextureProxy(GrContext* ctx, const GrSurfaceDesc& desc,
bool useCache,
const SkColorSpace* srcColorSpace, const SkColorSpace* srcColorSpace,
const SkColorSpace* dstColorSpace) { const SkColorSpace* dstColorSpace) {
SkYUVPlanesCache::Info yuvInfo; SkYUVPlanesCache::Info yuvInfo;
void* planes[3]; 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; 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 * 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 * into a form that is supported by the GPU (typically transformed into RGB). The texture will
* is true, then the texture will automatically have a key added, so it can be retrieved * automatically have a key added, so it can be retrieved from the cache (assuming it is
* from the cache (assuming it is requested by a provider w/ the same genID). If srcColorSpace * requested by a provider w/ the same genID). If srcColorSpace and dstColorSpace are
* and dstColorSpace are specified, then a color conversion from src to dst will be applied to * specified, then a color conversion from src to dst will be applied to the pixels.
* the pixels.
* *
* On failure (e.g. the provider had no data), this returns NULL. * 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* srcColorSpace,
const SkColorSpace* dstColorSpace); 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 // TODO: Update to create the mipped surface in the YUV generator and draw the base layer
// directly into the mipped surface. // directly into the mipped surface.
proxy = provider.refAsTextureProxy(ctx, desc, true, generatorColorSpace, thisColorSpace); proxy = provider.refAsTextureProxy(ctx, desc, generatorColorSpace, thisColorSpace);
if (proxy) { if (proxy) {
SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath, SK_HISTOGRAM_ENUMERATION("LockTexturePath", kYUV_LockTexturePath,
kLockTexturePathCount); kLockTexturePathCount);