| 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 45 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 56 #define DEFAULT_CACHE_VALUE -1 | 56 #define DEFAULT_CACHE_VALUE -1 | 
| 57 static int gGpuCacheSizeBytes; | 57 static int gGpuCacheSizeBytes; | 
| 58 static int gGpuCacheSizeCount; | 58 static int gGpuCacheSizeCount; | 
| 59 #else | 59 #else | 
| 60 class GrContextFactory; | 60 class GrContextFactory; | 
| 61 class GrContext; | 61 class GrContext; | 
| 62 class GrSurface; | 62 class GrSurface; | 
| 63 typedef int GLContextType; | 63 typedef int GLContextType; | 
| 64 #endif | 64 #endif | 
| 65 | 65 | 
|  | 66 #define DEBUGFAIL_SEE_STDERR SkDEBUGFAIL("see stderr for message") | 
|  | 67 | 
| 66 extern bool gSkSuppressFontCachePurgeSpew; | 68 extern bool gSkSuppressFontCachePurgeSpew; | 
| 67 | 69 | 
| 68 #ifdef SK_SUPPORT_PDF | 70 #ifdef SK_SUPPORT_PDF | 
| 69     #include "SkPDFDevice.h" | 71     #include "SkPDFDevice.h" | 
| 70     #include "SkPDFDocument.h" | 72     #include "SkPDFDocument.h" | 
| 71 #endif | 73 #endif | 
| 72 | 74 | 
| 73 // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , | 75 // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , | 
| 74 // stop writing out XPS-format image baselines in gm. | 76 // stop writing out XPS-format image baselines in gm. | 
| 75 #undef SK_SUPPORT_XPS | 77 #undef SK_SUPPORT_XPS | 
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 761             add_actual_results_to_json_summary(completeName, actualBitmapHash, e
      rrors, | 763             add_actual_results_to_json_summary(completeName, actualBitmapHash, e
      rrors, | 
| 762                                                expectations.ignoreFailure()); | 764                                                expectations.ignoreFailure()); | 
| 763             add_expected_results_to_json_summary(completeName, expectations); | 765             add_expected_results_to_json_summary(completeName, expectations); | 
| 764         } | 766         } | 
| 765 | 767 | 
| 766         return errors; | 768         return errors; | 
| 767     } | 769     } | 
| 768 | 770 | 
| 769     /** | 771     /** | 
| 770      * Add this result to the appropriate JSON collection of actual results, | 772      * Add this result to the appropriate JSON collection of actual results, | 
| 771      * depending on status. | 773      * depending on errors encountered. | 
| 772      */ | 774      */ | 
| 773     void add_actual_results_to_json_summary(const char testName[], | 775     void add_actual_results_to_json_summary(const char testName[], | 
| 774                                             const SkHashDigest& actualBitmapHash
      , | 776                                             const SkHashDigest& actualResult, | 
| 775                                             ErrorCombination result, | 777                                             ErrorCombination errors, | 
| 776                                             bool ignoreFailure) { | 778                                             bool ignoreFailure) { | 
| 777         Json::Value actualResults; | 779         Json::Value jsonActualResults = ActualResultAsJsonValue(actualResult); | 
| 778         actualResults[kJsonKey_ActualResults_AnyStatus_Checksum] = | 780         if (errors.isEmpty()) { | 
| 779             asJsonValue(actualBitmapHash); | 781             this->fJsonActualResults_Succeeded[testName] = jsonActualResults; | 
| 780         if (result.isEmpty()) { |  | 
| 781             this->fJsonActualResults_Succeeded[testName] = actualResults; |  | 
| 782         } else { | 782         } else { | 
| 783             if (ignoreFailure) { | 783             if (ignoreFailure) { | 
| 784                 // TODO: Once we have added the ability to compare | 784                 // TODO: Once we have added the ability to compare | 
| 785                 // actual results against expectations in a JSON file | 785                 // actual results against expectations in a JSON file | 
| 786                 // (where we can set ignore-failure to either true or | 786                 // (where we can set ignore-failure to either true or | 
| 787                 // false), add test cases that exercise ignored | 787                 // false), add test cases that exercise ignored | 
| 788                 // failures (both for kMissingExpectations_ErrorType | 788                 // failures (both for kMissingExpectations_ErrorType | 
| 789                 // and kExpectationsMismatch_ErrorType). | 789                 // and kExpectationsMismatch_ErrorType). | 
| 790                 this->fJsonActualResults_FailureIgnored[testName] = | 790                 this->fJsonActualResults_FailureIgnored[testName] = | 
| 791                     actualResults; | 791                     jsonActualResults; | 
| 792             } else { | 792             } else { | 
| 793                 if (result.includes(kMissingExpectations_ErrorType)) { | 793                 if (errors.includes(kMissingExpectations_ErrorType)) { | 
| 794                     // TODO: What about the case where there IS an | 794                     // TODO: What about the case where there IS an | 
| 795                     // expected image hash digest, but that gm test | 795                     // expected image hash digest, but that gm test | 
| 796                     // doesn't actually run?  For now, those cases | 796                     // doesn't actually run?  For now, those cases | 
| 797                     // will always be ignored, because gm only looks | 797                     // will always be ignored, because gm only looks | 
| 798                     // at expectations that correspond to gm tests | 798                     // at expectations that correspond to gm tests | 
| 799                     // that were actually run. | 799                     // that were actually run. | 
| 800                     // | 800                     // | 
| 801                     // Once we have the ability to express | 801                     // Once we have the ability to express | 
| 802                     // expectations as a JSON file, we should fix this | 802                     // expectations as a JSON file, we should fix this | 
| 803                     // (and add a test case for which an expectation | 803                     // (and add a test case for which an expectation | 
| 804                     // is given but the test is never run). | 804                     // is given but the test is never run). | 
| 805                     this->fJsonActualResults_NoComparison[testName] = | 805                     this->fJsonActualResults_NoComparison[testName] = | 
| 806                         actualResults; | 806                         jsonActualResults; | 
| 807                 } | 807                 } | 
| 808                 if (result.includes(kExpectationsMismatch_ErrorType) || | 808                 if (errors.includes(kExpectationsMismatch_ErrorType) || | 
| 809                     result.includes(kRenderModeMismatch_ErrorType)) { | 809                     errors.includes(kRenderModeMismatch_ErrorType)) { | 
| 810                     this->fJsonActualResults_Failed[testName] = actualResults; | 810                     this->fJsonActualResults_Failed[testName] = jsonActualResult
      s; | 
| 811                 } | 811                 } | 
| 812             } | 812             } | 
| 813         } | 813         } | 
| 814     } | 814     } | 
| 815 | 815 | 
| 816     /** | 816     /** | 
| 817      * Add this test to the JSON collection of expected results. | 817      * Add this test to the JSON collection of expected results. | 
| 818      */ | 818      */ | 
| 819     void add_expected_results_to_json_summary(const char testName[], | 819     void add_expected_results_to_json_summary(const char testName[], | 
| 820                                               Expectations expectations) { | 820                                               Expectations expectations) { | 
| 821         // For now, we assume that this collection starts out empty and we | 821         this->fJsonExpectedResults[testName] = expectations.asJsonValue(); | 
| 822         // just fill it in as we go; once gm accepts a JSON file as input, |  | 
| 823         // we'll have to change that. |  | 
| 824         Json::Value expectedResults; |  | 
| 825         expectedResults[kJsonKey_ExpectedResults_Checksums] = |  | 
| 826             expectations.allowedChecksumsAsJson(); |  | 
| 827         expectedResults[kJsonKey_ExpectedResults_IgnoreFailure] = |  | 
| 828             expectations.ignoreFailure(); |  | 
| 829         this->fJsonExpectedResults[testName] = expectedResults; |  | 
| 830     } | 822     } | 
| 831 | 823 | 
| 832     /** | 824     /** | 
| 833      * Compare actualBitmap to expectations stored in this->fExpectationsSource. | 825      * Compare actualBitmap to expectations stored in this->fExpectationsSource. | 
| 834      * | 826      * | 
| 835      * @param gm which test generated the actualBitmap | 827      * @param gm which test generated the actualBitmap | 
| 836      * @param gRec | 828      * @param gRec | 
| 837      * @param writePath unless this is NULL, write out actual images into this | 829      * @param writePath unless this is NULL, write out actual images into this | 
| 838      *        directory | 830      *        directory | 
| 839      * @param actualBitmap bitmap generated by this run | 831      * @param actualBitmap bitmap generated by this run | 
| (...skipping 1112 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1952     // ('GM is unexpectedly skipping tests on Android') | 1944     // ('GM is unexpectedly skipping tests on Android') | 
| 1953 #ifndef SK_BUILD_FOR_ANDROID | 1945 #ifndef SK_BUILD_FOR_ANDROID | 
| 1954     if (expectedNumberOfTests != gmmain.fTestsRun) { | 1946     if (expectedNumberOfTests != gmmain.fTestsRun) { | 
| 1955         gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", | 1947         gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", | 
| 1956                    expectedNumberOfTests, gmmain.fTestsRun); | 1948                    expectedNumberOfTests, gmmain.fTestsRun); | 
| 1957         reportError = true; | 1949         reportError = true; | 
| 1958     } | 1950     } | 
| 1959 #endif | 1951 #endif | 
| 1960 | 1952 | 
| 1961     if (FLAGS_writeJsonSummaryPath.count() == 1) { | 1953     if (FLAGS_writeJsonSummaryPath.count() == 1) { | 
| 1962         Json::Value actualResults; | 1954         Json::Value root = CreateJsonTree( | 
| 1963         actualResults[kJsonKey_ActualResults_Failed] = | 1955             gmmain.fJsonExpectedResults, | 
| 1964             gmmain.fJsonActualResults_Failed; | 1956             gmmain.fJsonActualResults_Failed, gmmain.fJsonActualResults_FailureI
      gnored, | 
| 1965         actualResults[kJsonKey_ActualResults_FailureIgnored] = | 1957             gmmain.fJsonActualResults_NoComparison, gmmain.fJsonActualResults_Su
      cceeded); | 
| 1966             gmmain.fJsonActualResults_FailureIgnored; |  | 
| 1967         actualResults[kJsonKey_ActualResults_NoComparison] = |  | 
| 1968             gmmain.fJsonActualResults_NoComparison; |  | 
| 1969         actualResults[kJsonKey_ActualResults_Succeeded] = |  | 
| 1970             gmmain.fJsonActualResults_Succeeded; |  | 
| 1971         Json::Value root; |  | 
| 1972         root[kJsonKey_ActualResults] = actualResults; |  | 
| 1973         root[kJsonKey_ExpectedResults] = gmmain.fJsonExpectedResults; |  | 
| 1974         std::string jsonStdString = root.toStyledString(); | 1958         std::string jsonStdString = root.toStyledString(); | 
| 1975         SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); | 1959         SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); | 
| 1976         stream.write(jsonStdString.c_str(), jsonStdString.length()); | 1960         stream.write(jsonStdString.c_str(), jsonStdString.length()); | 
| 1977     } | 1961     } | 
| 1978 | 1962 | 
| 1979 #if SK_SUPPORT_GPU | 1963 #if SK_SUPPORT_GPU | 
| 1980 | 1964 | 
| 1981 #if GR_CACHE_STATS | 1965 #if GR_CACHE_STATS | 
| 1982     for (int i = 0; i < configs.count(); i++) { | 1966     for (int i = 0; i < configs.count(); i++) { | 
| 1983         ConfigData config = gRec[configs[i]]; | 1967         ConfigData config = gRec[configs[i]]; | 
| (...skipping 18 matching lines...) Expand all  Loading... | 
| 2002     if (FLAGS_forceBWtext) { | 1986     if (FLAGS_forceBWtext) { | 
| 2003         canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1987         canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 
| 2004     } | 1988     } | 
| 2005 } | 1989 } | 
| 2006 | 1990 | 
| 2007 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1991 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 
| 2008 int main(int argc, char * const argv[]) { | 1992 int main(int argc, char * const argv[]) { | 
| 2009     return tool_main(argc, (char**) argv); | 1993     return tool_main(argc, (char**) argv); | 
| 2010 } | 1994 } | 
| 2011 #endif | 1995 #endif | 
| OLD | NEW | 
|---|