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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 SkAutoLockPixels autoLockPixels2(source); | 144 SkAutoLockPixels autoLockPixels2(source); |
145 REPORTER_ASSERT(r, source.getColor(0, 0) == copy.getColor(0, 0)); | 145 REPORTER_ASSERT(r, source.getColor(0, 0) == copy.getColor(0, 0)); |
146 } | 146 } |
147 } | 147 } |
148 | 148 |
149 static void test_erasecolor_premul(skiatest::Reporter* reporter, SkColorType ct,
SkColor input, | 149 static void test_erasecolor_premul(skiatest::Reporter* reporter, SkColorType ct,
SkColor input, |
150 SkColor expected) { | 150 SkColor expected) { |
151 SkBitmap bm; | 151 SkBitmap bm; |
152 bm.allocPixels(SkImageInfo::Make(1, 1, ct, kPremul_SkAlphaType)); | 152 bm.allocPixels(SkImageInfo::Make(1, 1, ct, kPremul_SkAlphaType)); |
153 bm.eraseColor(input); | 153 bm.eraseColor(input); |
154 SkDebugf("expected: %x actual: %x\n", expected, bm.getColor(0, 0)); | 154 if (reporter->verbose()) { |
| 155 SkDebugf("expected: %x actual: %x\n", expected, bm.getColor(0, 0)); |
| 156 } |
155 REPORTER_ASSERT(reporter, bm.getColor(0, 0) == expected); | 157 REPORTER_ASSERT(reporter, bm.getColor(0, 0) == expected); |
156 } | 158 } |
157 | 159 |
158 /** | 160 /** |
159 * This test checks that eraseColor premultiplies the color correctly. | 161 * This test checks that eraseColor premultiplies the color correctly. |
160 */ | 162 */ |
161 DEF_TEST(Bitmap_eraseColor_Premul, r) { | 163 DEF_TEST(Bitmap_eraseColor_Premul, r) { |
162 SkColor color = 0x80FF0080; | 164 SkColor color = 0x80FF0080; |
163 test_erasecolor_premul(r, kAlpha_8_SkColorType, color, 0x80000000); | 165 test_erasecolor_premul(r, kAlpha_8_SkColorType, color, 0x80000000); |
164 test_erasecolor_premul(r, kRGB_565_SkColorType, color, 0xFF840042); | 166 test_erasecolor_premul(r, kRGB_565_SkColorType, color, 0xFF840042); |
165 test_erasecolor_premul(r, kARGB_4444_SkColorType, color, 0x88FF0080); | 167 test_erasecolor_premul(r, kARGB_4444_SkColorType, color, 0x88FF0080); |
166 test_erasecolor_premul(r, kRGBA_8888_SkColorType, color, color); | 168 test_erasecolor_premul(r, kRGBA_8888_SkColorType, color, color); |
167 test_erasecolor_premul(r, kBGRA_8888_SkColorType, color, color); | 169 test_erasecolor_premul(r, kBGRA_8888_SkColorType, color, color); |
168 } | 170 } |
OLD | NEW |