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

Side by Side Diff: gm/gmmain.cpp

Issue 17365002: GM: add --writeChecksumBasedFilenames option (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_make_bitmap_filename Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | gm/tests/outputs/checksum-based-filenames/output-expected/command_line » ('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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after
218 const char *configName, 218 const char *configName,
219 const char *renderModeDescriptor, 219 const char *renderModeDescriptor,
220 const char *suffix) { 220 const char *suffix) {
221 SkString filename = make_shortname_plus_config(shortName, configName); 221 SkString filename = make_shortname_plus_config(shortName, configName);
222 filename.append(renderModeDescriptor); 222 filename.append(renderModeDescriptor);
223 filename.appendUnichar('.'); 223 filename.appendUnichar('.');
224 filename.append(suffix); 224 filename.append(suffix);
225 return SkOSPath::SkPathJoin(path, filename.c_str()); 225 return SkOSPath::SkPathJoin(path, filename.c_str());
226 } 226 }
227 227
228 /**
229 * Assemble filename suitable for writing out an SkBitmap.
230 */
231 SkString make_bitmap_filename(const char *path,
epoger 2013/06/18 05:45:36 Patchset 2 adds the make_bitmap_filename() wrapper
232 const char *shortName,
233 const char *configName,
234 const char *renderModeDescriptor) {
235 return make_filename(path, shortName, configName, renderModeDescriptor, kPNG_FileExtension);
236 }
237
228 /* since PNG insists on unpremultiplying our alpha, we take no 238 /* since PNG insists on unpremultiplying our alpha, we take no
229 precision chances and force all pixels to be 100% opaque, 239 precision chances and force all pixels to be 100% opaque,
230 otherwise on compare we may not get a perfect match. 240 otherwise on compare we may not get a perfect match.
231 */ 241 */
232 static void force_all_opaque(const SkBitmap& bitmap) { 242 static void force_all_opaque(const SkBitmap& bitmap) {
233 SkBitmap::Config config = bitmap.config(); 243 SkBitmap::Config config = bitmap.config();
234 switch (config) { 244 switch (config) {
235 case SkBitmap::kARGB_8888_Config: 245 case SkBitmap::kARGB_8888_Config:
236 force_all_opaque_8888(bitmap); 246 force_all_opaque_8888(bitmap);
237 break; 247 break;
238 case SkBitmap::kRGB_565_Config: 248 case SkBitmap::kRGB_565_Config:
239 // nothing to do here; 565 bitmaps are inherently opaque 249 // nothing to do here; 565 bitmaps are inherently opaque
240 break; 250 break;
241 default: 251 default:
242 gm_fprintf(stderr, "unsupported bitmap config %d\n", config); 252 gm_fprintf(stderr, "unsupported bitmap config %d\n", config);
243 DEBUGFAIL_SEE_STDERR; 253 DEBUGFAIL_SEE_STDERR;
244 } 254 }
245 } 255 }
246 256
247 static void force_all_opaque_8888(const SkBitmap& bitmap) { 257 static void force_all_opaque_8888(const SkBitmap& bitmap) {
248 SkAutoLockPixels lock(bitmap); 258 SkAutoLockPixels lock(bitmap);
249 for (int y = 0; y < bitmap.height(); y++) { 259 for (int y = 0; y < bitmap.height(); y++) {
250 for (int x = 0; x < bitmap.width(); x++) { 260 for (int x = 0; x < bitmap.width(); x++) {
251 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); 261 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT);
252 } 262 }
253 } 263 }
254 } 264 }
255 265
266 // EPOGER: make sure to create any directories needed along the path
267 // EPOGER: make sure this works even if the destination file already exists -- just overwrite it
256 static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { 268 static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) {
257 // TODO(epoger): Now that we have removed force_all_opaque() 269 // TODO(epoger): Now that we have removed force_all_opaque()
258 // from this method, we should be able to get rid of the 270 // from this method, we should be able to get rid of the
259 // transformation to 8888 format also. 271 // transformation to 8888 format also.
260 SkBitmap copy; 272 SkBitmap copy;
261 bitmap.copyTo(&copy, SkBitmap::kARGB_8888_Config); 273 bitmap.copyTo(&copy, SkBitmap::kARGB_8888_Config);
262 return SkImageEncoder::EncodeFile(path.c_str(), copy, 274 return SkImageEncoder::EncodeFile(path.c_str(), copy,
263 SkImageEncoder::kPNG_Type, 100); 275 SkImageEncoder::kPNG_Type, 100);
264 } 276 }
265 277
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after
635 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], 647 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [],
636 const char renderModeDescriptor [], 648 const char renderModeDescriptor [],
637 const char *shortName, SkBitmap& bitm ap, 649 const char *shortName, SkBitmap& bitm ap,
638 SkDynamicMemoryWStream* document) { 650 SkDynamicMemoryWStream* document) {
639 SkString path; 651 SkString path;
640 bool success = false; 652 bool success = false;
641 if (gRec.fBackend == kRaster_Backend || 653 if (gRec.fBackend == kRaster_Backend ||
642 gRec.fBackend == kGPU_Backend || 654 gRec.fBackend == kGPU_Backend ||
643 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { 655 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
644 656
645 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 657 path = make_bitmap_filename(writePath, shortName, gRec.fName, render ModeDescriptor);
646 kPNG_FileExtension);
647 success = write_bitmap(path, bitmap); 658 success = write_bitmap(path, bitmap);
648 } 659 }
649 if (kPDF_Backend == gRec.fBackend) { 660 if (kPDF_Backend == gRec.fBackend) {
650 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 661 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
651 "pdf"); 662 "pdf");
652 success = write_document(path, *document); 663 success = write_document(path, *document);
653 } 664 }
654 if (kXPS_Backend == gRec.fBackend) { 665 if (kXPS_Backend == gRec.fBackend) {
655 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, 666 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor,
656 "xps"); 667 "xps");
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
773 // in a non-standard renderMode. 784 // in a non-standard renderMode.
774 if ('\0' == *renderModeDescriptor) { 785 if ('\0' == *renderModeDescriptor) {
775 errors.add(kExpectationsMismatch_ErrorType); 786 errors.add(kExpectationsMismatch_ErrorType);
776 } else { 787 } else {
777 errors.add(kRenderModeMismatch_ErrorType); 788 errors.add(kRenderModeMismatch_ErrorType);
778 } 789 }
779 790
780 // Write out the "actuals" for any mismatches, if we have 791 // Write out the "actuals" for any mismatches, if we have
781 // been directed to do so. 792 // been directed to do so.
782 if (fMismatchPath) { 793 if (fMismatchPath) {
783 SkString path = 794 SkString path = make_bitmap_filename(fMismatchPath, shortName, c onfigName,
784 make_filename(fMismatchPath, shortName, configName, renderMo deDescriptor, 795 renderModeDescriptor);
785 kPNG_FileExtension);
786 write_bitmap(path, actualBitmap); 796 write_bitmap(path, actualBitmap);
787 } 797 }
788 798
789 // If we have access to a single expected bitmap, log more 799 // If we have access to a single expected bitmap, log more
790 // detail about the mismatch. 800 // detail about the mismatch.
791 const SkBitmap *expectedBitmapPtr = expectations.asBitmap(); 801 const SkBitmap *expectedBitmapPtr = expectations.asBitmap();
792 if (NULL != expectedBitmapPtr) { 802 if (NULL != expectedBitmapPtr) {
793 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me); 803 report_bitmap_diffs(*expectedBitmapPtr, actualBitmap, completeNa me);
794 } 804 }
795 } 805 }
(...skipping 500 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 "any differences between those and the newly generated ones."); 1306 "any differences between those and the newly generated ones.");
1297 DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass."); 1307 DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass.");
1298 DEFINE_string2(resourcePath, i, "", "Directory that stores image resources."); 1308 DEFINE_string2(resourcePath, i, "", "Directory that stores image resources.");
1299 DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass."); 1309 DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass.");
1300 DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserializa tion test pass."); 1310 DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserializa tion test pass.");
1301 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in pipe mode only."); 1311 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in pipe mode only.");
1302 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); 1312 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay.");
1303 DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture."); 1313 DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture.");
1304 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale " 1314 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point scale "
1305 "factors to be used for tileGrid playback testing. Default value: 1.0"); 1315 "factors to be used for tileGrid playback testing. Default value: 1.0");
1306 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t o this file.");
1307 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i nfo about " 1316 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i nfo about "
1308 "each test)."); 1317 "each test).");
1318 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images, use checksum-"
1319 "based filenames, as rebaseline.py will use when downloading them fr om Google Storage");
1320 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t o this file.");
1309 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); 1321 DEFINE_string2(writePath, w, "", "Write rendered images into this directory.");
1310 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.") ; 1322 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.") ;
1311 DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, " 1323 DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, "
1312 "which can be in range 0-100). N = -1 will disable JPEG compression . " 1324 "which can be in range 0-100). N = -1 will disable JPEG compression . "
1313 "Default is N = 100, maximum quality."); 1325 "Default is N = 100, maximum quality.");
1314 1326
1315 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect) { 1327 static bool encode_to_dct_stream(SkWStream* stream, const SkBitmap& bitmap, cons t SkIRect& rect) {
1316 // Filter output of warnings that JPEG is not available for the image. 1328 // Filter output of warnings that JPEG is not available for the image.
1317 if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return false; 1329 if (bitmap.width() >= 65500 || bitmap.height() >= 65500) return false;
1318 if (FLAGS_pdfJpegQuality == -1) return false; 1330 if (FLAGS_pdfJpegQuality == -1) return false;
(...skipping 767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2086 if (FLAGS_forceBWtext) { 2098 if (FLAGS_forceBWtext) {
2087 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2099 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2088 } 2100 }
2089 } 2101 }
2090 2102
2091 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2103 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2092 int main(int argc, char * const argv[]) { 2104 int main(int argc, char * const argv[]) {
2093 return tool_main(argc, (char**) argv); 2105 return tool_main(argc, (char**) argv);
2094 } 2106 }
2095 #endif 2107 #endif
OLDNEW
« no previous file with comments | « no previous file | gm/tests/outputs/checksum-based-filenames/output-expected/command_line » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698