Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(637)

Unified Diff: src/image/SkImage_Gpu.cpp

Issue 1929833004: Revert of Refactor drawContext/RenderTarget creation (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | tests/ClearTest.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/image/SkImage_Gpu.cpp
diff --git a/src/image/SkImage_Gpu.cpp b/src/image/SkImage_Gpu.cpp
index eea7e2c04074e191eee77d1e022348c338f92757..a66a623638ad7a3d8a5c4fb53ac7a4d94a77104a 100644
--- a/src/image/SkImage_Gpu.cpp
+++ b/src/image/SkImage_Gpu.cpp
@@ -249,16 +249,17 @@
return nullptr;
}
- const int width = yuvSizes[0].fWidth;
- const int height = yuvSizes[0].fHeight;
-
+ GrSurfaceDesc dstDesc;
// Needs to be a render target in order to draw to it for the yuv->rgb conversion.
- sk_sp<GrDrawContext> drawContext(ctx->newDrawContext(GrContext::kTight_BackingFit,
- width, height,
- kRGBA_8888_GrPixelConfig,
- 0,
- origin));
- if (!drawContext) {
+ 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) {
return nullptr;
}
@@ -267,13 +268,17 @@
paint.addColorFragmentProcessor(GrYUVEffect::CreateYUVToRGB(yTex, uTex, vTex, yuvSizes,
colorSpace))->unref();
- const SkRect rect = SkRect::MakeWH(SkIntToScalar(width), SkIntToScalar(height));
+ 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;
+ }
drawContext->drawRect(GrClip::WideOpen(), paint, SkMatrix::I(), rect);
- ctx->flushSurfaceWrites(drawContext->accessRenderTarget());
- return sk_make_sp<SkImage_Gpu>(width, height, kNeedNewImageUniqueID,
- kOpaque_SkAlphaType,
- drawContext->asTexture().get(), budgeted);
+ ctx->flushSurfaceWrites(dst);
+ return sk_make_sp<SkImage_Gpu>(dstDesc.fWidth, dstDesc.fHeight, kNeedNewImageUniqueID,
+ kOpaque_SkAlphaType, dst, budgeted);
}
static sk_sp<SkImage> create_image_from_maker(GrTextureMaker* maker, SkAlphaType at, uint32_t id) {
« no previous file with comments | « src/gpu/GrContext.cpp ('k') | tests/ClearTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698