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 #include "skdiff.h" | 7 #include "skdiff.h" |
8 #include "skdiff_html.h" | 8 #include "skdiff_html.h" |
9 #include "skdiff_utils.h" | 9 #include "skdiff_utils.h" |
10 #include "SkBitmap.h" | 10 #include "SkBitmap.h" |
11 #include "SkData.h" | 11 #include "SkData.h" |
12 #include "SkForceLinking.h" | 12 #include "SkForceLinking.h" |
scroggo
2016/03/11 19:56:13
I assume this is no longer necessary
msarett
2016/03/11 19:58:08
I recently realized that force linking is also use
scroggo
2016/03/11 20:00:34
Really? I added force linking because we auto-regi
msarett
2016/03/11 20:05:47
Maybe I'm wrong... I'm certainly not an expert in
| |
13 #include "SkImageDecoder.h" | |
14 #include "SkImageEncoder.h" | 13 #include "SkImageEncoder.h" |
15 #include "SkOSFile.h" | 14 #include "SkOSFile.h" |
16 #include "SkStream.h" | 15 #include "SkStream.h" |
17 #include "../private/SkTDArray.h" | 16 #include "../private/SkTDArray.h" |
18 #include "../private/SkTSearch.h" | 17 #include "../private/SkTSearch.h" |
19 | 18 |
20 #include <stdlib.h> | 19 #include <stdlib.h> |
21 | 20 |
22 __SK_FORCE_IMAGE_DECODER_LINKING; | 21 __SK_FORCE_IMAGE_DECODER_LINKING; |
23 | 22 |
(...skipping 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
342 DiffRecord* fDrp; | 341 DiffRecord* fDrp; |
343 }; | 342 }; |
344 | 343 |
345 static void get_bounds(DiffResource& resource, const char* name) { | 344 static void get_bounds(DiffResource& resource, const char* name) { |
346 if (resource.fBitmap.empty() && !DiffResource::isStatusFailed(resource.fStat us)) { | 345 if (resource.fBitmap.empty() && !DiffResource::isStatusFailed(resource.fStat us)) { |
347 SkAutoDataUnref fileBits(read_file(resource.fFullPath.c_str())); | 346 SkAutoDataUnref fileBits(read_file(resource.fFullPath.c_str())); |
348 if (nullptr == fileBits) { | 347 if (nullptr == fileBits) { |
349 SkDebugf("WARNING: couldn't read %s file <%s>\n", name, resource.fFu llPath.c_str()); | 348 SkDebugf("WARNING: couldn't read %s file <%s>\n", name, resource.fFu llPath.c_str()); |
350 resource.fStatus = DiffResource::kCouldNotRead_Status; | 349 resource.fStatus = DiffResource::kCouldNotRead_Status; |
351 } else { | 350 } else { |
352 get_bitmap(fileBits, resource, SkImageDecoder::kDecodeBounds_Mode); | 351 get_bitmap(fileBits, resource, true); |
353 } | 352 } |
354 } | 353 } |
355 } | 354 } |
356 | 355 |
357 static void get_bounds(DiffRecord& drp) { | 356 static void get_bounds(DiffRecord& drp) { |
358 get_bounds(drp.fBase, "base"); | 357 get_bounds(drp.fBase, "base"); |
359 get_bounds(drp.fComparison, "comparison"); | 358 get_bounds(drp.fComparison, "comparison"); |
360 } | 359 } |
361 | 360 |
362 #ifdef SK_OS_WIN | 361 #ifdef SK_OS_WIN |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
486 drp->fComparison.fStatus = DiffResource::kCouldNotRead_Statu s; | 485 drp->fComparison.fStatus = DiffResource::kCouldNotRead_Statu s; |
487 VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[ j]); | 486 VERBOSE_STATUS("READ FAIL", ANSI_COLOR_RED, comparisonFiles[ j]); |
488 } | 487 } |
489 drp->fResult = DiffRecord::kCouldNotCompare_Result; | 488 drp->fResult = DiffRecord::kCouldNotCompare_Result; |
490 | 489 |
491 } else if (are_buffers_equal(baseFileBits, comparisonFileBits)) { | 490 } else if (are_buffers_equal(baseFileBits, comparisonFileBits)) { |
492 drp->fResult = DiffRecord::kEqualBits_Result; | 491 drp->fResult = DiffRecord::kEqualBits_Result; |
493 VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]); | 492 VERBOSE_STATUS("MATCH", ANSI_COLOR_GREEN, baseFiles[i]); |
494 } else { | 493 } else { |
495 AutoReleasePixels arp(drp); | 494 AutoReleasePixels arp(drp); |
496 get_bitmap(baseFileBits, drp->fBase, SkImageDecoder::kDecodePixe ls_Mode); | 495 get_bitmap(baseFileBits, drp->fBase, false); |
497 get_bitmap(comparisonFileBits, drp->fComparison, | 496 get_bitmap(comparisonFileBits, drp->fComparison, false); |
498 SkImageDecoder::kDecodePixels_Mode); | |
499 VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]); | 497 VERBOSE_STATUS("DIFFERENT", ANSI_COLOR_RED, baseFiles[i]); |
500 if (DiffResource::kDecoded_Status == drp->fBase.fStatus && | 498 if (DiffResource::kDecoded_Status == drp->fBase.fStatus && |
501 DiffResource::kDecoded_Status == drp->fComparison.fStatus) { | 499 DiffResource::kDecoded_Status == drp->fComparison.fStatus) { |
502 create_and_write_diff_image(drp, dmp, colorThreshold, | 500 create_and_write_diff_image(drp, dmp, colorThreshold, |
503 outputDir, drp->fBase.fFilename) ; | 501 outputDir, drp->fBase.fFilename) ; |
504 } else { | 502 } else { |
505 drp->fResult = DiffRecord::kCouldNotCompare_Result; | 503 drp->fResult = DiffRecord::kCouldNotCompare_Result; |
506 } | 504 } |
507 } | 505 } |
508 | 506 |
(...skipping 342 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
851 // range [0...255] are wrapped (mod 256). Do the conversion ourselves, to | 849 // range [0...255] are wrapped (mod 256). Do the conversion ourselves, to |
852 // make sure that we only return 0 when there were no failures. | 850 // make sure that we only return 0 when there were no failures. |
853 return (num_failing_results > 255) ? 255 : num_failing_results; | 851 return (num_failing_results > 255) ? 255 : num_failing_results; |
854 } | 852 } |
855 | 853 |
856 #if !defined SK_BUILD_FOR_IOS | 854 #if !defined SK_BUILD_FOR_IOS |
857 int main(int argc, char * const argv[]) { | 855 int main(int argc, char * const argv[]) { |
858 return tool_main(argc, (char**) argv); | 856 return tool_main(argc, (char**) argv); |
859 } | 857 } |
860 #endif | 858 #endif |
OLD | NEW |