diff options
author | Robert Phillips <robertphillips@google.com> | 2017-04-18 07:48:58 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-18 12:29:07 +0000 |
commit | f41c22fca369af85b06ff34bae8a41c6672aff43 (patch) | |
tree | 2fe43da6efca51b046b285019429362656d8cf1c /tests | |
parent | 7efa0476306588dae9e3149f72f7018f74714cd4 (diff) |
Pass GrSurfaceContext into read/writeSurfacePixels
This is mainly so writeSurfacePixels can have continuity of surfaceContext when it draws.
Change-Id: I34f1dc5c4c3dcfa7bf91aa3ad72b7a48ed9de1a9
Reviewed-on: https://skia-review.googlesource.com/13595
Commit-Queue: Robert Phillips <robertphillips@google.com>
Reviewed-by: Brian Osman <brianosman@google.com>
Diffstat (limited to 'tests')
-rw-r--r-- | tests/FloatingPointTextureTest.cpp | 7 | ||||
-rw-r--r-- | tests/IntTextureTest.cpp | 36 |
2 files changed, 27 insertions, 16 deletions
diff --git a/tests/FloatingPointTextureTest.cpp b/tests/FloatingPointTextureTest.cpp index 5adc2e7892..e092921cbb 100644 --- a/tests/FloatingPointTextureTest.cpp +++ b/tests/FloatingPointTextureTest.cpp @@ -59,7 +59,12 @@ void runFPTest(skiatest::Reporter* reporter, GrContext* context, if (!fpProxy) { continue; } - bool result = context->contextPriv().readSurfacePixels(fpProxy.get(), nullptr, + + sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext( + std::move(fpProxy), nullptr); + REPORTER_ASSERT(reporter, sContext); + + bool result = context->contextPriv().readSurfacePixels(sContext.get(), 0, 0, DEV_W, DEV_H, desc.fConfig, nullptr, readBuffer.begin(), 0); diff --git a/tests/IntTextureTest.cpp b/tests/IntTextureTest.cpp index eacd0617a2..daeb13e53d 100644 --- a/tests/IntTextureTest.cpp +++ b/tests/IntTextureTest.cpp @@ -82,10 +82,16 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { return; } + sk_sp<GrSurfaceContext> sContext = context->contextPriv().makeWrappedSurfaceContext( + std::move(proxy), nullptr); + if (!sContext) { + return; + } + std::unique_ptr<int32_t[]> readData(new int32_t[kS * kS]); // Test that reading to a non-integer config fails. { - bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, + bool success = context->contextPriv().readSurfacePixels(sContext.get(), 0, 0, kS, kS, kRGBA_8888_GrPixelConfig, nullptr, readData.get()); @@ -93,7 +99,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { } { std::unique_ptr<uint16_t[]> halfData(new uint16_t[4 * kS * kS]); - bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, + bool success = context->contextPriv().readSurfacePixels(sContext.get(), 0, 0, kS, kS, kRGBA_half_GrPixelConfig, nullptr, halfData.get()); @@ -104,7 +110,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { // we don't support. Right now this test is counting on GR_RGBA_INTEGER/GL_BYTE being the // implementation-dependent second format). sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - bool success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, + bool success = context->contextPriv().readSurfacePixels(sContext.get(), 0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, nullptr, readData.get()); @@ -116,7 +122,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { { // readPixels should fail if we attempt to use the unpremul flag with an integer texture. bool success = context->contextPriv().readSurfacePixels( - proxy.get(), nullptr, + sContext.get(), 0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, nullptr, readData.get(), 0, @@ -127,15 +133,14 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { // Test that copying from one integer texture to another succeeds. { sk_sp<GrSurfaceContext> dstContext(GrSurfaceProxy::TestCopy(context, desc, - proxy.get())); + sContext->asSurfaceProxy())); REPORTER_ASSERT(reporter, dstContext); if (!dstContext || !dstContext->asTextureProxy()) { return; } sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - bool success = context->contextPriv().readSurfacePixels(dstContext->asSurfaceProxy(), - nullptr, 0, 0, kS, kS, + bool success = context->contextPriv().readSurfacePixels(dstContext.get(), 0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, nullptr, readData.get()); REPORTER_ASSERT(reporter, success); @@ -151,7 +156,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { nonIntDesc.fConfig = kRGBA_8888_GrPixelConfig; sk_sp<GrSurfaceContext> dstContext(GrSurfaceProxy::TestCopy(context, nonIntDesc, - proxy.get())); + sContext->asSurfaceProxy())); REPORTER_ASSERT(reporter, !dstContext); } @@ -161,7 +166,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { nonIntDesc.fConfig = kRGBA_half_GrPixelConfig; sk_sp<GrSurfaceContext> dstContext(GrSurfaceProxy::TestCopy(context, nonIntDesc, - proxy.get())); + sContext->asSurfaceProxy())); REPORTER_ASSERT(reporter, !dstContext); } @@ -171,7 +176,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { { // Can't write pixels from a non-int config. - bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr, + bool success = context->contextPriv().writeSurfacePixels(sContext.get(), 0, 0, kS/2, kS/2, kRGBA_8888_GrPixelConfig, nullptr, bottomRightQuarter, kRowBytes); @@ -180,7 +185,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { { // Can't use unpremul flag. bool success = context->contextPriv().writeSurfacePixels( - proxy.get(), nullptr, + sContext.get(), 0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig, nullptr, @@ -189,7 +194,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { REPORTER_ASSERT(reporter, !success); } { - bool success = context->contextPriv().writeSurfacePixels(proxy.get(), nullptr, + bool success = context->contextPriv().writeSurfacePixels(sContext.get(), 0, 0, kS/2, kS/2, kRGBA_8888_sint_GrPixelConfig, nullptr, @@ -200,7 +205,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { } sk_bzero(readData.get(), sizeof(int32_t) * kS * kS); - success = context->contextPriv().readSurfacePixels(proxy.get(), nullptr, + success = context->contextPriv().readSurfacePixels(sContext.get(), 0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, nullptr, readData.get(), 0); @@ -234,7 +239,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { expectedData.get()[i] = ((0xFF * a) << 24) | ((0xFF * b) << 16) | ((0xFF * g) << 8) | (0xFF * r); } - context->contextPriv().writeSurfacePixels(proxy.get(), nullptr, + context->contextPriv().writeSurfacePixels(sContext.get(), 0, 0, kS, kS, kRGBA_8888_sint_GrPixelConfig, nullptr, testData.get(), 0); @@ -253,7 +258,8 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(IntTexture, reporter, ctxInfo) { for (auto filter : kNamedFilters) { sk_sp<GrFragmentProcessor> fp(GrSimpleTextureEffect::Make(context->resourceProvider(), - proxy, nullptr, + sContext->asTextureProxyRef(), + nullptr, SkMatrix::I(), filter.fMode)); REPORTER_ASSERT(reporter, fp); |