| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 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 "CrashHandler.h" | 8 #include "CrashHandler.h" |
| 9 #include "DMJsonWriter.h" | 9 #include "DMJsonWriter.h" |
| 10 #include "DMSrcSink.h" | 10 #include "DMSrcSink.h" |
| (...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 508 } | 508 } |
| 509 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); | 509 SkAutoTDelete<SkStreamAsset> data(stream.detachAsStream()); |
| 510 | 510 |
| 511 SkString md5; | 511 SkString md5; |
| 512 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { | 512 if (!FLAGS_writePath.isEmpty() || !FLAGS_readPath.isEmpty()) { |
| 513 SkMD5 hash; | 513 SkMD5 hash; |
| 514 if (data->getLength()) { | 514 if (data->getLength()) { |
| 515 hash.writeStream(data, data->getLength()); | 515 hash.writeStream(data, data->getLength()); |
| 516 data->rewind(); | 516 data->rewind(); |
| 517 } else { | 517 } else { |
| 518 hash.write(bitmap.getPixels(), bitmap.getSize()); | 518 // If we're BGRA (Linux, Windows), swizzle over to RGBA (Mac
, Android). |
| 519 // This helps eliminate multiple 0-pixel-diff hashes on gold
.skia.org. |
| 520 // (Android's general slow speed breaks the tie arbitrarily
in RGBA's favor.) |
| 521 // We might consider promoting 565 to RGBA too. |
| 522 if (bitmap.colorType() == kBGRA_8888_SkColorType) { |
| 523 SkBitmap swizzle; |
| 524 SkAssertResult(bitmap.copyTo(&swizzle, kRGBA_8888_SkColo
rType)); |
| 525 hash.write(swizzle.getPixels(), swizzle.getSize()); |
| 526 } else { |
| 527 hash.write(bitmap.getPixels(), bitmap.getSize()); |
| 528 } |
| 519 } | 529 } |
| 520 SkMD5::Digest digest; | 530 SkMD5::Digest digest; |
| 521 hash.finish(digest); | 531 hash.finish(digest); |
| 522 for (int i = 0; i < 16; i++) { | 532 for (int i = 0; i < 16; i++) { |
| 523 md5.appendf("%02x", digest.data[i]); | 533 md5.appendf("%02x", digest.data[i]); |
| 524 } | 534 } |
| 525 } | 535 } |
| 526 | 536 |
| 527 if (!FLAGS_readPath.isEmpty() && | 537 if (!FLAGS_readPath.isEmpty() && |
| 528 !gGold.contains(Gold(task->sink.tag, task->src.tag, | 538 !gGold.contains(Gold(task->sink.tag, task->src.tag, |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 811 } | 821 } |
| 812 return 0; | 822 return 0; |
| 813 } | 823 } |
| 814 | 824 |
| 815 #if !defined(SK_BUILD_FOR_IOS) | 825 #if !defined(SK_BUILD_FOR_IOS) |
| 816 int main(int argc, char** argv) { | 826 int main(int argc, char** argv) { |
| 817 SkCommandLineFlags::Parse(argc, argv); | 827 SkCommandLineFlags::Parse(argc, argv); |
| 818 return dm_main(); | 828 return dm_main(); |
| 819 } | 829 } |
| 820 #endif | 830 #endif |
| OLD | NEW |