From bab2dbb5fa50da8e8365abbaa9f1490e659f436c Mon Sep 17 00:00:00 2001 From: Robert Phillips Date: Mon, 17 Apr 2017 07:43:27 -0400 Subject: Reduce read/write-SurfacePixels call sites (take 2) Reland of: https://skia-review.googlesource.com/c/13068/ (Reduce read/write-SurfacePixels call sites) TBR=brianosman@google.com Change-Id: I035b9fc2feab5fa443570ca54fbb0df8c9382cb3 Reviewed-on: https://skia-review.googlesource.com/13582 Commit-Queue: Ravi Mistry Reviewed-by: Robert Phillips --- tests/ReadWriteAlphaTest.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'tests/ReadWriteAlphaTest.cpp') diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index 2a68191a2d..531159ff6f 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -142,13 +142,17 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { } } + const SkImageInfo dstInfo = SkImageInfo::Make(X_SIZE, Y_SIZE, + kAlpha_8_SkColorType, + kPremul_SkAlphaType); + // Attempt to read back just alpha from a RGBA/BGRA texture. Once with a texture-only src and // once with a render target. - for (auto cfg : kRGBAConfigs) { + for (auto config : kRGBAConfigs) { for (int rt = 0; rt < 2; ++rt) { GrSurfaceDesc desc; desc.fFlags = rt ? kRenderTarget_GrSurfaceFlag : kNone_GrSurfaceFlags; - desc.fConfig = cfg; + desc.fConfig = config; desc.fWidth = X_SIZE; desc.fHeight = Y_SIZE; @@ -170,6 +174,9 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { continue; } + sk_sp sContext = context->contextPriv().makeWrappedSurfaceContext( + std::move(proxy), nullptr); + for (auto rowBytes : kRowBytes) { size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE; @@ -178,11 +185,7 @@ DEF_GPUTEST_FOR_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE); // read the texture back - bool result = context->contextPriv().readSurfacePixels( - proxy.get(), nullptr, - 0, 0, desc.fWidth, desc.fHeight, - kAlpha_8_GrPixelConfig, nullptr, - readback.get(), rowBytes); + bool result = sContext->readPixels(dstInfo, readback.get(), rowBytes, 0, 0); REPORTER_ASSERT_MESSAGE(reporter, result, "8888 readPixels failed"); // make sure the original & read back versions match -- cgit v1.2.3