| 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 732 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 743 * results to the JSON summary. (This is so that we will always | 743 * results to the JSON summary. (This is so that we will always |
| 744 * report errors across rendering modes, such as pipe vs tiled. | 744 * report errors across rendering modes, such as pipe vs tiled. |
| 745 * See https://codereview.chromium.org/13650002/ ) | 745 * See https://codereview.chromium.org/13650002/ ) |
| 746 */ | 746 */ |
| 747 ErrorCombination compare_to_expectations(Expectations expectations, | 747 ErrorCombination compare_to_expectations(Expectations expectations, |
| 748 const SkBitmap& actualBitmap, | 748 const SkBitmap& actualBitmap, |
| 749 const char *shortName, const char *
configName, | 749 const char *shortName, const char *
configName, |
| 750 const char *renderModeDescriptor, | 750 const char *renderModeDescriptor, |
| 751 bool addToJsonSummary) { | 751 bool addToJsonSummary) { |
| 752 ErrorCombination errors; | 752 ErrorCombination errors; |
| 753 SkHashDigest actualBitmapHash; | 753 uint64_t actualBitmapHash; |
| 754 // TODO(epoger): Better handling for error returned by ComputeDigest()? | 754 // TODO(epoger): Better handling for error returned by ComputeDigest()? |
| 755 // For now, we just report a digest of 0 in error cases, like before. | 755 // For now, we just report a digest of 0 in error cases, like before. |
| 756 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { | 756 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { |
| 757 actualBitmapHash = 0; | 757 actualBitmapHash = 0; |
| 758 } | 758 } |
| 759 SkString shortNamePlusConfig = make_shortname_plus_config(shortName, con
figName); | 759 SkString shortNamePlusConfig = make_shortname_plus_config(shortName, con
figName); |
| 760 SkString completeNameString(shortNamePlusConfig); | 760 SkString completeNameString(shortNamePlusConfig); |
| 761 completeNameString.append(renderModeDescriptor); | 761 completeNameString.append(renderModeDescriptor); |
| 762 completeNameString.append("."); | 762 completeNameString.append("."); |
| 763 completeNameString.append(kPNG_FileExtension); | 763 completeNameString.append(kPNG_FileExtension); |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 800 } | 800 } |
| 801 | 801 |
| 802 return errors; | 802 return errors; |
| 803 } | 803 } |
| 804 | 804 |
| 805 /** | 805 /** |
| 806 * Add this result to the appropriate JSON collection of actual results, | 806 * Add this result to the appropriate JSON collection of actual results, |
| 807 * depending on errors encountered. | 807 * depending on errors encountered. |
| 808 */ | 808 */ |
| 809 void add_actual_results_to_json_summary(const char testName[], | 809 void add_actual_results_to_json_summary(const char testName[], |
| 810 const SkHashDigest& actualResult, | 810 uint64_t actualResult, |
| 811 ErrorCombination errors, | 811 ErrorCombination errors, |
| 812 bool ignoreFailure) { | 812 bool ignoreFailure) { |
| 813 Json::Value jsonActualResults = ActualResultAsJsonValue(actualResult); | 813 Json::Value jsonActualResults = ActualResultAsJsonValue(actualResult); |
| 814 if (errors.isEmpty()) { | 814 if (errors.isEmpty()) { |
| 815 this->fJsonActualResults_Succeeded[testName] = jsonActualResults; | 815 this->fJsonActualResults_Succeeded[testName] = jsonActualResults; |
| 816 } else { | 816 } else { |
| 817 if (ignoreFailure) { | 817 if (ignoreFailure) { |
| 818 // TODO: Once we have added the ability to compare | 818 // TODO: Once we have added the ability to compare |
| 819 // actual results against expectations in a JSON file | 819 // actual results against expectations in a JSON file |
| 820 // (where we can set ignore-failure to either true or | 820 // (where we can set ignore-failure to either true or |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 889 * hash digest of actualBitmap, which *has* been run through | 889 * hash digest of actualBitmap, which *has* been run through |
| 890 * force_all_opaque(). | 890 * force_all_opaque(). |
| 891 * See comments above complete_bitmap() for more detail. | 891 * See comments above complete_bitmap() for more detail. |
| 892 */ | 892 */ |
| 893 Expectations expectations = expectationsSource->get(nameWithExtensio
n.c_str()); | 893 Expectations expectations = expectationsSource->get(nameWithExtensio
n.c_str()); |
| 894 errors.add(compare_to_expectations(expectations, actualBitmap, | 894 errors.add(compare_to_expectations(expectations, actualBitmap, |
| 895 gm->shortName(), gRec.fName, "",
true)); | 895 gm->shortName(), gRec.fName, "",
true)); |
| 896 } else { | 896 } else { |
| 897 // If we are running without expectations, we still want to | 897 // If we are running without expectations, we still want to |
| 898 // record the actual results. | 898 // record the actual results. |
| 899 SkHashDigest actualBitmapHash; | 899 uint64_t actualBitmapHash; |
| 900 // TODO(epoger): Better handling for error returned by ComputeDigest
()? | 900 // TODO(epoger): Better handling for error returned by ComputeDigest
()? |
| 901 // For now, we just report a digest of 0 in error cases, like before
. | 901 // For now, we just report a digest of 0 in error cases, like before
. |
| 902 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash))
{ | 902 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash))
{ |
| 903 actualBitmapHash = 0; | 903 actualBitmapHash = 0; |
| 904 } | 904 } |
| 905 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual
BitmapHash, | 905 add_actual_results_to_json_summary(nameWithExtension.c_str(), actual
BitmapHash, |
| 906 ErrorCombination(kMissingExpectat
ions_ErrorType), | 906 ErrorCombination(kMissingExpectat
ions_ErrorType), |
| 907 false); | 907 false); |
| 908 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), | 908 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), |
| 909 shortNamePlusConfig, ""); | 909 shortNamePlusConfig, ""); |
| (...skipping 1179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2089 if (FLAGS_forceBWtext) { | 2089 if (FLAGS_forceBWtext) { |
| 2090 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2090 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2091 } | 2091 } |
| 2092 } | 2092 } |
| 2093 | 2093 |
| 2094 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2094 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2095 int main(int argc, char * const argv[]) { | 2095 int main(int argc, char * const argv[]) { |
| 2096 return tool_main(argc, (char**) argv); | 2096 return tool_main(argc, (char**) argv); |
| 2097 } | 2097 } |
| 2098 #endif | 2098 #endif |
| OLD | NEW |