Chromium Code Reviews| 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 294 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 305 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); | 305 SkImageDecoder* codec = SkImageDecoder::Factory(&stream); |
| 306 if (NULL == codec) { | 306 if (NULL == codec) { |
| 307 gMissingCodecs.push_back().set(srcPath); | 307 gMissingCodecs.push_back().set(srcPath); |
| 308 return; | 308 return; |
| 309 } | 309 } |
| 310 | 310 |
| 311 SkAutoTDelete<SkImageDecoder> ad(codec); | 311 SkAutoTDelete<SkImageDecoder> ad(codec); |
| 312 | 312 |
| 313 stream.rewind(); | 313 stream.rewind(); |
| 314 | 314 |
| 315 | |
|
djsollen
2013/07/17 18:34:16
extra space?
scroggo
2013/07/17 19:14:31
D'oh! Removed.
| |
| 315 // Create a string representing just the filename itself, for use in json ex pectations. | 316 // Create a string representing just the filename itself, for use in json ex pectations. |
| 316 SkString basename = SkOSPath::SkBasename(srcPath); | 317 SkString basename = SkOSPath::SkBasename(srcPath); |
| 317 const char* filename = basename.c_str(); | 318 const char* filename = basename.c_str(); |
| 318 | 319 |
| 319 if (!codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config, | 320 if (!codec->decode(&stream, &bitmap, SkBitmap::kARGB_8888_Config, |
| 320 SkImageDecoder::kDecodePixels_Mode)) { | 321 SkImageDecoder::kDecodePixels_Mode)) { |
| 321 if (expect_to_fail(filename)) { | 322 if (expect_to_fail(filename)) { |
| 322 gSuccessfulDecodes.push_back().appendf( | 323 gSuccessfulDecodes.push_back().appendf( |
| 323 "failed to decode %s, which is a known failure.", srcPath); | 324 "failed to decode %s, which is a known failure.", srcPath); |
| 324 } else { | 325 } else { |
| 325 gDecodeFailures.push_back().set(srcPath); | 326 gDecodeFailures.push_back().set(srcPath); |
| 326 } | 327 } |
| 327 return; | 328 return; |
| 328 } | 329 } |
| 329 | 330 |
| 331 // Test decoding just the bounds. The bounds should always match. | |
| 332 { | |
| 333 stream.rewind(); | |
| 334 SkBitmap dim; | |
| 335 if (!codec->decode(&stream, &dim, SkImageDecoder::kDecodeBounds_Mode)) { | |
| 336 SkString failure = SkStringPrintf("failed to decode bounds for %s", srcPath); | |
| 337 gDecodeFailures.push_back() = failure; | |
| 338 } else { | |
| 339 // Now check that the bounds match: | |
| 340 if (dim.width() != bitmap.width() || dim.height() != bitmap.height() ) { | |
| 341 SkString failure = SkStringPrintf("bounds do not match for %s", srcPath); | |
| 342 gDecodeFailures.push_back() = failure; | |
| 343 } | |
| 344 } | |
| 345 } | |
| 346 | |
| 330 if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures) ) { | 347 if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures) ) { |
| 331 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.widt h(), | 348 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.widt h(), |
| 332 bitmap.height()); | 349 bitmap.height()); |
| 333 } else if (!FLAGS_mismatchPath.isEmpty()) { | 350 } else if (!FLAGS_mismatchPath.isEmpty()) { |
| 334 SkString outPath; | 351 SkString outPath; |
| 335 make_outname(&outPath, FLAGS_mismatchPath[0], srcPath, ".png"); | 352 make_outname(&outPath, FLAGS_mismatchPath[0], srcPath, ".png"); |
| 336 if (write_bitmap(outPath.c_str(), bitmap)) { | 353 if (write_bitmap(outPath.c_str(), bitmap)) { |
| 337 gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str() ); | 354 gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str() ); |
| 338 } else { | 355 } else { |
| 339 gEncodeFailures.push_back().set(outPath); | 356 gEncodeFailures.push_back().set(outPath); |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 580 } | 597 } |
| 581 | 598 |
| 582 return failed ? -1 : 0; | 599 return failed ? -1 : 0; |
| 583 } | 600 } |
| 584 | 601 |
| 585 #if !defined SK_BUILD_FOR_IOS | 602 #if !defined SK_BUILD_FOR_IOS |
| 586 int main(int argc, char * const argv[]) { | 603 int main(int argc, char * const argv[]) { |
| 587 return tool_main(argc, (char**) argv); | 604 return tool_main(argc, (char**) argv); |
| 588 } | 605 } |
| 589 #endif | 606 #endif |
| OLD | NEW |