| 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 if (reporter->verbose()) { | 154 INFOF(reporter, "expected: %x actual: %x\n", expected, bm.getColor(0, 0)); |
| 155 SkDebugf("expected: %x actual: %x\n", expected, bm.getColor(0, 0)); | |
| 156 } | |
| 157 REPORTER_ASSERT(reporter, bm.getColor(0, 0) == expected); | 155 REPORTER_ASSERT(reporter, bm.getColor(0, 0) == expected); |
| 158 } | 156 } |
| 159 | 157 |
| 160 /** | 158 /** |
| 161 * This test checks that eraseColor premultiplies the color correctly. | 159 * This test checks that eraseColor premultiplies the color correctly. |
| 162 */ | 160 */ |
| 163 DEF_TEST(Bitmap_eraseColor_Premul, r) { | 161 DEF_TEST(Bitmap_eraseColor_Premul, r) { |
| 164 SkColor color = 0x80FF0080; | 162 SkColor color = 0x80FF0080; |
| 165 test_erasecolor_premul(r, kAlpha_8_SkColorType, color, 0x80000000); | 163 test_erasecolor_premul(r, kAlpha_8_SkColorType, color, 0x80000000); |
| 166 test_erasecolor_premul(r, kRGB_565_SkColorType, color, 0xFF840042); | 164 test_erasecolor_premul(r, kRGB_565_SkColorType, color, 0xFF840042); |
| 167 test_erasecolor_premul(r, kARGB_4444_SkColorType, color, 0x88FF0080); | 165 test_erasecolor_premul(r, kARGB_4444_SkColorType, color, 0x88FF0080); |
| 168 test_erasecolor_premul(r, kRGBA_8888_SkColorType, color, color); | 166 test_erasecolor_premul(r, kRGBA_8888_SkColorType, color, color); |
| 169 test_erasecolor_premul(r, kBGRA_8888_SkColorType, color, color); | 167 test_erasecolor_premul(r, kBGRA_8888_SkColorType, color, color); |
| 170 } | 168 } |
| OLD | NEW |