OLD | NEW |
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 #include "gm_expectations.h" | 8 #include "gm_expectations.h" |
9 #include "SkBitmap.h" | 9 #include "SkBitmap.h" |
10 #include "SkColorPriv.h" | 10 #include "SkColorPriv.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 DEFINE_string(mismatchPath, "", "Folder to write mismatched images to."); | 27 DEFINE_string(mismatchPath, "", "Folder to write mismatched images to."); |
28 DEFINE_string2(readPath, r, "", "Folder(s) and files to decode images. Required.
"); | 28 DEFINE_string2(readPath, r, "", "Folder(s) and files to decode images. Required.
"); |
29 DEFINE_string(readExpectationsPath, "", "Path to read JSON expectations from."); | 29 DEFINE_string(readExpectationsPath, "", "Path to read JSON expectations from."); |
30 DEFINE_bool(reencode, true, "Reencode the images to test encoding."); | 30 DEFINE_bool(reencode, true, "Reencode the images to test encoding."); |
31 DEFINE_int32(sampleSize, 1, "Set the sampleSize for decoding."); | 31 DEFINE_int32(sampleSize, 1, "Set the sampleSize for decoding."); |
32 DEFINE_bool(skip, false, "Skip writing zeroes."); | 32 DEFINE_bool(skip, false, "Skip writing zeroes."); |
33 DEFINE_bool(testSubsetDecoding, true, "Test decoding subsets of images."); | 33 DEFINE_bool(testSubsetDecoding, true, "Test decoding subsets of images."); |
34 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images
, use checksum-" | 34 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images
, use checksum-" |
35 "based filenames, as rebaseline.py will use when downloading them fr
om Google Storage"); | 35 "based filenames, as rebaseline.py will use when downloading them fr
om Google Storage"); |
36 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); | 36 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
| 37 DEFINE_bool(unpremul, false, "Require unpremultiplied colors."); |
37 | 38 |
38 struct Format { | 39 struct Format { |
39 SkImageEncoder::Type fType; | 40 SkImageEncoder::Type fType; |
40 SkImageDecoder::Format fFormat; | 41 SkImageDecoder::Format fFormat; |
41 const char* fSuffix; | 42 const char* fSuffix; |
42 }; | 43 }; |
43 | 44 |
44 static const Format gFormats[] = { | 45 static const Format gFormats[] = { |
45 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, | 46 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, |
46 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, | 47 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, |
(...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); | 493 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); |
493 if (NULL == codec) { | 494 if (NULL == codec) { |
494 gMissingCodecs.push_back().set(srcPath); | 495 gMissingCodecs.push_back().set(srcPath); |
495 return; | 496 return; |
496 } | 497 } |
497 | 498 |
498 SkAutoTDelete<SkImageDecoder> ad(codec); | 499 SkAutoTDelete<SkImageDecoder> ad(codec); |
499 | 500 |
500 codec->setSkipWritingZeroes(FLAGS_skip); | 501 codec->setSkipWritingZeroes(FLAGS_skip); |
501 codec->setSampleSize(FLAGS_sampleSize); | 502 codec->setSampleSize(FLAGS_sampleSize); |
| 503 codec->setRequireUnpremultipliedColors(FLAGS_unpremul); |
502 stream.rewind(); | 504 stream.rewind(); |
503 | 505 |
504 // Create a string representing just the filename itself, for use in json ex
pectations. | 506 // Create a string representing just the filename itself, for use in json ex
pectations. |
505 SkString basename = SkOSPath::Basename(srcPath); | 507 SkString basename = SkOSPath::Basename(srcPath); |
506 // Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENA
ME_PATTERN | 508 // Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENA
ME_PATTERN |
507 replace_char(&basename, '_', '-'); | 509 replace_char(&basename, '_', '-'); |
508 // Replace '.' with '-', so the output filename can still retain the origina
l file extension, | 510 // Replace '.' with '-', so the output filename can still retain the origina
l file extension, |
509 // but still end up with only one '.', which denotes the actual extension of
the final file. | 511 // but still end up with only one '.', which denotes the actual extension of
the final file. |
510 replace_char(&basename, '.', '-'); | 512 replace_char(&basename, '.', '-'); |
511 const char* filename = basename.c_str(); | 513 const char* filename = basename.c_str(); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 print_strings("Known failures", gKnownFailures); | 836 print_strings("Known failures", gKnownFailures); |
835 | 837 |
836 return failed ? -1 : 0; | 838 return failed ? -1 : 0; |
837 } | 839 } |
838 | 840 |
839 #if !defined SK_BUILD_FOR_IOS | 841 #if !defined SK_BUILD_FOR_IOS |
840 int main(int argc, char * const argv[]) { | 842 int main(int argc, char * const argv[]) { |
841 return tool_main(argc, (char**) argv); | 843 return tool_main(argc, (char**) argv); |
842 } | 844 } |
843 #endif | 845 #endif |
OLD | NEW |