| 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 851 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 862 } | 862 } |
| 863 | 863 |
| 864 /** | 864 /** |
| 865 * Add this result to the appropriate JSON collection of actual results (but
just ONE), | 865 * Add this result to the appropriate JSON collection of actual results (but
just ONE), |
| 866 * depending on errors encountered. | 866 * depending on errors encountered. |
| 867 */ | 867 */ |
| 868 void add_actual_results_to_json_summary(const char testName[], | 868 void add_actual_results_to_json_summary(const char testName[], |
| 869 const GmResultDigest &actualResultDi
gest, | 869 const GmResultDigest &actualResultDi
gest, |
| 870 ErrorCombination errors, | 870 ErrorCombination errors, |
| 871 bool ignoreFailure) { | 871 bool ignoreFailure) { |
| 872 #ifdef SK_BUILD_JSON_WRITER | |
| 873 Json::Value jsonActualResults = actualResultDigest.asJsonTypeValuePair()
; | 872 Json::Value jsonActualResults = actualResultDigest.asJsonTypeValuePair()
; |
| 874 Json::Value *resultCollection = NULL; | 873 Json::Value *resultCollection = NULL; |
| 875 | 874 |
| 876 if (errors.isEmpty()) { | 875 if (errors.isEmpty()) { |
| 877 resultCollection = &this->fJsonActualResults_Succeeded; | 876 resultCollection = &this->fJsonActualResults_Succeeded; |
| 878 } else if (errors.includes(kRenderModeMismatch_ErrorType)) { | 877 } else if (errors.includes(kRenderModeMismatch_ErrorType)) { |
| 879 resultCollection = &this->fJsonActualResults_Failed; | 878 resultCollection = &this->fJsonActualResults_Failed; |
| 880 } else if (errors.includes(kExpectationsMismatch_ErrorType)) { | 879 } else if (errors.includes(kExpectationsMismatch_ErrorType)) { |
| 881 if (ignoreFailure) { | 880 if (ignoreFailure) { |
| 882 resultCollection = &this->fJsonActualResults_FailureIgnored; | 881 resultCollection = &this->fJsonActualResults_FailureIgnored; |
| (...skipping 11 matching lines...) Expand all Loading... |
| 894 // JSON file, we should fix this (and add a test case for | 893 // JSON file, we should fix this (and add a test case for |
| 895 // which an expectation is given but the test is never | 894 // which an expectation is given but the test is never |
| 896 // run). | 895 // run). |
| 897 resultCollection = &this->fJsonActualResults_NoComparison; | 896 resultCollection = &this->fJsonActualResults_NoComparison; |
| 898 } | 897 } |
| 899 | 898 |
| 900 // If none of the above cases match, we don't add it to ANY tally of act
ual results. | 899 // If none of the above cases match, we don't add it to ANY tally of act
ual results. |
| 901 if (resultCollection) { | 900 if (resultCollection) { |
| 902 (*resultCollection)[testName] = jsonActualResults; | 901 (*resultCollection)[testName] = jsonActualResults; |
| 903 } | 902 } |
| 904 #endif | |
| 905 } | 903 } |
| 906 | 904 |
| 907 /** | 905 /** |
| 908 * Add this test to the JSON collection of expected results. | 906 * Add this test to the JSON collection of expected results. |
| 909 */ | 907 */ |
| 910 void add_expected_results_to_json_summary(const char testName[], | 908 void add_expected_results_to_json_summary(const char testName[], |
| 911 Expectations expectations) { | 909 Expectations expectations) { |
| 912 #ifdef SK_BUILD_JSON_WRITER | |
| 913 this->fJsonExpectedResults[testName] = expectations.asJsonValue(); | 910 this->fJsonExpectedResults[testName] = expectations.asJsonValue(); |
| 914 #endif | |
| 915 } | 911 } |
| 916 | 912 |
| 917 /** | 913 /** |
| 918 * Compare actualBitmap to expectations stored in this->fExpectationsSource. | 914 * Compare actualBitmap to expectations stored in this->fExpectationsSource. |
| 919 * | 915 * |
| 920 * @param gm which test generated the actualBitmap | 916 * @param gm which test generated the actualBitmap |
| 921 * @param gRec | 917 * @param gRec |
| 922 * @param configName The config name to look for in the expectation file. | 918 * @param configName The config name to look for in the expectation file. |
| 923 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL | 919 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL |
| 924 * if we don't have a usable bitmap representation | 920 * if we don't have a usable bitmap representation |
| (...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1264 // collection of tests that have failed with each ErrorType | 1260 // collection of tests that have failed with each ErrorType |
| 1265 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; | 1261 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; |
| 1266 SkTArray<SkString> fTestsSkippedOnAllRenderModes; | 1262 SkTArray<SkString> fTestsSkippedOnAllRenderModes; |
| 1267 int fTestsRun; | 1263 int fTestsRun; |
| 1268 SkTDict<int> fRenderModesEncountered; | 1264 SkTDict<int> fRenderModesEncountered; |
| 1269 | 1265 |
| 1270 // Where to read expectations (expected image hash digests, etc.) from. | 1266 // Where to read expectations (expected image hash digests, etc.) from. |
| 1271 // If unset, we don't do comparisons. | 1267 // If unset, we don't do comparisons. |
| 1272 SkAutoTUnref<ExpectationsSource> fExpectationsSource; | 1268 SkAutoTUnref<ExpectationsSource> fExpectationsSource; |
| 1273 | 1269 |
| 1274 #ifdef SK_BUILD_JSON_WRITER | |
| 1275 // JSON summaries that we generate as we go (just for output). | 1270 // JSON summaries that we generate as we go (just for output). |
| 1276 Json::Value fJsonExpectedResults; | 1271 Json::Value fJsonExpectedResults; |
| 1277 Json::Value fJsonActualResults_Failed; | 1272 Json::Value fJsonActualResults_Failed; |
| 1278 Json::Value fJsonActualResults_FailureIgnored; | 1273 Json::Value fJsonActualResults_FailureIgnored; |
| 1279 Json::Value fJsonActualResults_NoComparison; | 1274 Json::Value fJsonActualResults_NoComparison; |
| 1280 Json::Value fJsonActualResults_Succeeded; | 1275 Json::Value fJsonActualResults_Succeeded; |
| 1281 #endif | |
| 1282 }; // end of GMMain class definition | 1276 }; // end of GMMain class definition |
| 1283 | 1277 |
| 1284 #if SK_SUPPORT_GPU | 1278 #if SK_SUPPORT_GPU |
| 1285 static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_G
LContextType; | 1279 static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_G
LContextType; |
| 1286 #else | 1280 #else |
| 1287 static const GLContextType kDontCare_GLContextType = 0; | 1281 static const GLContextType kDontCare_GLContextType = 0; |
| 1288 #endif | 1282 #endif |
| 1289 | 1283 |
| 1290 static const ConfigData gRec[] = { | 1284 static const ConfigData gRec[] = { |
| 1291 { kN32_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888", true }, | 1285 { kN32_SkColorType, kRaster_Backend, kDontCare_GLContextType,
0, kRW_ConfigFlag, "8888", true }, |
| (...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1468 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ
ation test pass."); | 1462 DEFINE_bool(serialize, false, "Exercise the SkPicture serialization & deserializ
ation test pass."); |
| 1469 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); | 1463 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); |
| 1470 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); | 1464 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); |
| 1471 DEFINE_bool(tileGrid, false, "Exercise the tile grid variant of SkPicture."); | 1465 DEFINE_bool(tileGrid, false, "Exercise the tile grid variant of SkPicture."); |
| 1472 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point
scale " | 1466 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point
scale " |
| 1473 "factors to be used for tileGrid playback testing. Default value:
1.0"); | 1467 "factors to be used for tileGrid playback testing. Default value:
1.0"); |
| 1474 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i
nfo about " | 1468 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i
nfo about " |
| 1475 "each test)."); | 1469 "each test)."); |
| 1476 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images,
use checksum-" | 1470 DEFINE_bool(writeChecksumBasedFilenames, false, "When writing out actual images,
use checksum-" |
| 1477 "based filenames, as rebaseline.py will use when downloading them fr
om Google Storage"); | 1471 "based filenames, as rebaseline.py will use when downloading them fr
om Google Storage"); |
| 1478 #ifdef SK_BUILD_JSON_WRITER | |
| 1479 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t
o this file."); | 1472 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t
o this file."); |
| 1480 #endif | |
| 1481 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); | 1473 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
| 1482 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.")
; | 1474 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.")
; |
| 1483 DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, " | 1475 DEFINE_int32(pdfJpegQuality, -1, "Encodes images in JPEG at quality level N, " |
| 1484 "which can be in range 0-100). N = -1 will disable JPEG compression
. " | 1476 "which can be in range 0-100). N = -1 will disable JPEG compression
. " |
| 1485 "Default is N = 100, maximum quality."); | 1477 "Default is N = 100, maximum quality."); |
| 1486 // TODO(edisonn): pass a matrix instead of forcePerspectiveMatrix | 1478 // TODO(edisonn): pass a matrix instead of forcePerspectiveMatrix |
| 1487 // Either the 9 numbers defining the matrix | 1479 // Either the 9 numbers defining the matrix |
| 1488 // or probably more readable would be to replace it with a set of a few predicat
es | 1480 // or probably more readable would be to replace it with a set of a few predicat
es |
| 1489 // Like --prerotate 100 200 10 --posttranslate 10, 10 | 1481 // Like --prerotate 100 200 10 --posttranslate 10, 10 |
| 1490 // Probably define spacial names like centerx, centery, top, bottom, left, right | 1482 // Probably define spacial names like centerx, centery, top, bottom, left, right |
| (...skipping 703 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2194 SkDebugf("readPath %s does not exist!\n", readPath); | 2186 SkDebugf("readPath %s does not exist!\n", readPath); |
| 2195 return false; | 2187 return false; |
| 2196 } | 2188 } |
| 2197 if (sk_isdir(readPath)) { | 2189 if (sk_isdir(readPath)) { |
| 2198 if (FLAGS_verbose) { | 2190 if (FLAGS_verbose) { |
| 2199 SkDebugf("reading from %s\n", readPath); | 2191 SkDebugf("reading from %s\n", readPath); |
| 2200 } | 2192 } |
| 2201 gmmain->fExpectationsSource.reset(SkNEW_ARGS( | 2193 gmmain->fExpectationsSource.reset(SkNEW_ARGS( |
| 2202 IndividualImageExpectationsSource, (readPath))); | 2194 IndividualImageExpectationsSource, (readPath))); |
| 2203 } else { | 2195 } else { |
| 2204 #ifdef SK_BUILD_JSON_WRITER | |
| 2205 if (FLAGS_verbose) { | 2196 if (FLAGS_verbose) { |
| 2206 SkDebugf("reading expectations from JSON summary file %s\n", rea
dPath); | 2197 SkDebugf("reading expectations from JSON summary file %s\n", rea
dPath); |
| 2207 } | 2198 } |
| 2208 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource,
(readPath))); | 2199 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource,
(readPath))); |
| 2209 #endif | |
| 2210 } | 2200 } |
| 2211 } | 2201 } |
| 2212 return true; | 2202 return true; |
| 2213 } | 2203 } |
| 2214 | 2204 |
| 2215 static bool parse_flags_resource_path() { | 2205 static bool parse_flags_resource_path() { |
| 2216 if (FLAGS_resourcePath.count() == 1) { | 2206 if (FLAGS_resourcePath.count() == 1) { |
| 2217 GM::SetResourcePath(FLAGS_resourcePath[0]); | 2207 GM::SetResourcePath(FLAGS_resourcePath[0]); |
| 2218 } | 2208 } |
| 2219 return true; | 2209 return true; |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2406 // https://code.google.com/p/skia/issues/detail?id=1222 | 2396 // https://code.google.com/p/skia/issues/detail?id=1222 |
| 2407 // ('GM is unexpectedly skipping tests on Android') | 2397 // ('GM is unexpectedly skipping tests on Android') |
| 2408 #ifndef SK_BUILD_FOR_ANDROID | 2398 #ifndef SK_BUILD_FOR_ANDROID |
| 2409 if (expectedNumberOfTests != gmmain.fTestsRun) { | 2399 if (expectedNumberOfTests != gmmain.fTestsRun) { |
| 2410 SkDebugf("expected %d tests, but ran or skipped %d tests\n", | 2400 SkDebugf("expected %d tests, but ran or skipped %d tests\n", |
| 2411 expectedNumberOfTests, gmmain.fTestsRun); | 2401 expectedNumberOfTests, gmmain.fTestsRun); |
| 2412 reportError = true; | 2402 reportError = true; |
| 2413 } | 2403 } |
| 2414 #endif | 2404 #endif |
| 2415 | 2405 |
| 2416 #ifdef SK_BUILD_JSON_WRITER | |
| 2417 if (FLAGS_writeJsonSummaryPath.count() == 1) { | 2406 if (FLAGS_writeJsonSummaryPath.count() == 1) { |
| 2418 Json::Value root = CreateJsonTree( | 2407 Json::Value root = CreateJsonTree( |
| 2419 gmmain.fJsonExpectedResults, | 2408 gmmain.fJsonExpectedResults, |
| 2420 gmmain.fJsonActualResults_Failed, gmmain.fJsonActualResults_FailureI
gnored, | 2409 gmmain.fJsonActualResults_Failed, gmmain.fJsonActualResults_FailureI
gnored, |
| 2421 gmmain.fJsonActualResults_NoComparison, gmmain.fJsonActualResults_Su
cceeded); | 2410 gmmain.fJsonActualResults_NoComparison, gmmain.fJsonActualResults_Su
cceeded); |
| 2422 std::string jsonStdString = root.toStyledString(); | 2411 std::string jsonStdString = root.toStyledString(); |
| 2423 SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); | 2412 SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); |
| 2424 stream.write(jsonStdString.c_str(), jsonStdString.length()); | 2413 stream.write(jsonStdString.c_str(), jsonStdString.length()); |
| 2425 } | 2414 } |
| 2426 #endif | |
| 2427 | 2415 |
| 2428 #if SK_SUPPORT_GPU | 2416 #if SK_SUPPORT_GPU |
| 2429 | 2417 |
| 2430 #if GR_CACHE_STATS | 2418 #if GR_CACHE_STATS |
| 2431 for (int i = 0; i < configs.count(); i++) { | 2419 for (int i = 0; i < configs.count(); i++) { |
| 2432 ConfigData config = gRec[configs[i]]; | 2420 ConfigData config = gRec[configs[i]]; |
| 2433 | 2421 |
| 2434 if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) { | 2422 if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) { |
| 2435 GrContext* gr = grFactory->get(config.fGLContextType); | 2423 GrContext* gr = grFactory->get(config.fGLContextType); |
| 2436 | 2424 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 2463 if (FLAGS_forceBWtext) { | 2451 if (FLAGS_forceBWtext) { |
| 2464 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2452 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2465 } | 2453 } |
| 2466 } | 2454 } |
| 2467 | 2455 |
| 2468 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2456 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2469 int main(int argc, char * const argv[]) { | 2457 int main(int argc, char * const argv[]) { |
| 2470 return tool_main(argc, (char**) argv); | 2458 return tool_main(argc, (char**) argv); |
| 2471 } | 2459 } |
| 2472 #endif | 2460 #endif |
| OLD | NEW |