aboutsummaryrefslogtreecommitdiffhomepage
path: root/tests/ReadWriteAlphaTest.cpp
diff options
context:
space:
mode:
authorGravatar robertphillips <robertphillips@google.com>2016-04-19 08:32:40 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2016-04-19 08:32:40 -0700
commitdf082c54257256ca7570fb3a75852d2af4e6a80c (patch)
treed5a467e51410f45474e8bf7f873ef30f1849e5e8 /tests/ReadWriteAlphaTest.cpp
parent2477594a3953d93c7fe22cfd03289abfba5a2d82 (diff)
Add more diagnostic messages to ReadWriteAlpha test
Diffstat (limited to 'tests/ReadWriteAlphaTest.cpp')
-rw-r--r--tests/ReadWriteAlphaTest.cpp33
1 files changed, 20 insertions, 13 deletions
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<uint8_t> 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<uint8_t> 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);
}