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 309 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
320 SkImageDecoder::kDecodePixels_Mode)) { | 320 SkImageDecoder::kDecodePixels_Mode)) { |
321 if (expect_to_fail(filename)) { | 321 if (expect_to_fail(filename)) { |
322 gSuccessfulDecodes.push_back().appendf( | 322 gSuccessfulDecodes.push_back().appendf( |
323 "failed to decode %s, which is a known failure.", srcPath); | 323 "failed to decode %s, which is a known failure.", srcPath); |
324 } else { | 324 } else { |
325 gDecodeFailures.push_back().set(srcPath); | 325 gDecodeFailures.push_back().set(srcPath); |
326 } | 326 } |
327 return; | 327 return; |
328 } | 328 } |
329 | 329 |
| 330 // Test decoding just the bounds. The bounds should always match. |
| 331 { |
| 332 stream.rewind(); |
| 333 SkBitmap dim; |
| 334 if (!codec->decode(&stream, &dim, SkImageDecoder::kDecodeBounds_Mode)) { |
| 335 SkString failure = SkStringPrintf("failed to decode bounds for %s",
srcPath); |
| 336 gDecodeFailures.push_back() = failure; |
| 337 } else { |
| 338 // Now check that the bounds match: |
| 339 if (dim.width() != bitmap.width() || dim.height() != bitmap.height()
) { |
| 340 SkString failure = SkStringPrintf("bounds do not match for %s",
srcPath); |
| 341 gDecodeFailures.push_back() = failure; |
| 342 } |
| 343 } |
| 344 } |
| 345 |
330 if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures)
) { | 346 if (compare_to_expectations_if_necessary(bitmap, filename, &gDecodeFailures)
) { |
331 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.widt
h(), | 347 gSuccessfulDecodes.push_back().printf("%s [%d %d]", srcPath, bitmap.widt
h(), |
332 bitmap.height()); | 348 bitmap.height()); |
333 } else if (!FLAGS_mismatchPath.isEmpty()) { | 349 } else if (!FLAGS_mismatchPath.isEmpty()) { |
334 SkString outPath; | 350 SkString outPath; |
335 make_outname(&outPath, FLAGS_mismatchPath[0], srcPath, ".png"); | 351 make_outname(&outPath, FLAGS_mismatchPath[0], srcPath, ".png"); |
336 if (write_bitmap(outPath.c_str(), bitmap)) { | 352 if (write_bitmap(outPath.c_str(), bitmap)) { |
337 gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str()
); | 353 gSuccessfulDecodes.push_back().appendf("\twrote %s", outPath.c_str()
); |
338 } else { | 354 } else { |
339 gEncodeFailures.push_back().set(outPath); | 355 gEncodeFailures.push_back().set(outPath); |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 } | 596 } |
581 | 597 |
582 return failed ? -1 : 0; | 598 return failed ? -1 : 0; |
583 } | 599 } |
584 | 600 |
585 #if !defined SK_BUILD_FOR_IOS | 601 #if !defined SK_BUILD_FOR_IOS |
586 int main(int argc, char * const argv[]) { | 602 int main(int argc, char * const argv[]) { |
587 return tool_main(argc, (char**) argv); | 603 return tool_main(argc, (char**) argv); |
588 } | 604 } |
589 #endif | 605 #endif |
OLD | NEW |