From df082c54257256ca7570fb3a75852d2af4e6a80c Mon Sep 17 00:00:00 2001 From: robertphillips Date: Tue, 19 Apr 2016 08:32:40 -0700 Subject: Add more diagnostic messages to ReadWriteAlpha test GOLD_TRYBOT_URL= https://gold.skia.org/search2?unt=true&query=source_type%3Dgm&master=false&issue=1902063002 Review URL: https://codereview.chromium.org/1902063002 --- tests/ReadWriteAlphaTest.cpp | 33 ++++++++++++++++++++------------- 1 file changed, 20 insertions(+), 13 deletions(-) (limited to 'tests/ReadWriteAlphaTest.cpp') diff --git a/tests/ReadWriteAlphaTest.cpp b/tests/ReadWriteAlphaTest.cpp index 851cf4e501..1f235fd97a 100644 --- a/tests/ReadWriteAlphaTest.cpp +++ b/tests/ReadWriteAlphaTest.cpp @@ -36,6 +36,8 @@ static void validate_alpha_data(skiatest::Reporter* reporter, int w, int h, cons DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { unsigned char alphaData[X_SIZE * Y_SIZE]; + static const int kClearValue = 0x2; + bool match; static const size_t kRowBytes[] = {0, X_SIZE, X_SIZE + 1, 2 * X_SIZE - 1}; for (int rt = 0; rt < 2; ++rt) { @@ -68,21 +70,23 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { for (auto rowBytes : kRowBytes) { // upload the texture (do per-rowbytes iteration because we may overwrite below). - texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, - alphaData, 0); + bool result = texture->writePixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, + alphaData, 0); + REPORTER_ASSERT_MESSAGE(reporter, result, "Initial A8 writePixels failed"); size_t nonZeroRowBytes = rowBytes ? rowBytes : X_SIZE; SkAutoTDeleteArray readback(new uint8_t[nonZeroRowBytes * Y_SIZE]); // clear readback to something non-zero so we can detect readback failures - memset(readback.get(), 0x1, nonZeroRowBytes * Y_SIZE); + memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE); // read the texture back - texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, - readback.get(), rowBytes); + result = texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, + readback.get(), rowBytes); + REPORTER_ASSERT_MESSAGE(reporter, result, "Initial A8 readPixels failed"); // make sure the original & read back versions match SkString msg; - msg.printf("rt:%d, rb:%d", rt, SkToU32(rowBytes)); + msg.printf("rt:%d, rb:%d A8", rt, SkToU32(rowBytes)); validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes, alphaData, msg); @@ -101,9 +105,10 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { canvas.drawRect(rect, paint); - memset(readback.get(), 0x1, nonZeroRowBytes * Y_SIZE); - texture->readPixels(0, 0, desc.fWidth, desc.fHeight, desc.fConfig, readback.get(), - rowBytes); + memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE); + result = texture->readPixels(0, 0, desc.fWidth, desc.fHeight, + desc.fConfig, readback.get(), rowBytes); + REPORTER_ASSERT_MESSAGE(reporter, result, "A8 readPixels after clear failed"); match = true; for (int y = 0; y < Y_SIZE && match; ++y) { @@ -166,15 +171,17 @@ DEF_GPUTEST_FOR_GL_RENDERING_CONTEXTS(ReadWriteAlpha, reporter, ctxInfo) { SkAutoTDeleteArray readback(new uint8_t[nonZeroRowBytes * Y_SIZE]); // Clear so we don't accidentally see values from previous iteration. - memset(readback.get(), 0x0, nonZeroRowBytes * Y_SIZE); + memset(readback.get(), kClearValue, nonZeroRowBytes * Y_SIZE); // read the texture back - texture->readPixels(0, 0, desc.fWidth, desc.fHeight, kAlpha_8_GrPixelConfig, - readback.get(), rowBytes); + bool result = texture->readPixels(0, 0, desc.fWidth, desc.fHeight, + kAlpha_8_GrPixelConfig, + readback.get(), rowBytes); + REPORTER_ASSERT_MESSAGE(reporter, result, "8888 readPixels failed"); // make sure the original & read back versions match SkString msg; - msg.printf("rt:%d, rb:%d", rt, SkToU32(rowBytes)); + msg.printf("rt:%d, rb:%d 8888", rt, SkToU32(rowBytes)); validate_alpha_data(reporter, X_SIZE, Y_SIZE, readback.get(), nonZeroRowBytes, alphaData, msg); } -- cgit v1.2.3