diff options
author | 2017-01-23 15:30:35 -0500 | |
---|---|---|
committer | 2017-01-24 12:23:28 +0000 | |
commit | bc7a4fb06780f9829b4b21470fe6f0503d2297cd (patch) | |
tree | d8a2460df05c73909530a3316cdc8b6192d5c55e /src/gpu/GrYUVProvider.cpp | |
parent | ad24145e41b473012a900818933291541e80815c (diff) |
Make GrYUVEffect take GrTextureProxies
This opens the door for swapping all the effects over to taking GrTextureProxies.
Change-Id: I3b03ba93a68f9945c9a8fee008fd170ed57616eb
Reviewed-on: https://skia-review.googlesource.com/7344
Reviewed-by: Brian Salomon <bsalomon@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'src/gpu/GrYUVProvider.cpp')
-rw-r--r-- | src/gpu/GrYUVProvider.cpp | 35 |
1 files changed, 22 insertions, 13 deletions
diff --git a/src/gpu/GrYUVProvider.cpp b/src/gpu/GrYUVProvider.cpp index 2f75d92b46..f3231a49da 100644 --- a/src/gpu/GrYUVProvider.cpp +++ b/src/gpu/GrYUVProvider.cpp @@ -6,7 +6,9 @@ */ #include "GrContext.h" +#include "GrContextPriv.h" #include "GrRenderTargetContext.h" +#include "GrTextureProxy.h" #include "GrYUVProvider.h" #include "effects/GrGammaEffect.h" #include "effects/GrYUVEffect.h" @@ -93,25 +95,29 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx, } GrSurfaceDesc yuvDesc; + yuvDesc.fOrigin = kTopLeft_GrSurfaceOrigin; yuvDesc.fConfig = kAlpha_8_GrPixelConfig; - sk_sp<GrTexture> yuvTextures[3]; + sk_sp<GrSurfaceContext> yuvTextureContexts[3]; for (int i = 0; i < 3; i++) { yuvDesc.fWidth = yuvInfo.fSizeInfo.fSizes[i].fWidth; yuvDesc.fHeight = yuvInfo.fSizeInfo.fSizes[i].fHeight; // TODO: why do we need this check? - bool needsExactTexture = + SkBackingFit fit = (yuvDesc.fWidth != yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fWidth) || - (yuvDesc.fHeight != yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight); - if (needsExactTexture) { - yuvTextures[i].reset(ctx->textureProvider()->createTexture(yuvDesc, SkBudgeted::kYes)); - } else { - yuvTextures[i].reset(ctx->textureProvider()->createApproxTexture(yuvDesc)); + (yuvDesc.fHeight != yuvInfo.fSizeInfo.fSizes[SkYUVSizeInfo::kY].fHeight) + ? SkBackingFit::kExact : SkBackingFit::kApprox; + + yuvTextureContexts[i] = ctx->contextPriv().makeDeferredSurfaceContext(yuvDesc, fit, + SkBudgeted::kYes); + if (!yuvTextureContexts[i]) { + return nullptr; + } + + const SkImageInfo ii = SkImageInfo::MakeA8(yuvDesc.fWidth, yuvDesc.fHeight); + if (!yuvTextureContexts[i]->writePixels(ii, planes[i], + yuvInfo.fSizeInfo.fWidthBytes[i], 0, 0)) { + return nullptr; } - if (!yuvTextures[i] || - !yuvTextures[i]->writePixels(0, 0, yuvDesc.fWidth, yuvDesc.fHeight, yuvDesc.fConfig, - planes[i], yuvInfo.fSizeInfo.fWidthBytes[i])) { - return nullptr; - } } // We never want to perform color-space conversion during the decode @@ -126,7 +132,10 @@ sk_sp<GrTexture> GrYUVProvider::refAsTexture(GrContext* ctx, GrPaint paint; sk_sp<GrFragmentProcessor> yuvToRgbProcessor( - GrYUVEffect::MakeYUVToRGB(yuvTextures[0].get(), yuvTextures[1].get(), yuvTextures[2].get(), + GrYUVEffect::MakeYUVToRGB(ctx, + sk_ref_sp(yuvTextureContexts[0]->asDeferredTexture()), + sk_ref_sp(yuvTextureContexts[1]->asDeferredTexture()), + sk_ref_sp(yuvTextureContexts[2]->asDeferredTexture()), yuvInfo.fSizeInfo.fSizes, yuvInfo.fColorSpace, false)); paint.addColorFragmentProcessor(std::move(yuvToRgbProcessor)); |