Index: tests/BitmapTest.cpp |
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp |
index 4d68e73dbe4dae7981f9ed52e1f1d96d2c6e7a1e..2bd8490b770ae481370aa36328c5c3d1d6cbad0d 100644 |
--- a/tests/BitmapTest.cpp |
+++ b/tests/BitmapTest.cpp |
@@ -122,3 +122,26 @@ DEF_TEST(Bitmap, reporter) { |
test_bigalloc(reporter); |
test_peekpixels(reporter); |
} |
+ |
+/** |
+ * This test checks that getColor works for both swizzles. |
+ */ |
+DEF_TEST(Bitmap_getColor_Swizzle, r) { |
+ SkBitmap source; |
+ source.allocN32Pixels(1,1); |
+ source.eraseColor(SK_ColorRED); |
+ SkColorType colorTypes[] = { |
+ kRGBA_8888_SkColorType, |
+ kBGRA_8888_SkColorType, |
+ }; |
+ for (SkColorType ct : colorTypes) { |
+ SkBitmap copy; |
+ if (!source.copyTo(©, ct)) { |
+ ERRORF(r, "SkBitmap::copy failed %d", (int)ct); |
+ continue; |
+ } |
+ SkAutoLockPixels autoLockPixels1(copy); |
+ SkAutoLockPixels autoLockPixels2(source); |
+ REPORTER_ASSERT(r, source.getColor(0, 0) == copy.getColor(0, 0)); |
+ } |
+} |