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