Initialize bitmaps to different colors, to avoid flaky success
This has been passing on devices where the readPixels is failing, because the bitmaps sometimes start out with the same contents. Bug: skia: Change-Id: I4bbe2274807184720c559871e6035f436e4f6e51 Reviewed-on: https://skia-review.googlesource.com/153670 Commit-Queue: Brian Osman <brianosman@google.com> Commit-Queue: Robert Phillips <robertphillips@google.com> Auto-Submit: Brian Osman <brianosman@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
This commit is contained in:
parent
f2ade42f3c
commit
ea30810348
@ -14,9 +14,10 @@
|
||||
#include "GrContextPriv.h"
|
||||
#include "Test.h"
|
||||
|
||||
static SkBitmap read_pixels(sk_sp<SkSurface> surface) {
|
||||
static SkBitmap read_pixels(sk_sp<SkSurface> surface, SkColor initColor) {
|
||||
SkBitmap bmp;
|
||||
bmp.allocN32Pixels(surface->width(), surface->height());
|
||||
bmp.eraseColor(initColor);
|
||||
if (!surface->readPixels(bmp, 0, 0)) {
|
||||
SkDebugf("readPixels failed\n");
|
||||
}
|
||||
@ -52,18 +53,18 @@ static void test_bug_6653(GrContext* ctx, skiatest::Reporter* reporter, const ch
|
||||
auto s1 = make_surface(ctx);
|
||||
s1->getCanvas()->clear(SK_ColorBLACK);
|
||||
s1->getCanvas()->drawOval(rect, paint);
|
||||
SkBitmap b1 = read_pixels(s1);
|
||||
SkBitmap b1 = read_pixels(s1, SK_ColorBLACK);
|
||||
s1 = nullptr;
|
||||
|
||||
// The bug requires that all three of the following surfaces are cleared to the same color
|
||||
auto s2 = make_surface(ctx);
|
||||
s2->getCanvas()->clear(SK_ColorBLUE);
|
||||
SkBitmap b2 = read_pixels(s2);
|
||||
SkBitmap b2 = read_pixels(s2, SK_ColorBLACK);
|
||||
s2 = nullptr;
|
||||
|
||||
auto s3 = make_surface(ctx);
|
||||
s3->getCanvas()->clear(SK_ColorBLUE);
|
||||
SkBitmap b3 = read_pixels(s3);
|
||||
SkBitmap b3 = read_pixels(s3, SK_ColorBLACK);
|
||||
s0->getCanvas()->drawBitmap(b3, 0, 0);
|
||||
s3 = nullptr;
|
||||
|
||||
@ -73,9 +74,10 @@ static void test_bug_6653(GrContext* ctx, skiatest::Reporter* reporter, const ch
|
||||
|
||||
// When this fails, b4 will "succeed", but return an empty bitmap (containing just the
|
||||
// clear color). Regardless, b5 will contain the oval that was just drawn, so diffing the
|
||||
// two bitmaps tests for the failure case.
|
||||
SkBitmap b4 = read_pixels(s4);
|
||||
SkBitmap b5 = read_pixels(s4);
|
||||
// two bitmaps tests for the failure case. Initialize the bitmaps to different colors so
|
||||
// that if the readPixels doesn't work, this test will always fail.
|
||||
SkBitmap b4 = read_pixels(s4, SK_ColorRED);
|
||||
SkBitmap b5 = read_pixels(s4, SK_ColorGREEN);
|
||||
|
||||
bool match = true;
|
||||
for (int y = 0; y < b4.height() && match; ++y) {
|
||||
|
Loading…
Reference in New Issue
Block a user