aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/gpu/GrYUVProvider.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/gpu/GrYUVProvider.cpp')
-rw-r--r--src/gpu/GrYUVProvider.cpp35
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));