diff options
author | halcanary <halcanary@google.com> | 2015-12-09 10:21:59 -0800 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2015-12-09 10:21:59 -0800 |
commit | b260d130ca8bead7713b290ff0b56b427761922d (patch) | |
tree | ea286d8b7787cc40c5c21d1be11aa97c98262c0f /tests/BitmapTest.cpp | |
parent | 4a4f14ba3f93cc6bb9146be0f029a9badb1b95d9 (diff) |
SkBitmap::getColor repsects swizzle
Review URL: https://codereview.chromium.org/1510253002
Diffstat (limited to 'tests/BitmapTest.cpp')
-rw-r--r-- | tests/BitmapTest.cpp | 23 |
1 files changed, 23 insertions, 0 deletions
diff --git a/tests/BitmapTest.cpp b/tests/BitmapTest.cpp index 4d68e73dbe..2bd8490b77 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)); + } +} |