OLD | NEW |
1 /* | 1 /* |
2 * Copyright 2012 Google Inc. | 2 * Copyright 2012 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 "LazyDecodeBitmap.h" | 8 #include "LazyDecodeBitmap.h" |
9 #include "CopyTilesRenderer.h" | 9 #include "CopyTilesRenderer.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
(...skipping 30 matching lines...) Expand all Loading... |
41 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " | 41 DEFINE_bool(writeWholeImage, false, "In tile mode, write the entire rendered ima
ge to a " |
42 "file, instead of an image for each tile."); | 42 "file, instead of an image for each tile."); |
43 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p
ixels as " | 43 DEFINE_bool(validate, false, "Verify that the rendered image contains the same p
ixels as " |
44 "the picture rendered in simple mode. When used in conjunction with
--bbh, results " | 44 "the picture rendered in simple mode. When used in conjunction with
--bbh, results " |
45 "are validated against the picture rendered in the same mode, but wi
thout the bbh."); | 45 "are validated against the picture rendered in the same mode, but wi
thout the bbh."); |
46 | 46 |
47 DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recordi
ng the picture."); | 47 DEFINE_bool(bench_record, false, "If true, drop into an infinite loop of recordi
ng the picture."); |
48 | 48 |
49 DEFINE_bool(preprocess, false, "If true, perform device specific preprocessing b
efore rendering."); | 49 DEFINE_bool(preprocess, false, "If true, perform device specific preprocessing b
efore rendering."); |
50 | 50 |
51 static void make_output_filepath(SkString* path, const SkString& dir, | |
52 const SkString& name) { | |
53 sk_tools::make_filepath(path, dir, name); | |
54 // Remove ".skp" | |
55 path->remove(path->size() - 4, 4); | |
56 } | |
57 | |
58 ////////////////////////////////////////////////////////////////////////////////
//////////////////// | 51 ////////////////////////////////////////////////////////////////////////////////
//////////////////// |
59 | 52 |
60 /** | 53 /** |
61 * Table for translating from format of data to a suffix. | 54 * Table for translating from format of data to a suffix. |
62 */ | 55 */ |
63 struct Format { | 56 struct Format { |
64 SkImageDecoder::Format fFormat; | 57 SkImageDecoder::Format fFormat; |
65 const char* fSuffix; | 58 const char* fSuffix; |
66 }; | 59 }; |
67 static const Format gFormats[] = { | 60 static const Format gFormats[] = { |
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 for (int i = 1; i <= 255; ++i) { | 334 for (int i = 1; i <= 255; ++i) { |
342 if(diffs[i] > 0) { | 335 if(diffs[i] > 0) { |
343 SkDebugf("Number of pixels with max diff of %i is %i\n", i, diff
s[i]); | 336 SkDebugf("Number of pixels with max diff of %i is %i\n", i, diff
s[i]); |
344 } | 337 } |
345 } | 338 } |
346 } | 339 } |
347 | 340 |
348 if (FLAGS_writeWholeImage) { | 341 if (FLAGS_writeWholeImage) { |
349 sk_tools::force_all_opaque(*bitmap); | 342 sk_tools::force_all_opaque(*bitmap); |
350 | 343 |
| 344 // TODO(epoger): It would be better for the filename (without outputDir)
to be passed in |
| 345 // here, and used both for the checksum file and writing into outputDir. |
| 346 SkString inputFilename, outputPath; |
| 347 sk_tools::get_basename(&inputFilename, inputPath); |
| 348 sk_tools::make_filepath(&outputPath, *outputDir, inputFilename); |
| 349 sk_tools::replace_char(&outputPath, '.', '_'); |
| 350 outputPath.append(".png"); |
| 351 |
351 if (NULL != jsonSummaryPtr) { | 352 if (NULL != jsonSummaryPtr) { |
352 // TODO(epoger): This is a hacky way of constructing the filename as
sociated with the | 353 SkString outputFileBasename; |
353 // image checksum; we basically are repeating the logic of make_outp
ut_filepath() | 354 sk_tools::get_basename(&outputFileBasename, outputPath); |
354 // and code below here, within here. | 355 jsonSummaryPtr->add(inputFilename.c_str(), outputFileBasename.c_str(
), *bitmap); |
355 // It would be better for the filename (without outputDir) to be pas
sed in here, | |
356 // and used both for the checksum file and writing into outputDir. | |
357 // | |
358 // TODO(epoger): what about including the config type within hashFil
ename? That way, | |
359 // we could combine results of different config types without confli
cting filenames. | |
360 SkString hashFilename; | |
361 sk_tools::get_basename(&hashFilename, inputPath); | |
362 hashFilename.remove(hashFilename.size() - 4, 4); // Remove ".skp" | |
363 hashFilename.append(".png"); | |
364 jsonSummaryPtr->add(hashFilename.c_str(), *bitmap); | |
365 } | 356 } |
366 | 357 |
367 if (NULL != outputDir) { | 358 if (NULL != outputDir) { |
368 SkString inputFilename; | |
369 sk_tools::get_basename(&inputFilename, inputPath); | |
370 SkString outputPath; | |
371 make_output_filepath(&outputPath, *outputDir, inputFilename); | |
372 outputPath.append(".png"); | |
373 if (!SkImageEncoder::EncodeFile(outputPath.c_str(), *bitmap, | 359 if (!SkImageEncoder::EncodeFile(outputPath.c_str(), *bitmap, |
374 SkImageEncoder::kPNG_Type, 100)) { | 360 SkImageEncoder::kPNG_Type, 100)) { |
375 SkDebugf("Failed to draw the picture.\n"); | 361 SkDebugf("Failed to draw the picture.\n"); |
376 success = false; | 362 success = false; |
377 } | 363 } |
378 } | 364 } |
379 } | 365 } |
380 SkDELETE(bitmap); | 366 SkDELETE(bitmap); |
381 | 367 |
382 return success; | 368 return success; |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); | 480 jsonSummary.writeToFile(FLAGS_writeJsonSummaryPath[0]); |
495 } | 481 } |
496 return 0; | 482 return 0; |
497 } | 483 } |
498 | 484 |
499 #if !defined SK_BUILD_FOR_IOS | 485 #if !defined SK_BUILD_FOR_IOS |
500 int main(int argc, char * const argv[]) { | 486 int main(int argc, char * const argv[]) { |
501 return tool_main(argc, (char**) argv); | 487 return tool_main(argc, (char**) argv); |
502 } | 488 } |
503 #endif | 489 #endif |
OLD | NEW |