| 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 10 matching lines...) Expand all Loading... |
| 21 #include "SkTemplates.h" | 21 #include "SkTemplates.h" |
| 22 | 22 |
| 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_int32(sampleSize, 1, "Set the sampleSize for decoding."); |
| 32 DEFINE_bool(skip, false, "Skip writing zeroes."); |
| 31 DEFINE_bool(testSubsetDecoding, true, "Test decoding subsets of images."); | 33 DEFINE_bool(testSubsetDecoding, true, "Test decoding subsets of images."); |
| 32 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); | 34 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
| 33 DEFINE_bool(skip, false, "Skip writing zeroes."); | |
| 34 | 35 |
| 35 struct Format { | 36 struct Format { |
| 36 SkImageEncoder::Type fType; | 37 SkImageEncoder::Type fType; |
| 37 SkImageDecoder::Format fFormat; | 38 SkImageDecoder::Format fFormat; |
| 38 const char* fSuffix; | 39 const char* fSuffix; |
| 39 }; | 40 }; |
| 40 | 41 |
| 41 static const Format gFormats[] = { | 42 static const Format gFormats[] = { |
| 42 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, | 43 { SkImageEncoder::kBMP_Type, SkImageDecoder::kBMP_Format, ".bmp" }, |
| 43 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, | 44 { SkImageEncoder::kGIF_Type, SkImageDecoder::kGIF_Format, ".gif" }, |
| (...skipping 349 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 393 | 394 |
| 394 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); | 395 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); |
| 395 if (NULL == codec) { | 396 if (NULL == codec) { |
| 396 gMissingCodecs.push_back().set(srcPath); | 397 gMissingCodecs.push_back().set(srcPath); |
| 397 return; | 398 return; |
| 398 } | 399 } |
| 399 | 400 |
| 400 SkAutoTDelete<SkImageDecoder> ad(codec); | 401 SkAutoTDelete<SkImageDecoder> ad(codec); |
| 401 | 402 |
| 402 codec->setSkipWritingZeroes(FLAGS_skip); | 403 codec->setSkipWritingZeroes(FLAGS_skip); |
| 404 codec->setSampleSize(FLAGS_sampleSize); |
| 403 stream.rewind(); | 405 stream.rewind(); |
| 404 | 406 |
| 405 // Create a string representing just the filename itself, for use in json ex
pectations. | 407 // Create a string representing just the filename itself, for use in json ex
pectations. |
| 406 SkString basename = SkOSPath::SkBasename(srcPath); | 408 SkString basename = SkOSPath::SkBasename(srcPath); |
| 407 const char* filename = basename.c_str(); | 409 const char* filename = basename.c_str(); |
| 408 | 410 |
| 409 if (!codec->decode(&stream, &bitmap, gPrefConfig, | 411 if (!codec->decode(&stream, &bitmap, gPrefConfig, |
| 410 SkImageDecoder::kDecodePixels_Mode)) { | 412 SkImageDecoder::kDecodePixels_Mode)) { |
| 411 if (expect_to_fail(filename)) { | 413 if (expect_to_fail(filename)) { |
| 412 gSuccessfulDecodes.push_back().appendf( | 414 gSuccessfulDecodes.push_back().appendf( |
| (...skipping 302 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 715 } | 717 } |
| 716 | 718 |
| 717 return failed ? -1 : 0; | 719 return failed ? -1 : 0; |
| 718 } | 720 } |
| 719 | 721 |
| 720 #if !defined SK_BUILD_FOR_IOS | 722 #if !defined SK_BUILD_FOR_IOS |
| 721 int main(int argc, char * const argv[]) { | 723 int main(int argc, char * const argv[]) { |
| 722 return tool_main(argc, (char**) argv); | 724 return tool_main(argc, (char**) argv); |
| 723 } | 725 } |
| 724 #endif | 726 #endif |
| OLD | NEW |