Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(208)

Side by Side Diff: tests/BitmapTest.cpp

Issue 1521673002: In SkPixmap.cpp, change SkAlphaMul to SkMulDiv255. (Closed) Base URL: https://skia.googlesource.com/skia@master
Patch Set: Make uppercase consistent. Created 5 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « src/core/SkPixmap.cpp ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 SkBitmap copy; 138 SkBitmap copy;
139 if (!source.copyTo(&copy, ct)) { 139 if (!source.copyTo(&copy, ct)) {
140 ERRORF(r, "SkBitmap::copy failed %d", (int)ct); 140 ERRORF(r, "SkBitmap::copy failed %d", (int)ct);
141 continue; 141 continue;
142 } 142 }
143 SkAutoLockPixels autoLockPixels1(copy); 143 SkAutoLockPixels autoLockPixels1(copy);
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
149 static void test_erasecolor_premul(skiatest::Reporter* reporter, SkColorType ct, SkColor input,
150 SkColor expected) {
151 SkBitmap bm;
152 bm.allocPixels(SkImageInfo::Make(1, 1, ct, kPremul_SkAlphaType));
153 bm.eraseColor(input);
154 SkDebugf("expected: %x actual: %x\n", expected, bm.getColor(0, 0));
155 REPORTER_ASSERT(reporter, bm.getColor(0, 0) == expected);
156 }
157
158 /**
159 * This test checks that eraseColor premultiplies the color correctly.
160 */
161 DEF_TEST(Bitmap_eraseColor_Premul, r) {
162 SkColor color = 0x80FF0080;
163 test_erasecolor_premul(r, kAlpha_8_SkColorType, color, 0x80000000);
164 test_erasecolor_premul(r, kRGB_565_SkColorType, color, 0xFF840042);
165 test_erasecolor_premul(r, kARGB_4444_SkColorType, color, 0x88FF0080);
166 test_erasecolor_premul(r, kRGBA_8888_SkColorType, color, color);
167 test_erasecolor_premul(r, kBGRA_8888_SkColorType, color, color);
168 }
OLDNEW
« no previous file with comments | « src/core/SkPixmap.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698