From 4431de6af930a8638c194b072558ea3a4b79d908 Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Tue, 13 Dec 2016 09:01:40 -0500 Subject: Add a deferred copy surface 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. Change-Id: Iab1867668d8146a766201158a251b9174438ee2b Reviewed-on: https://skia-review.googlesource.com/5773 Reviewed-by: Brian Osman Reviewed-by: Robert Phillips Commit-Queue: Robert Phillips --- tests/RectangleTextureTest.cpp | 37 ++++++++++++++++++++++++------------- 1 file changed, 24 insertions(+), 13 deletions(-) (limited to 'tests/RectangleTextureTest.cpp') diff --git a/tests/RectangleTextureTest.cpp b/tests/RectangleTextureTest.cpp index cc0c4d1e31..587160448c 100644 --- a/tests/RectangleTextureTest.cpp +++ b/tests/RectangleTextureTest.cpp @@ -15,7 +15,7 @@ #include "gl/GLTestContext.h" static void test_read_pixels(skiatest::Reporter* reporter, GrContext* context, - GrTexture* texture, uint32_t expectedPixelValues[]) { + GrSurface* texture, uint32_t expectedPixelValues[]) { int pixelCnt = texture->width() * texture->height(); SkAutoTMalloc pixels(pixelCnt); memset(pixels.get(), 0, sizeof(uint32_t)*pixelCnt); @@ -52,22 +52,30 @@ static void test_write_pixels(skiatest::Reporter* reporter, GrContext* context, } static void test_copy_surface_src(skiatest::Reporter* reporter, GrContext* context, - GrTexture* rectangleTexture, uint32_t expectedPixelValues[]) { + GrTexture* rectTexture, uint32_t expectedPixelValues[]) { + GrSurfaceDesc copyDstDesc; + copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig; + copyDstDesc.fWidth = rectTexture->width(); + copyDstDesc.fHeight = rectTexture->height(); + for (auto flags : {kNone_GrSurfaceFlags, kRenderTarget_GrSurfaceFlag}) { - GrSurfaceDesc copyDstDesc; - copyDstDesc.fConfig = kRGBA_8888_GrPixelConfig; - copyDstDesc.fWidth = rectangleTexture->width(); - copyDstDesc.fHeight = rectangleTexture->height(); copyDstDesc.fFlags = flags; - sk_sp dst( - context->textureProvider()->createTexture(copyDstDesc, SkBudgeted::kYes)); - context->copySurface(dst.get(), rectangleTexture); - test_read_pixels(reporter, context, dst.get(), expectedPixelValues); + + sk_sp dst(GrSurfaceProxy::TestCopy(context, copyDstDesc, + rectTexture, SkBudgeted::kYes)); + + GrSurface* dstSurf = dst->instantiate(context->textureProvider()); + + test_read_pixels(reporter, context, dstSurf, expectedPixelValues); } } static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* context, GrTexture* rectangleTexture) { + + sk_sp sContext(context->contextPriv().makeWrappedSurfaceContext( + sk_ref_sp(rectangleTexture))); + int pixelCnt = rectangleTexture->width() * rectangleTexture->height(); SkAutoTMalloc pixels(pixelCnt); for (int y = 0; y < rectangleTexture->width(); ++y) { @@ -81,10 +89,13 @@ static void test_copy_surface_dst(skiatest::Reporter* reporter, GrContext* conte copySrcDesc.fWidth = rectangleTexture->width(); copySrcDesc.fHeight = rectangleTexture->height(); copySrcDesc.fFlags = flags; - sk_sp src(context->textureProvider()->createTexture( - copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); - context->copySurface(rectangleTexture, src.get()); + sk_sp src(GrSurfaceProxy::MakeDeferred(*context->caps(), + context->textureProvider(), + copySrcDesc, + SkBudgeted::kYes, pixels.get(), 0)); + sContext->copy(src.get()); + test_read_pixels(reporter, context, rectangleTexture, pixels.get()); } } -- cgit v1.2.3