| 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 /* | 8 /* |
| 9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
| 10 * | 10 * |
| (...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 707 * results to the JSON summary. (This is so that we will always | 707 * results to the JSON summary. (This is so that we will always |
| 708 * report errors across rendering modes, such as pipe vs tiled. | 708 * report errors across rendering modes, such as pipe vs tiled. |
| 709 * See https://codereview.chromium.org/13650002/ ) | 709 * See https://codereview.chromium.org/13650002/ ) |
| 710 */ | 710 */ |
| 711 ErrorCombination compare_to_expectations(Expectations expectations, | 711 ErrorCombination compare_to_expectations(Expectations expectations, |
| 712 const SkBitmap& actualBitmap, | 712 const SkBitmap& actualBitmap, |
| 713 const SkString& baseNameString, | 713 const SkString& baseNameString, |
| 714 const char renderModeDescriptor[], | 714 const char renderModeDescriptor[], |
| 715 bool addToJsonSummary) { | 715 bool addToJsonSummary) { |
| 716 ErrorCombination errors; | 716 ErrorCombination errors; |
| 717 SkHashDigest actualBitmapHash; | 717 SkUInt64HashDigest actualBitmapHash; |
| 718 // TODO(epoger): Better handling for error returned by ComputeDigest()? | 718 // TODO(epoger): Better handling for error returned by ComputeDigest()? |
| 719 // For now, we just report a digest of 0 in error cases, like before. | 719 // For now, we just report a digest of 0 in error cases, like before. |
| 720 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { | 720 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { |
| 721 actualBitmapHash = 0; | 721 actualBitmapHash = 0; |
| 722 } | 722 } |
| 723 SkString completeNameString = baseNameString; | 723 SkString completeNameString = baseNameString; |
| 724 completeNameString.append(renderModeDescriptor); | 724 completeNameString.append(renderModeDescriptor); |
| 725 const char* completeName = completeNameString.c_str(); | 725 const char* completeName = completeNameString.c_str(); |
| 726 | 726 |
| 727 if (expectations.empty()) { | 727 if (expectations.empty()) { |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 761 } | 761 } |
| 762 | 762 |
| 763 return errors; | 763 return errors; |
| 764 } | 764 } |
| 765 | 765 |
| 766 /** | 766 /** |
| 767 * Add this result to the appropriate JSON collection of actual results, | 767 * Add this result to the appropriate JSON collection of actual results, |
| 768 * depending on status. | 768 * depending on status. |
| 769 */ | 769 */ |
| 770 void add_actual_results_to_json_summary(const char testName[], | 770 void add_actual_results_to_json_summary(const char testName[], |
| 771 const SkHashDigest& actualBitmapHash
, | 771 const SkUInt64HashDigest& actualBitm
apHash, |
| 772 ErrorCombination result, | 772 ErrorCombination result, |
| 773 bool ignoreFailure) { | 773 bool ignoreFailure) { |
| 774 Json::Value actualResults; | 774 Json::Value actualResults; |
| 775 actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] = | 775 actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] = |
| 776 asJsonValue(actualBitmapHash); | 776 asJsonValue(actualBitmapHash); |
| 777 if (result.isEmpty()) { | 777 if (result.isEmpty()) { |
| 778 this->fJsonActualResults_Succeeded[testName] = actualResults; | 778 this->fJsonActualResults_Succeeded[testName] = actualResults; |
| 779 } else { | 779 } else { |
| 780 if (ignoreFailure) { | 780 if (ignoreFailure) { |
| 781 // TODO: Once we have added the ability to compare | 781 // TODO: Once we have added the ability to compare |
| (...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 857 * hash digest of actualBitmap, which *has* been run through | 857 * hash digest of actualBitmap, which *has* been run through |
| 858 * force_all_opaque(). | 858 * force_all_opaque(). |
| 859 * See comments above complete_bitmap() for more detail. | 859 * See comments above complete_bitmap() for more detail. |
| 860 */ | 860 */ |
| 861 Expectations expectations = expectationsSource->get(name.c_str()); | 861 Expectations expectations = expectationsSource->get(name.c_str()); |
| 862 errors.add(compare_to_expectations(expectations, actualBitmap, | 862 errors.add(compare_to_expectations(expectations, actualBitmap, |
| 863 name, "", true)); | 863 name, "", true)); |
| 864 } else { | 864 } else { |
| 865 // If we are running without expectations, we still want to | 865 // If we are running without expectations, we still want to |
| 866 // record the actual results. | 866 // record the actual results. |
| 867 SkHashDigest actualBitmapHash; | 867 SkUInt64HashDigest actualBitmapHash; |
| 868 // TODO(epoger): Better handling for error returned by ComputeDigest
()? | 868 // TODO(epoger): Better handling for error returned by ComputeDigest
()? |
| 869 // For now, we just report a digest of 0 in error cases, like before
. | 869 // For now, we just report a digest of 0 in error cases, like before
. |
| 870 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash))
{ | 870 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash))
{ |
| 871 actualBitmapHash = 0; | 871 actualBitmapHash = 0; |
| 872 } | 872 } |
| 873 add_actual_results_to_json_summary(name.c_str(), actualBitmapHash, | 873 add_actual_results_to_json_summary(name.c_str(), actualBitmapHash, |
| 874 ErrorCombination(kMissingExpectat
ions_ErrorType), | 874 ErrorCombination(kMissingExpectat
ions_ErrorType), |
| 875 false); | 875 false); |
| 876 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
name, ""); | 876 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
name, ""); |
| 877 } | 877 } |
| (...skipping 1036 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1914 if (FLAGS_forceBWtext) { | 1914 if (FLAGS_forceBWtext) { |
| 1915 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1915 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 1916 } | 1916 } |
| 1917 } | 1917 } |
| 1918 | 1918 |
| 1919 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1919 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 1920 int main(int argc, char * const argv[]) { | 1920 int main(int argc, char * const argv[]) { |
| 1921 return tool_main(argc, (char**) argv); | 1921 return tool_main(argc, (char**) argv); |
| 1922 } | 1922 } |
| 1923 #endif | 1923 #endif |
| OLD | NEW |