Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(97)

Side by Side Diff: gm/gmmain.cpp

Issue 14265010: Make SkSHA1 and SkM5 use common SkDigestHash result type (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: switch_to_MD5 Created 7 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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
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 BITMAP_HASH_TYPE actualBitmapHash;
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.
720 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { 718 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) {
epoger 2013/04/18 18:07:13 Unlike SkData objects, SkHashDigest objects are mu
721 actualBitmapHash = 0; 719 // TODO(epoger): Better handling for error returned by ComputeDigest ()?
720 // For now, we just leave actualBitmapHash empty.
722 } 721 }
723 SkString completeNameString = baseNameString; 722 SkString completeNameString = baseNameString;
724 completeNameString.append(renderModeDescriptor); 723 completeNameString.append(renderModeDescriptor);
725 const char* completeName = completeNameString.c_str(); 724 const char* completeName = completeNameString.c_str();
726 725
727 if (expectations.empty()) { 726 if (expectations.empty()) {
728 errors.add(kMissingExpectations_ErrorType); 727 errors.add(kMissingExpectations_ErrorType);
729 } else if (!expectations.match(actualBitmapHash)) { 728 } else if (!expectations.match(actualBitmapHash)) {
730 addToJsonSummary = true; 729 addToJsonSummary = true;
731 // The error mode we record depends on whether this was running 730 // The error mode we record depends on whether this was running
(...skipping 29 matching lines...) Expand all
761 } 760 }
762 761
763 return errors; 762 return errors;
764 } 763 }
765 764
766 /** 765 /**
767 * Add this result to the appropriate JSON collection of actual results, 766 * Add this result to the appropriate JSON collection of actual results,
768 * depending on status. 767 * depending on status.
769 */ 768 */
770 void add_actual_results_to_json_summary(const char testName[], 769 void add_actual_results_to_json_summary(const char testName[],
771 const SkHashDigest& actualBitmapHash , 770 const BITMAP_HASH_TYPE& actualBitmap Hash,
772 ErrorCombination result, 771 ErrorCombination result,
773 bool ignoreFailure) { 772 bool ignoreFailure) {
774 Json::Value actualResults; 773 Json::Value actualResults;
775 actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] = 774 actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] =
776 asJsonValue(actualBitmapHash); 775 asJsonValue(actualBitmapHash);
777 if (result.isEmpty()) { 776 if (result.isEmpty()) {
778 this->fJsonActualResults_Succeeded[testName] = actualResults; 777 this->fJsonActualResults_Succeeded[testName] = actualResults;
779 } else { 778 } else {
780 if (ignoreFailure) { 779 if (ignoreFailure) {
781 // TODO: Once we have added the ability to compare 780 // TODO: Once we have added the ability to compare
(...skipping 75 matching lines...) Expand 10 before | Expand all | Expand 10 after
857 * hash digest of actualBitmap, which *has* been run through 856 * hash digest of actualBitmap, which *has* been run through
858 * force_all_opaque(). 857 * force_all_opaque().
859 * See comments above complete_bitmap() for more detail. 858 * See comments above complete_bitmap() for more detail.
860 */ 859 */
861 Expectations expectations = expectationsSource->get(name.c_str()); 860 Expectations expectations = expectationsSource->get(name.c_str());
862 errors.add(compare_to_expectations(expectations, actualBitmap, 861 errors.add(compare_to_expectations(expectations, actualBitmap,
863 name, "", true)); 862 name, "", true));
864 } else { 863 } else {
865 // If we are running without expectations, we still want to 864 // If we are running without expectations, we still want to
866 // record the actual results. 865 // record the actual results.
867 SkHashDigest actualBitmapHash; 866 BITMAP_HASH_TYPE actualBitmapHash;
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 .
870 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) { 867 if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) {
871 actualBitmapHash = 0; 868 // TODO(epoger): Better handling for error returned by ComputeDi gest()?
869 // For now, we just leave actualBitmapHash empty.
872 } 870 }
873 add_actual_results_to_json_summary(name.c_str(), actualBitmapHash, 871 add_actual_results_to_json_summary(name.c_str(), actualBitmapHash,
874 ErrorCombination(kMissingExpectat ions_ErrorType), 872 ErrorCombination(kMissingExpectat ions_ErrorType),
875 false); 873 false);
876 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), name, ""); 874 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), name, "");
877 } 875 }
878 876
879 // TODO: Consider moving this into compare_to_expectations(), 877 // TODO: Consider moving this into compare_to_expectations(),
880 // similar to fMismatchPath... for now, we don't do that, because 878 // similar to fMismatchPath... for now, we don't do that, because
881 // we don't want to write out the actual bitmaps for all 879 // we don't want to write out the actual bitmaps for all
(...skipping 1032 matching lines...) Expand 10 before | Expand all | Expand 10 after
1914 if (FLAGS_forceBWtext) { 1912 if (FLAGS_forceBWtext) {
1915 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 1913 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
1916 } 1914 }
1917 } 1915 }
1918 1916
1919 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 1917 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1920 int main(int argc, char * const argv[]) { 1918 int main(int argc, char * const argv[]) {
1921 return tool_main(argc, (char**) argv); 1919 return tool_main(argc, (char**) argv);
1922 } 1920 }
1923 #endif 1921 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698