diff options
author | Robert Phillips <robertphillips@google.com> | 2017-04-17 07:43:27 -0400 |
---|---|---|
committer | Skia Commit-Bot <skia-commit-bot@chromium.org> | 2017-04-17 12:28:13 +0000 |
commit | bab2dbb5fa50da8e8365abbaa9f1490e659f436c (patch) | |
tree | 902cc5b3632fb138e19c5ac3b436785b5530288b /tests/ReadWriteAlphaTest.cpp | |
parent | f9c090404824581a12eeee65875dda7347768657 (diff) |
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 <rmistry@google.com>
Reviewed-by: Robert Phillips <robertphillips@google.com>
Diffstat (limited to 'tests/ReadWriteAlphaTest.cpp')
-rw-r--r-- | tests/ReadWriteAlphaTest.cpp | 17 |
1 files changed, 10 insertions, 7 deletions
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<GrSurfaceContext> 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 |