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

Side by Side Diff: gm/gmmain.cpp

Issue 234243002: Revert of Rename kPMColor_SkColorType to kN32_SkColorType. (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 8 months 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 | « gm/gammatext.cpp ('k') | gm/tilemodes.cpp » ('j') | 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 2011 Google Inc. 2 * Copyright 2011 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 /* 8 /*
9 * Code for the "gm" (Golden Master) rendering comparison tool. 9 * Code for the "gm" (Golden Master) rendering comparison tool.
10 * 10 *
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
261 } 261 }
262 } 262 }
263 263
264 /* since PNG insists on unpremultiplying our alpha, we take no 264 /* since PNG insists on unpremultiplying our alpha, we take no
265 precision chances and force all pixels to be 100% opaque, 265 precision chances and force all pixels to be 100% opaque,
266 otherwise on compare we may not get a perfect match. 266 otherwise on compare we may not get a perfect match.
267 */ 267 */
268 static void force_all_opaque(const SkBitmap& bitmap) { 268 static void force_all_opaque(const SkBitmap& bitmap) {
269 SkColorType colorType = bitmap.colorType(); 269 SkColorType colorType = bitmap.colorType();
270 switch (colorType) { 270 switch (colorType) {
271 case kN32_SkColorType: 271 case kPMColor_SkColorType:
272 force_all_opaque_8888(bitmap); 272 force_all_opaque_8888(bitmap);
273 break; 273 break;
274 case kRGB_565_SkColorType: 274 case kRGB_565_SkColorType:
275 // nothing to do here; 565 bitmaps are inherently opaque 275 // nothing to do here; 565 bitmaps are inherently opaque
276 break; 276 break;
277 default: 277 default:
278 SkDebugf("unsupported bitmap colorType %d\n", colorType); 278 SkDebugf("unsupported bitmap colorType %d\n", colorType);
279 DEBUGFAIL_SEE_STDERR; 279 DEBUGFAIL_SEE_STDERR;
280 } 280 }
281 } 281 }
282 282
283 static void force_all_opaque_8888(const SkBitmap& bitmap) { 283 static void force_all_opaque_8888(const SkBitmap& bitmap) {
284 SkAutoLockPixels lock(bitmap); 284 SkAutoLockPixels lock(bitmap);
285 for (int y = 0; y < bitmap.height(); y++) { 285 for (int y = 0; y < bitmap.height(); y++) {
286 for (int x = 0; x < bitmap.width(); x++) { 286 for (int x = 0; x < bitmap.width(); x++) {
287 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); 287 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);
288 } 288 }
289 } 289 }
290 } 290 }
291 291
292 static ErrorCombination write_bitmap(const SkString& path, const SkBitmap& b itmap) { 292 static ErrorCombination write_bitmap(const SkString& path, const SkBitmap& b itmap) {
293 // TODO(epoger): Now that we have removed force_all_opaque() 293 // TODO(epoger): Now that we have removed force_all_opaque()
294 // from this method, we should be able to get rid of the 294 // from this method, we should be able to get rid of the
295 // transformation to 8888 format also. 295 // transformation to 8888 format also.
296 SkBitmap copy; 296 SkBitmap copy;
297 bitmap.copyTo(&copy, kN32_SkColorType); 297 bitmap.copyTo(&copy, kPMColor_SkColorType);
298 if (!SkImageEncoder::EncodeFile(path.c_str(), copy, 298 if (!SkImageEncoder::EncodeFile(path.c_str(), copy,
299 SkImageEncoder::kPNG_Type, 299 SkImageEncoder::kPNG_Type,
300 100)) { 300 100)) {
301 SkDebugf("FAILED to write bitmap: %s\n", path.c_str()); 301 SkDebugf("FAILED to write bitmap: %s\n", path.c_str());
302 return ErrorCombination(kWritingReferenceImage_ErrorType); 302 return ErrorCombination(kWritingReferenceImage_ErrorType);
303 } 303 }
304 return kEmpty_ErrorCombination; 304 return kEmpty_ErrorCombination;
305 } 305 }
306 306
307 /** 307 /**
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after
733 const int expectedWidth = expectedBitmap.width(); 733 const int expectedWidth = expectedBitmap.width();
734 const int expectedHeight = expectedBitmap.height(); 734 const int expectedHeight = expectedBitmap.height();
735 const int width = actualBitmap.width(); 735 const int width = actualBitmap.width();
736 const int height = actualBitmap.height(); 736 const int height = actualBitmap.height();
737 if ((expectedWidth != width) || (expectedHeight != height)) { 737 if ((expectedWidth != width) || (expectedHeight != height)) {
738 SkDebugf("---- %s: dimension mismatch -- expected [%d %d], actual [% d %d]\n", 738 SkDebugf("---- %s: dimension mismatch -- expected [%d %d], actual [% d %d]\n",
739 testName, expectedWidth, expectedHeight, width, height); 739 testName, expectedWidth, expectedHeight, width, height);
740 return; 740 return;
741 } 741 }
742 742
743 if ((kN32_SkColorType != expectedBitmap.colorType()) || 743 if ((kPMColor_SkColorType != expectedBitmap.colorType()) ||
744 (kN32_SkColorType != actualBitmap.colorType())) { 744 (kPMColor_SkColorType != actualBitmap.colorType())) {
745 SkDebugf("---- %s: not computing max per-channel pixel mismatch beca use non-8888\n", 745 SkDebugf("---- %s: not computing max per-channel pixel mismatch beca use non-8888\n",
746 testName); 746 testName);
747 return; 747 return;
748 } 748 }
749 749
750 SkAutoLockPixels alp0(expectedBitmap); 750 SkAutoLockPixels alp0(expectedBitmap);
751 SkAutoLockPixels alp1(actualBitmap); 751 SkAutoLockPixels alp1(actualBitmap);
752 int errR = 0; 752 int errR = 0;
753 int errG = 0; 753 int errG = 0;
754 int errB = 0; 754 int errB = 0;
(...skipping 1686 matching lines...) Expand 10 before | Expand all | Expand 10 after
2441 if (FLAGS_forceBWtext) { 2441 if (FLAGS_forceBWtext) {
2442 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2442 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2443 } 2443 }
2444 } 2444 }
2445 2445
2446 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2446 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2447 int main(int argc, char * const argv[]) { 2447 int main(int argc, char * const argv[]) {
2448 return tool_main(argc, (char**) argv); 2448 return tool_main(argc, (char**) argv);
2449 } 2449 }
2450 #endif 2450 #endif
OLDNEW
« no previous file with comments | « gm/gammatext.cpp ('k') | gm/tilemodes.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698