| 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 12 matching lines...) Expand all Loading... |
| 23 __SK_FORCE_IMAGE_DECODER_LINKING; | 23 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 24 | 24 |
| 25 DEFINE_string(config, "None", "Preferred config to decode into. [None|8888|565|A
8]"); | 25 DEFINE_string(config, "None", "Preferred config to decode into. [None|8888|565|A
8]"); |
| 26 DEFINE_string(createExpectationsPath, "", "Path to write JSON expectations."); | 26 DEFINE_string(createExpectationsPath, "", "Path to write JSON expectations."); |
| 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_bool(testSubsetDecoding, true, "Test decoding subsets of images."); | 31 DEFINE_bool(testSubsetDecoding, true, "Test decoding subsets of images."); |
| 32 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); | 32 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
| 33 DEFINE_bool(skip, false, "Skip writing zeroes."); |
| 33 | 34 |
| 34 struct Format { | 35 struct Format { |
| 35 SkImageEncoder::Type fType; | 36 SkImageEncoder::Type fType; |
| 36 SkImageDecoder::Format fFormat; | 37 SkImageDecoder::Format fFormat; |
| 37 const char* fSuffix; | 38 const char* fSuffix; |
| 38 }; | 39 }; |
| 39 | 40 |
| 40 static const Format gFormats[] = { | 41 static const Format gFormats[] = { |
| 41 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, | 42 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, |
| 42 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, | 43 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, |
| (...skipping 333 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 } | 377 } |
| 377 | 378 |
| 378 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); | 379 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); |
| 379 if (NULL == codec) { | 380 if (NULL == codec) { |
| 380 gMissingCodecs.push_back().set(srcPath); | 381 gMissingCodecs.push_back().set(srcPath); |
| 381 return; | 382 return; |
| 382 } | 383 } |
| 383 | 384 |
| 384 SkAutoTDelete<SkImageDecoder> ad(codec); | 385 SkAutoTDelete<SkImageDecoder> ad(codec); |
| 385 | 386 |
| 387 codec->setSkipWritingZeroes(FLAGS_skip); |
| 386 stream.rewind(); | 388 stream.rewind(); |
| 387 | 389 |
| 388 // Create a string representing just the filename itself, for use in json ex
pectations. | 390 // Create a string representing just the filename itself, for use in json ex
pectations. |
| 389 SkString basename = SkOSPath::SkBasename(srcPath); | 391 SkString basename = SkOSPath::SkBasename(srcPath); |
| 390 const char* filename = basename.c_str(); | 392 const char* filename = basename.c_str(); |
| 391 | 393 |
| 392 if (!codec->decode(&stream, &bitmap, gPrefConfig, | 394 if (!codec->decode(&stream, &bitmap, gPrefConfig, |
| 393 SkImageDecoder::kDecodePixels_Mode)) { | 395 SkImageDecoder::kDecodePixels_Mode)) { |
| 394 if (expect_to_fail(filename)) { | 396 if (expect_to_fail(filename)) { |
| 395 gSuccessfulDecodes.push_back().appendf( | 397 gSuccessfulDecodes.push_back().appendf( |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 697 } | 699 } |
| 698 | 700 |
| 699 return failed ? -1 : 0; | 701 return failed ? -1 : 0; |
| 700 } | 702 } |
| 701 | 703 |
| 702 #if !defined SK_BUILD_FOR_IOS | 704 #if !defined SK_BUILD_FOR_IOS |
| 703 int main(int argc, char * const argv[]) { | 705 int main(int argc, char * const argv[]) { |
| 704 return tool_main(argc, (char**) argv); | 706 return tool_main(argc, (char**) argv); |
| 705 } | 707 } |
| 706 #endif | 708 #endif |
| OLD | NEW |