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 308 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
319 if (modeAsString.startsWith("-")) { | 319 if (modeAsString.startsWith("-")) { |
320 modeAsString.remove(0, 1); | 320 modeAsString.remove(0, 1); |
321 } | 321 } |
322 modes.push_back(modeAsString); | 322 modes.push_back(modeAsString); |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 /** | 326 /** |
327 * Returns true if failures on this test should be ignored. | 327 * Returns true if failures on this test should be ignored. |
328 */ | 328 */ |
329 bool ShouldIgnoreTest(const SkString &name) const { | 329 bool ShouldIgnoreTest(const char *name) const { |
330 for (int i = 0; i < fIgnorableTestSubstrings.count(); i++) { | 330 for (int i = 0; i < fIgnorableTestNames.count(); i++) { |
331 if (name.contains(fIgnorableTestSubstrings[i].c_str())) { | 331 if (fIgnorableTestNames[i].equals(name)) { |
332 return true; | 332 return true; |
333 } | 333 } |
334 } | 334 } |
335 return false; | 335 return false; |
336 } | 336 } |
337 | 337 |
338 /** | 338 /** |
339 * Calls RecordTestResults to record that we skipped a test. | 339 * Calls RecordTestResults to record that we skipped a test. |
340 * | 340 * |
341 * Depending on the backend, this may mean that we skipped a single rendermo
de, or all | 341 * Depending on the backend, this may mean that we skipped a single rendermo
de, or all |
(...skipping 569 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
911 * | 911 * |
912 * @param gm which test generated the actualBitmap | 912 * @param gm which test generated the actualBitmap |
913 * @param gRec | 913 * @param gRec |
914 * @param configName The config name to look for in the expectation file. | 914 * @param configName The config name to look for in the expectation file. |
915 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL | 915 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL |
916 * if we don't have a usable bitmap representation | 916 * if we don't have a usable bitmap representation |
917 */ | 917 */ |
918 ErrorCombination compare_test_results_to_stored_expectations( | 918 ErrorCombination compare_test_results_to_stored_expectations( |
919 GM* gm, const ConfigData& gRec, const char* configName, | 919 GM* gm, const ConfigData& gRec, const char* configName, |
920 const BitmapAndDigest* actualBitmapAndDigest) { | 920 const BitmapAndDigest* actualBitmapAndDigest) { |
921 | |
922 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(
), configName); | |
923 | |
924 ErrorCombination errors; | 921 ErrorCombination errors; |
925 | 922 |
926 if (NULL == actualBitmapAndDigest) { | 923 if (NULL == actualBitmapAndDigest) { |
927 // Note that we intentionally skipped validating the results for | 924 // Note that we intentionally skipped validating the results for |
928 // this test, because we don't know how to generate an SkBitmap | 925 // this test, because we don't know how to generate an SkBitmap |
929 // version of the output. | 926 // version of the output. |
930 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); | 927 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); |
931 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { | 928 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { |
932 // We don't record the results for this test or compare them | 929 // We don't record the results for this test or compare them |
933 // against any expectations, because the output image isn't | 930 // against any expectations, because the output image isn't |
934 // meaningful. | 931 // meaningful. |
935 // See https://code.google.com/p/skia/issues/detail?id=1410 ('some | 932 // See https://code.google.com/p/skia/issues/detail?id=1410 ('some |
936 // GM result images not available for download from Google Storage') | 933 // GM result images not available for download from Google Storage') |
937 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); | 934 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); |
938 } else { | 935 } else { |
939 ExpectationsSource *expectationsSource = this->fExpectationsSource.g
et(); | 936 ExpectationsSource *expectationsSource = this->fExpectationsSource.g
et(); |
940 SkString nameWithExtension(shortNamePlusConfig); | 937 SkString nameWithExtension = make_shortname_plus_config(gm->shortNam
e(), configName); |
941 nameWithExtension.append("."); | 938 nameWithExtension.append("."); |
942 nameWithExtension.append(kPNG_FileExtension); | 939 nameWithExtension.append(kPNG_FileExtension); |
943 | 940 |
944 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { | 941 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { |
945 /* | 942 /* |
946 * Get the expected results for this test, as one or more allowe
d | 943 * Get the expected results for this test, as one or more allowe
d |
947 * hash digests. The current implementation of expectationsSourc
e | 944 * hash digests. The current implementation of expectationsSourc
e |
948 * get this by computing the hash digest of a single PNG file on
disk. | 945 * get this by computing the hash digest of a single PNG file on
disk. |
949 * | 946 * |
950 * TODO(epoger): This relies on the fact that | 947 * TODO(epoger): This relies on the fact that |
951 * force_all_opaque() was called on the bitmap before it | 948 * force_all_opaque() was called on the bitmap before it |
952 * was written to disk as a PNG in the first place. If | 949 * was written to disk as a PNG in the first place. If |
953 * not, the hash digest returned here may not match the | 950 * not, the hash digest returned here may not match the |
954 * hash digest of actualBitmap, which *has* been run through | 951 * hash digest of actualBitmap, which *has* been run through |
955 * force_all_opaque(). | 952 * force_all_opaque(). |
956 * See comments above complete_bitmap() for more detail. | 953 * See comments above complete_bitmap() for more detail. |
957 */ | 954 */ |
958 Expectations expectations = expectationsSource->get(nameWithExte
nsion.c_str()); | 955 Expectations expectations = expectationsSource->get(nameWithExte
nsion.c_str()); |
959 if (this->ShouldIgnoreTest(shortNamePlusConfig)) { | 956 if (this->ShouldIgnoreTest(gm->shortName())) { |
960 expectations.setIgnoreFailure(true); | 957 expectations.setIgnoreFailure(true); |
961 } | 958 } |
962 errors.add(compare_to_expectations(expectations, *actualBitmapAn
dDigest, | 959 errors.add(compare_to_expectations(expectations, *actualBitmapAn
dDigest, |
963 gm->shortName(), configName,
"", true)); | 960 gm->shortName(), configName,
"", true)); |
964 } else { | 961 } else { |
965 // If we are running without expectations, we still want to | 962 // If we are running without expectations, we still want to |
966 // record the actual results. | 963 // record the actual results. |
967 add_actual_results_to_json_summary(nameWithExtension.c_str(), | 964 add_actual_results_to_json_summary(nameWithExtension.c_str(), |
968 actualBitmapAndDigest->fDiges
t, | 965 actualBitmapAndDigest->fDiges
t, |
969 ErrorCombination(kMissingExpe
ctations_ErrorType), | 966 ErrorCombination(kMissingExpe
ctations_ErrorType), |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1247 return errors; | 1244 return errors; |
1248 } | 1245 } |
1249 | 1246 |
1250 // | 1247 // |
1251 // member variables. | 1248 // member variables. |
1252 // They are public for now, to allow easier setting by tool_main(). | 1249 // They are public for now, to allow easier setting by tool_main(). |
1253 // | 1250 // |
1254 | 1251 |
1255 bool fUseFileHierarchy, fWriteChecksumBasedFilenames; | 1252 bool fUseFileHierarchy, fWriteChecksumBasedFilenames; |
1256 ErrorCombination fIgnorableErrorTypes; | 1253 ErrorCombination fIgnorableErrorTypes; |
1257 SkTArray<SkString> fIgnorableTestSubstrings; | 1254 SkTArray<SkString> fIgnorableTestNames; |
1258 | 1255 |
1259 const char* fMismatchPath; | 1256 const char* fMismatchPath; |
1260 const char* fMissingExpectationsPath; | 1257 const char* fMissingExpectationsPath; |
1261 | 1258 |
1262 // collection of tests that have failed with each ErrorType | 1259 // collection of tests that have failed with each ErrorType |
1263 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; | 1260 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; |
1264 SkTArray<SkString> fTestsSkippedOnAllRenderModes; | 1261 SkTArray<SkString> fTestsSkippedOnAllRenderModes; |
1265 int fTestsRun; | 1262 int fTestsRun; |
1266 SkTDict<int> fRenderModesEncountered; | 1263 SkTDict<int> fRenderModesEncountered; |
1267 | 1264 |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2067 return false; | 2064 return false; |
2068 } else { | 2065 } else { |
2069 outErrorTypes->add(type); | 2066 outErrorTypes->add(type); |
2070 } | 2067 } |
2071 } | 2068 } |
2072 } | 2069 } |
2073 return true; | 2070 return true; |
2074 } | 2071 } |
2075 | 2072 |
2076 /** | 2073 /** |
2077 * Replace contents of ignoreTestSubstrings with a list of testname/config subst
rings, indicating | 2074 * Replace contents of ignoreTestNames with a list of test names, indicating |
2078 * which tests' failures should be ignored. | 2075 * which tests' failures should be ignored. |
2079 */ | 2076 */ |
2080 static bool parse_flags_ignore_tests(SkTArray<SkString> &ignoreTestSubstrings) { | 2077 static bool parse_flags_ignore_tests(SkTArray<SkString> &ignoreTestNames) { |
2081 ignoreTestSubstrings.reset(); | 2078 ignoreTestNames.reset(); |
2082 | 2079 |
2083 // Parse --ignoreFailuresFile | 2080 // Parse --ignoreFailuresFile |
2084 for (int i = 0; i < FLAGS_ignoreFailuresFile.count(); i++) { | 2081 for (int i = 0; i < FLAGS_ignoreFailuresFile.count(); i++) { |
2085 SkTArray<SkString> linesFromFile; | 2082 SkTArray<SkString> linesFromFile; |
2086 if (!read_lines_from_file(FLAGS_ignoreFailuresFile[i], linesFromFile)) { | 2083 if (!read_lines_from_file(FLAGS_ignoreFailuresFile[i], linesFromFile)) { |
2087 return false; | 2084 return false; |
2088 } else { | 2085 } else { |
2089 for (int j = 0; j < linesFromFile.count(); j++) { | 2086 for (int j = 0; j < linesFromFile.count(); j++) { |
2090 SkString thisLine = linesFromFile[j]; | 2087 SkString thisLine = linesFromFile[j]; |
2091 if (thisLine.isEmpty() || thisLine.startsWith('#')) { | 2088 if (thisLine.isEmpty() || thisLine.startsWith('#')) { |
2092 // skip this line | 2089 // skip this line |
2093 } else { | 2090 } else { |
2094 ignoreTestSubstrings.push_back(thisLine); | 2091 ignoreTestNames.push_back(thisLine); |
2095 } | 2092 } |
2096 } | 2093 } |
2097 } | 2094 } |
2098 } | 2095 } |
2099 | 2096 |
2100 return true; | 2097 return true; |
2101 } | 2098 } |
2102 | 2099 |
2103 static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { | 2100 static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { |
2104 if (FLAGS_modulo.count() == 2) { | 2101 if (FLAGS_modulo.count() == 2) { |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2224 SkTDArray<const PDFRasterizerData*> pdfRasterizers; | 2221 SkTDArray<const PDFRasterizerData*> pdfRasterizers; |
2225 SkTDArray<SkScalar> tileGridReplayScales; | 2222 SkTDArray<SkScalar> tileGridReplayScales; |
2226 #if SK_SUPPORT_GPU | 2223 #if SK_SUPPORT_GPU |
2227 GrContextFactory* grFactory = new GrContextFactory; | 2224 GrContextFactory* grFactory = new GrContextFactory; |
2228 #else | 2225 #else |
2229 GrContextFactory* grFactory = NULL; | 2226 GrContextFactory* grFactory = NULL; |
2230 #endif | 2227 #endif |
2231 | 2228 |
2232 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || | 2229 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || |
2233 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || | 2230 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || |
2234 !parse_flags_ignore_tests(gmmain.fIgnorableTestSubstrings) || | 2231 !parse_flags_ignore_tests(gmmain.fIgnorableTestNames) || |
2235 #if SK_SUPPORT_GPU | 2232 #if SK_SUPPORT_GPU |
2236 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || | 2233 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || |
2237 #endif | 2234 #endif |
2238 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || | 2235 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || |
2239 !parse_flags_resource_path() || | 2236 !parse_flags_resource_path() || |
2240 !parse_flags_jpeg_quality() || | 2237 !parse_flags_jpeg_quality() || |
2241 !parse_flags_configs(&configs, grFactory) || | 2238 !parse_flags_configs(&configs, grFactory) || |
2242 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) || | 2239 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) || |
2243 !parse_flags_gmmain_paths(&gmmain)) { | 2240 !parse_flags_gmmain_paths(&gmmain)) { |
2244 return -1; | 2241 return -1; |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2412 if (FLAGS_forceBWtext) { | 2409 if (FLAGS_forceBWtext) { |
2413 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2410 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2414 } | 2411 } |
2415 } | 2412 } |
2416 | 2413 |
2417 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2414 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2418 int main(int argc, char * const argv[]) { | 2415 int main(int argc, char * const argv[]) { |
2419 return tool_main(argc, (char**) argv); | 2416 return tool_main(argc, (char**) argv); |
2420 } | 2417 } |
2421 #endif | 2418 #endif |
OLD | NEW |