From a9d9a392380952006303d83c35a63a32dffd0b36 Mon Sep 17 00:00:00 2001 From: kkinnunen Date: Fri, 6 Mar 2015 07:16:00 -0800 Subject: [PATCH] Read pixels in BGRA non-premul mode in few tests The tests assert on Sk_ColorGREEN, which is in BRGA non-premul. Read the pixels in same color format. Currently the tests pass on all platforms because GREEN is fully opaque and the component stays in the same place both on BGRA and RGBA. However, hypothetically somebody could copy-paste the assertion for further tests but use, say, RED. This creates latent error that is only visible on some platforms like mac. Review URL: https://codereview.chromium.org/989463002 --- tests/ImageFilterTest.cpp | 4 ++-- tests/SkImageTest.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/ImageFilterTest.cpp b/tests/ImageFilterTest.cpp index 2798ea0..430481f 100644 --- a/tests/ImageFilterTest.cpp +++ b/tests/ImageFilterTest.cpp @@ -1010,7 +1010,7 @@ static void test_xfermode_cropped_input(SkBaseDevice* device, skiatest::Reporter canvas.drawSprite(bitmap, 0, 0, &paint); uint32_t pixel; - SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); + SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType); canvas.readPixels(info, &pixel, 4, 0, 0); REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); @@ -1059,7 +1059,7 @@ DEF_TEST(ImageFilterNestedSaveLayer, reporter) { strokePaint.setStyle(SkPaint::kStroke_Style); strokePaint.setColor(SK_ColorRED); - SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); + SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType); uint32_t pixel; canvas.readPixels(info, &pixel, 4, 25, 25); REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); diff --git a/tests/SkImageTest.cpp b/tests/SkImageTest.cpp index 80ba776..3ba63b4 100644 --- a/tests/SkImageTest.cpp +++ b/tests/SkImageTest.cpp @@ -38,7 +38,7 @@ DEF_TEST(SkImageFromBitmap_extractSubset, reporter) { canvas.drawImage(image, 0, 0, NULL); uint32_t pixel = 0; - SkImageInfo info = SkImageInfo::MakeN32Premul(1, 1); + SkImageInfo info = SkImageInfo::Make(1, 1, kBGRA_8888_SkColorType, kUnpremul_SkAlphaType); canvas.readPixels(info, &pixel, 4, 0, 0); REPORTER_ASSERT(reporter, pixel == SK_ColorGREEN); canvas.readPixels(info, &pixel, 4, gWidth - 6, gWidth - 6); -- 2.7.4