aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/image
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-27 13:34:01 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-27 13:34:01 -0700
commit2f1c42e8448bbbadeb3df1c626faa90aa33f8907 (patch)
treed5fc271e0eb33e4203617ce852ce79d73444e4fd /src/image
parent4eeccc9de7d2381df85d68e0331a40cddf5989b1 (diff)
Refactor drawContext/RenderTarget creation
Diffstat (limited to 'src/image')
-rw-r--r--src/image/SkImage_Gpu.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index a66a623638..eea7e2c040 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -249,17 +249,16 @@ sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace
return nullptr;
}
- GrSurfaceDesc dstDesc;
+ const int width = yuvSizes[0].fWidth;
+ const int height = yuvSizes[0].fHeight;
+
// Needs to be a render target in order to draw to it for the yuv->rgb conversion.
- dstDesc.fFlags = kRenderTarget_GrSurfaceFlag;
- dstDesc.fOrigin = origin;
- dstDesc.fWidth = yuvSizes[0].fWidth;
- dstDesc.fHeight = yuvSizes[0].fHeight;
- dstDesc.fConfig = kRGBA_8888_GrPixelConfig;
- dstDesc.fSampleCnt = 0;
-
- SkAutoTUnref<GrTexture> dst(ctx->textureProvider()->createTexture(dstDesc, SkBudgeted::kYes));
- if (!dst) {
+ sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(GrContext::kTight_BackingFit,
+ width, height,
+ kRGBA_8888_GrPixelConfig,
+ 0,
+ origin));
+ if (!drawContext) {
return nullptr;
}
@@ -268,17 +267,13 @@ sk_sp<SkImage> SkImage::MakeFromYUVTexturesCopy(GrContext* ctx , SkYUVColorSpace
paint.addColorFragmentProcessor(GrYUVEffect::CreateYUVToRGB(yTex, uTex, vTex, yuvSizes,
colorSpace))->unref();
- const SkRect rect = SkRect::MakeWH(SkIntToScalar(dstDesc.fWidth),
- SkIntToScalar(dstDesc.fHeight));
- sk_sp<GrDrawContext> drawContext(ctx->drawContext(sk_ref_sp(dst->asRenderTarget())));
- if (!drawContext) {
- return nullptr;
- }
+ const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect);
- ctx->flushSurfaceWrites(dst);
- return sk_make_sp<SkImage_Gpu>(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
- kOpaque_SkAlphaType, dst, budgeted);
+ ctx->flushSurfaceWrites(drawContext->accessRenderTarget());
+ return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID,
+ kOpaque_SkAlphaType,
+ drawContext->asTexture().get(), budgeted);
}
static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {