aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrYUVProvider.cpp
diff options
context:
space:
mode:
authorGravatar Greg Daniel <egdaniel@google.com>2018-01-04 10:27:29 -0500
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2018-01-04 16:12:33 +0000
commit1445da6c03c7ce6a3039bd63498e1179a320722f (patch)
tree6092d32de7e9c6623da1c2866277610729c9f4e2 /src/gpu/GrYUVProvider.cpp
parent48ef021df81795f15746b3ca1d80339bf9a6c2d0 (diff)
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>
Diffstat (limited to 'src/gpu/GrYUVProvider.cpp')
-rw-r--r--src/gpu/GrYUVProvider.cpp57
1 files changed, 16 insertions, 41 deletions
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp
index 42319d2c06..0ca8cd90bd 100644
--- a/src/gpu/GrYUVProvider.cpp
+++ b/src/gpu/GrYUVProvider.cpp
@@ -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);
-
-private:
- // we only use one or the other of these
- sk_sp<SkCachedData> fCachedData;
- SkAutoMalloc fStorage;
-};
-}
+sk_sp<SkCachedData> init_provider(GrYUVProvider* provider, SkYUVPlanesCache::Info* yuvInfo,
+ void* planes[3]) {
+ sk_sp<SkCachedData> data;
+ data.reset(SkYUVPlanesCache::FindAndRef(provider->onGetID(), yuvInfo));
-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;
}