OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 #include "SkBitmap.h" | 8 #include "SkBitmap.h" |
9 #include "SkMallocPixelRef.h" | 9 #include "SkMallocPixelRef.h" |
10 #include "Test.h" | 10 #include "Test.h" |
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
115 } | 115 } |
116 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty()); | 116 REPORTER_ASSERT(reporter, SkToBool(width & height) != bm.empty()); |
117 } | 117 } |
118 } | 118 } |
119 | 119 |
120 test_bigwidth(reporter); | 120 test_bigwidth(reporter); |
121 test_allocpixels(reporter); | 121 test_allocpixels(reporter); |
122 test_bigalloc(reporter); | 122 test_bigalloc(reporter); |
123 test_peekpixels(reporter); | 123 test_peekpixels(reporter); |
124 } | 124 } |
| 125 |
| 126 /** |
| 127 * This test checks that getColor works for both swizzles. |
| 128 */ |
| 129 DEF_TEST(Bitmap_getColor_Swizzle, r) { |
| 130 SkBitmap source; |
| 131 source.allocN32Pixels(1,1); |
| 132 source.eraseColor(SK_ColorRED); |
| 133 SkColorType colorTypes[] = { |
| 134 kRGBA_8888_SkColorType, |
| 135 kBGRA_8888_SkColorType, |
| 136 }; |
| 137 for (SkColorType ct : colorTypes) { |
| 138 SkBitmap copy; |
| 139 if (!source.copyTo(©, ct)) { |
| 140 ERRORF(r, "SkBitmap::copy failed %d", (int)ct); |
| 141 continue; |
| 142 } |
| 143 SkAutoLockPixels autoLockPixels1(copy); |
| 144 SkAutoLockPixels autoLockPixels2(source); |
| 145 REPORTER_ASSERT(r, source.getColor(0, 0) == copy.getColor(0, 0)); |
| 146 } |
| 147 } |
OLD | NEW |