From 398487a850431cf495330d4023607df5305a311f Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 13 Dec 2016 15:29:42 -0500 Subject: Add a deferred copy surface (take 2) This CL forces all GrSurface copies to go through a GrSurfaceContext (rather than GrContext). There is a bit of goofiness going on here until read/writePixels is also consolidated in GrSurfaceContext and a proxy-backed SkImage/SkSurface is added. This is a reland of https://skia-review.googlesource.com/c/5773/ (Add a deferred copy surface) Change-Id: Ide560f569aede5e622420dc2f30eef76357d69f4 Reviewed-on: https://skia-review.googlesource.com/5939 Reviewed-by: Brian Osman Reviewed-by: Brian Salomon Commit-Queue: Robert Phillips --- tests/CopySurfaceTest.cpp | 36 ++++++++++++++++++++++++------------ 1 file changed, 24 insertions(+), 12 deletions(-) (limited to 'tests/CopySurfaceTest.cpp') diff --git a/tests/CopySurfaceTest.cpp b/tests/CopySurfaceTest.cpp index 053b456f57..68113e7ecc 100644 --- a/tests/CopySurfaceTest.cpp +++ b/tests/CopySurfaceTest.cpp @@ -10,6 +10,9 @@ #if SK_SUPPORT_GPU #include "GrContext.h" +#include "GrContextPriv.h" +#include "GrSurfaceContext.h" +#include "GrSurfaceProxy.h" #include "GrTexture.h" #include "GrTextureProvider.h" @@ -68,22 +71,29 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { dstDesc.fOrigin = dOrigin; dstDesc.fFlags = dFlags; - sk_sp src( - context->textureProvider()->createTexture(srcDesc, SkBudgeted::kNo, - srcPixels.get(), - kRowBytes)); - sk_sp dst( - context->textureProvider()->createTexture(dstDesc, SkBudgeted::kNo, - dstPixels.get(), - kRowBytes)); + sk_sp src(GrSurfaceProxy::MakeDeferred( + *context->caps(), + context->textureProvider(), + srcDesc, SkBudgeted::kNo, + srcPixels.get(), + kRowBytes)); + + sk_sp dst(GrSurfaceProxy::MakeDeferred( + *context->caps(), + context->textureProvider(), + dstDesc, SkBudgeted::kNo, + dstPixels.get(), + kRowBytes)); if (!src || !dst) { ERRORF(reporter, "Could not create surfaces for copy surface test."); continue; } - bool result - = context->copySurface(dst.get(), src.get(), srcRect, dstPoint); + sk_sp sContext = + context->contextPriv().makeTestSurfaceContext(dst); + + bool result = sContext->copy(src.get(), srcRect, dstPoint); bool expectedResult = true; SkIPoint dstOffset = { dstPoint.fX - srcRect.fLeft, @@ -120,9 +130,11 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(CopySurface, reporter, ctxInfo) { continue; } + GrSurface* dstSurf = dst->instantiate(context->textureProvider()); + sk_memset32(read.get(), 0, kW * kH); - if (!dst->readPixels(0, 0, kW, kH, baseDesc.fConfig, read.get(), - kRowBytes)) { + if (!dstSurf->readPixels(0, 0, kW, kH, baseDesc.fConfig, read.get(), + kRowBytes)) { ERRORF(reporter, "Error calling readPixels"); continue; } -- cgit v1.2.3