| 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 493 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 504 // Create a string representing just the filename itself, for use in json ex
pectations. | 504 // Create a string representing just the filename itself, for use in json ex
pectations. |
| 505 SkString basename = SkOSPath::Basename(srcPath); | 505 SkString basename = SkOSPath::Basename(srcPath); |
| 506 // Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENA
ME_PATTERN | 506 // Replace '_' with '-', so that the names can fit gm_json.py's IMAGE_FILENA
ME_PATTERN |
| 507 replace_char(&basename, '_', '-'); | 507 replace_char(&basename, '_', '-'); |
| 508 // Replace '.' with '-', so the output filename can still retain the origina
l file extension, | 508 // 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. | 509 // but still end up with only one '.', which denotes the actual extension of
the final file. |
| 510 replace_char(&basename, '.', '-'); | 510 replace_char(&basename, '.', '-'); |
| 511 const char* filename = basename.c_str(); | 511 const char* filename = basename.c_str(); |
| 512 | 512 |
| 513 if (!codec->decode(&stream, &bitmap, gPrefColorType, SkImageDecoder::kDecode
Pixels_Mode)) { | 513 if (!codec->decode(&stream, &bitmap, gPrefColorType, SkImageDecoder::kDecode
Pixels_Mode)) { |
| 514 if (NULL != gJsonExpectations.get()) { | 514 if (gJsonExpectations.get()) { |
| 515 const SkString name_config = create_json_key(filename); | 515 const SkString name_config = create_json_key(filename); |
| 516 skiagm::Expectations jsExpectations = gJsonExpectations->get(name_co
nfig.c_str()); | 516 skiagm::Expectations jsExpectations = gJsonExpectations->get(name_co
nfig.c_str()); |
| 517 if (jsExpectations.ignoreFailure()) { | 517 if (jsExpectations.ignoreFailure()) { |
| 518 // This is a known failure. | 518 // This is a known failure. |
| 519 gKnownFailures.push_back().appendf( | 519 gKnownFailures.push_back().appendf( |
| 520 "failed to decode %s, which is a known failure.", srcPath); | 520 "failed to decode %s, which is a known failure.", srcPath); |
| 521 return; | 521 return; |
| 522 } | 522 } |
| 523 if (jsExpectations.empty()) { | 523 if (jsExpectations.empty()) { |
| 524 // This is a failure, but it is a new file. Mark it as missing,
with | 524 // This is a failure, but it is a new file. Mark it as missing,
with |
| (...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 630 if (FLAGS_reencode && bitmap.colorType() != kAlpha_8_SkColorType) { | 630 if (FLAGS_reencode && bitmap.colorType() != kAlpha_8_SkColorType) { |
| 631 // Encode to the format the file was originally in, or PNG if the encode
r for the same | 631 // Encode to the format the file was originally in, or PNG if the encode
r for the same |
| 632 // format is unavailable. | 632 // format is unavailable. |
| 633 SkImageDecoder::Format format = codec->getFormat(); | 633 SkImageDecoder::Format format = codec->getFormat(); |
| 634 if (SkImageDecoder::kUnknown_Format == format) { | 634 if (SkImageDecoder::kUnknown_Format == format) { |
| 635 if (stream.rewind()) { | 635 if (stream.rewind()) { |
| 636 format = SkImageDecoder::GetStreamFormat(&stream); | 636 format = SkImageDecoder::GetStreamFormat(&stream); |
| 637 } | 637 } |
| 638 if (SkImageDecoder::kUnknown_Format == format) { | 638 if (SkImageDecoder::kUnknown_Format == format) { |
| 639 const char* dot = strrchr(srcPath, '.'); | 639 const char* dot = strrchr(srcPath, '.'); |
| 640 if (NULL != dot) { | 640 if (dot) { |
| 641 format = guess_format_from_suffix(dot); | 641 format = guess_format_from_suffix(dot); |
| 642 } | 642 } |
| 643 if (SkImageDecoder::kUnknown_Format == format) { | 643 if (SkImageDecoder::kUnknown_Format == format) { |
| 644 SkDebugf("Could not determine type for '%s'\n", srcPath); | 644 SkDebugf("Could not determine type for '%s'\n", srcPath); |
| 645 format = SkImageDecoder::kPNG_Format; | 645 format = SkImageDecoder::kPNG_Format; |
| 646 } | 646 } |
| 647 | 647 |
| 648 } | 648 } |
| 649 } else { | 649 } else { |
| 650 SkASSERT(!stream.rewind() || SkImageDecoder::GetStreamFormat(&stream
) == format); | 650 SkASSERT(!stream.rewind() || SkImageDecoder::GetStreamFormat(&stream
) == format); |
| (...skipping 183 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 834 print_strings("Known failures", gKnownFailures); | 834 print_strings("Known failures", gKnownFailures); |
| 835 | 835 |
| 836 return failed ? -1 : 0; | 836 return failed ? -1 : 0; |
| 837 } | 837 } |
| 838 | 838 |
| 839 #if !defined SK_BUILD_FOR_IOS | 839 #if !defined SK_BUILD_FOR_IOS |
| 840 int main(int argc, char * const argv[]) { | 840 int main(int argc, char * const argv[]) { |
| 841 return tool_main(argc, (char**) argv); | 841 return tool_main(argc, (char**) argv); |
| 842 } | 842 } |
| 843 #endif | 843 #endif |
| OLD | NEW |