diff options
author | Robert Phillips <robertphillips@google.com> | 2016-12-15 09:23:05 -0500 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2016-12-15 15:07:39 +0000 |
commit | e2f7d1899d890c2f08571e1bd6c7fa2c5ea1be0b (patch) | |
tree | d290f1a9d5d5e828c7177d230f56356f9fc9bf2e /tests/RectangleTextureTest.cpp | |
parent | db8f44f497f2b67b2500bbfc7b11ce7a510c5e5c (diff) |
Add a deferred copy surface (take 3)
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: Ib8fd96d0569274ef781366eb900ed8ee839ae9bd
Reviewed-on: https://skia-review.googlesource.com/6109
Reviewed-by: Brian Salomon <bsalomon@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Commit-Queue: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/RectangleTextureTest.cpp')
-rw-r--r-- | tests/RectangleTextureTest.cpp | 37 |
1 files changed, 24 insertions, 13 deletions
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<uint32_t> 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<GrTexture> dst( - context->textureProvider()->createTexture(copyDstDesc, SkBudgeted::kYes)); - context->copySurface(dst.get(), rectangleTexture); - test_read_pixels(reporter, context, dst.get(), expectedPixelValues); + + sk_sp<GrSurfaceProxy> 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<GrSurfaceContext> sContext(context->contextPriv().makeWrappedSurfaceContext( + sk_ref_sp(rectangleTexture))); + int pixelCnt = rectangleTexture->width() * rectangleTexture->height(); SkAutoTMalloc<uint32_t> 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<GrTexture> src(context->textureProvider()->createTexture( - copySrcDesc, SkBudgeted::kYes, pixels.get(), 0)); - context->copySurface(rectangleTexture, src.get()); + sk_sp<GrSurfaceProxy> 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()); } } |