| 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 * |
| 11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh | 11 * If you make changes to this, re-run the self-tests at gm/tests/run.sh |
| 12 * to make sure they still pass... you may need to change the expected | 12 * to make sure they still pass... you may need to change the expected |
| 13 * results of the self-test. | 13 * results of the self-test. |
| 14 */ | 14 */ |
| 15 | 15 |
| 16 #include "gm.h" | 16 #include "gm.h" |
| 17 #include "gm_expectations.h" | 17 #include "gm_expectations.h" |
| 18 #include "system_preferences.h" | 18 #include "system_preferences.h" |
| 19 #include "SkBitmap.h" | 19 #include "SkBitmap.h" |
| 20 #include "SkBitmapChecksummer.h" | 20 #include "SkBitmapChecksummer.h" |
| 21 #include "SkColorPriv.h" | 21 #include "SkColorPriv.h" |
| 22 #include "SkData.h" | 22 #include "SkData.h" |
| 23 #include "SkDeferredCanvas.h" | 23 #include "SkDeferredCanvas.h" |
| 24 #include "SkDevice.h" | 24 #include "SkDevice.h" |
| 25 #include "SkDrawFilter.h" | 25 #include "SkDrawFilter.h" |
| 26 #include "SkFlags.h" |
| 26 #include "SkGPipe.h" | 27 #include "SkGPipe.h" |
| 27 #include "SkGraphics.h" | 28 #include "SkGraphics.h" |
| 28 #include "SkImageDecoder.h" | 29 #include "SkImageDecoder.h" |
| 29 #include "SkImageEncoder.h" | 30 #include "SkImageEncoder.h" |
| 30 #include "SkOSFile.h" | 31 #include "SkOSFile.h" |
| 31 #include "SkPicture.h" | 32 #include "SkPicture.h" |
| 32 #include "SkRefCnt.h" | 33 #include "SkRefCnt.h" |
| 33 #include "SkStream.h" | 34 #include "SkStream.h" |
| 34 #include "SkTArray.h" | 35 #include "SkTArray.h" |
| 35 #include "SkTileGridPicture.h" | 36 #include "SkTileGridPicture.h" |
| (...skipping 14 matching lines...) Expand all Loading... |
| 50 #include "GrContextFactory.h" | 51 #include "GrContextFactory.h" |
| 51 #include "GrRenderTarget.h" | 52 #include "GrRenderTarget.h" |
| 52 #include "SkGpuDevice.h" | 53 #include "SkGpuDevice.h" |
| 53 typedef GrContextFactory::GLContextType GLContextType; | 54 typedef GrContextFactory::GLContextType GLContextType; |
| 54 #else | 55 #else |
| 55 class GrContext; | 56 class GrContext; |
| 56 class GrRenderTarget; | 57 class GrRenderTarget; |
| 57 typedef int GLContextType; | 58 typedef int GLContextType; |
| 58 #endif | 59 #endif |
| 59 | 60 |
| 60 static bool gForceBWtext; | |
| 61 | |
| 62 extern bool gSkSuppressFontCachePurgeSpew; | 61 extern bool gSkSuppressFontCachePurgeSpew; |
| 63 | 62 |
| 64 #ifdef SK_SUPPORT_PDF | 63 #ifdef SK_SUPPORT_PDF |
| 65 #include "SkPDFDevice.h" | 64 #include "SkPDFDevice.h" |
| 66 #include "SkPDFDocument.h" | 65 #include "SkPDFDocument.h" |
| 67 #endif | 66 #endif |
| 68 | 67 |
| 69 // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , | 68 // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , |
| 70 // stop writing out XPS-format image baselines in gm. | 69 // stop writing out XPS-format image baselines in gm. |
| 71 #undef SK_SUPPORT_XPS | 70 #undef SK_SUPPORT_XPS |
| (...skipping 284 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 356 * CON: Math is hard. | 355 * CON: Math is hard. |
| 357 * | 356 * |
| 358 * 4. Perform a "close enough" comparison of bitmaps (+/- 1 bit in each | 357 * 4. Perform a "close enough" comparison of bitmaps (+/- 1 bit in each |
| 359 * channel), rather than demanding absolute equality. | 358 * channel), rather than demanding absolute equality. |
| 360 * CON: Can't do this with checksums. | 359 * CON: Can't do this with checksums. |
| 361 */ | 360 */ |
| 362 static void complete_bitmap(SkBitmap* bitmap) { | 361 static void complete_bitmap(SkBitmap* bitmap) { |
| 363 force_all_opaque(*bitmap); | 362 force_all_opaque(*bitmap); |
| 364 } | 363 } |
| 365 | 364 |
| 366 static void installFilter(SkCanvas* canvas) { | 365 static void installFilter(SkCanvas* canvas); |
| 367 if (gForceBWtext) { | |
| 368 canvas->setDrawFilter(new BWTextDrawFilter)->unref(); | |
| 369 } | |
| 370 } | |
| 371 | 366 |
| 372 static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF, bool isDeferred)
{ | 367 static void invokeGM(GM* gm, SkCanvas* canvas, bool isPDF, bool isDeferred)
{ |
| 373 SkAutoCanvasRestore acr(canvas, true); | 368 SkAutoCanvasRestore acr(canvas, true); |
| 374 | 369 |
| 375 if (!isPDF) { | 370 if (!isPDF) { |
| 376 canvas->concat(gm->getInitialTransform()); | 371 canvas->concat(gm->getInitialTransform()); |
| 377 } | 372 } |
| 378 installFilter(canvas); | 373 installFilter(canvas); |
| 379 gm->setCanvasIsDeferred(isDeferred); | 374 gm->setCanvasIsDeferred(isDeferred); |
| 380 gm->draw(canvas); | 375 gm->draw(canvas); |
| (...skipping 624 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 #endif // defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU | 1000 #endif // defined(SK_SCALAR_IS_FLOAT) && SK_SUPPORT_GPU |
| 1006 #ifdef SK_SUPPORT_XPS | 1001 #ifdef SK_SUPPORT_XPS |
| 1007 /* At present we have no way of comparing XPS files (either natively or by c
onverting to PNG). */ | 1002 /* At present we have no way of comparing XPS files (either natively or by c
onverting to PNG). */ |
| 1008 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType,
0, kWrite_ConfigFlag, "xps" }, | 1003 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType,
0, kWrite_ConfigFlag, "xps" }, |
| 1009 #endif // SK_SUPPORT_XPS | 1004 #endif // SK_SUPPORT_XPS |
| 1010 #ifdef SK_SUPPORT_PDF | 1005 #ifdef SK_SUPPORT_PDF |
| 1011 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType,
0, kPDFConfigFlags, "pdf" }, | 1006 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType,
0, kPDFConfigFlags, "pdf" }, |
| 1012 #endif // SK_SUPPORT_PDF | 1007 #endif // SK_SUPPORT_PDF |
| 1013 }; | 1008 }; |
| 1014 | 1009 |
| 1015 static void usage(const char * argv0) { | 1010 static SkString configUsage() { |
| 1016 fprintf(stderr, "%s\n", argv0); | 1011 SkString result("Possible options for --config: ["); |
| 1017 fprintf(stderr, " [--config "); | |
| 1018 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1012 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 1019 if (i > 0) { | 1013 if (i > 0) { |
| 1020 fprintf(stderr, "|"); | 1014 result.appendf("|"); |
| 1021 } | 1015 } |
| 1022 fprintf(stderr, "%s", gRec[i].fName); | 1016 result.appendf("%s", gRec[i].fName); |
| 1023 } | 1017 } |
| 1024 fprintf(stderr, "]:\n run these configurations\n"); | 1018 result.appendf("]"); |
| 1025 fprintf(stderr, | 1019 return result; |
| 1020 } |
| 1021 |
| 1026 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). | 1022 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). |
| 1027 // It would probably be better if we allowed both yes-and-no settings for each | 1023 DEFINE_string(config, "", "Space delimited list of which configs to run. " |
| 1028 // one, e.g.: | 1024 "Possible configs listed above. If none are specified, " |
| 1029 // [--replay|--noreplay]: whether to exercise SkPicture replay; default is yes | 1025 "all will be run."); |
| 1030 " [--nodeferred]: skip the deferred rendering test pass\n" | 1026 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); |
| 1031 " [--disable-missing-warning]: don't print a message to stderr if\n" | 1027 DEFINE_bool(enableMissingWarning, true, "Print message to stderr (but don't fail
) if " |
| 1032 " unable to read a reference image for any tests (NOT default behavior)\n
" | 1028 "unable to read a reference image for any tests."); |
| 1033 " [--enable-missing-warning]: print message to stderr (but don't fail) if\n" | 1029 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); |
| 1034 " unable to read a reference image for any tests (default behavior)\n" | 1030 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); |
| 1035 " [--exclude-config]: disable this config (may be used multiple times)\n" | 1031 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si
ze or " |
| 1036 " [--forceBWtext]: disable text anti-aliasing\n" | 1032 "object count. -1 for either value means use the default. 0 for ei
ther " |
| 1037 #if SK_SUPPORT_GPU | 1033 "disables the cache."); |
| 1038 " [--gpuCacheSize <bytes> <count>]: limits gpu cache to byte size or object c
ount\n" | 1034 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " |
| 1039 " -1 for either value means use the default. 0 for either disables the ca
che.\n" | 1035 "when reading/writing files."); |
| 1040 #endif | 1036 DEFINE_string(match, "", "Only run tests whose name includes this substring/the
se substrings " |
| 1041 " [--help|-h]: show this help message\n" | 1037 "(more than one can be supplied, separated by spaces)."); |
| 1042 " [--hierarchy|--nohierarchy]: whether to use multilevel directory structure\
n" | 1038 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " |
| 1043 " when reading/writing files; default is no\n" | 1039 "pixel mismatches into this directory."); |
| 1044 " [--match <substring>]: only run tests whose name includes this substring\n" | 1040 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " |
| 1045 " [--mismatchPath <path>]: write images for tests that failed due to\n" | 1041 "testIndex %% divisor == remainder."); |
| 1046 " pixel mismatched into this directory" | 1042 DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass."); |
| 1047 " [--modulo <remainder> <divisor>]: only run tests for which \n" | 1043 DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass."); |
| 1048 " testIndex %% divisor == remainder\n" | 1044 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report
" |
| 1049 " [--nopdf]: skip the pdf rendering test pass\n" | 1045 "any differences between those and the newly generated ones."); |
| 1050 " [--nopipe]: Skip SkGPipe replay\n" | 1046 DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass."); |
| 1051 " [--readPath|-r <path>]: read reference images from this dir, and report\n" | 1047 DEFINE_string2(resourcePath, i, "", "Directory that stores image resources."); |
| 1052 " any differences between those and the newly generated ones\n" | 1048 DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass."); |
| 1053 " [--noreplay]: do not exercise SkPicture replay\n" | 1049 DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserializa
tion test pass."); |
| 1054 " [--resourcePath|-i <path>]: directory that stores image resources\n" | 1050 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); |
| 1055 " [--nortree]: Do not exercise the R-Tree variant of SkPicture\n" | 1051 DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture."); |
| 1056 " [--noserialize]: do not exercise SkPicture serialization & deserialization\
n" | 1052 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point
scale " |
| 1057 " [--tiledPipe]: Exercise tiled SkGPipe replay\n" | 1053 "factors to be used for tileGrid playback testing. Default value:
1.0"); |
| 1058 " [--notileGrid]: Do not exercise the tile grid variant of SkPicture\n" | 1054 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t
o this file."); |
| 1059 " [--tileGridReplayScales <scales>]: Comma separated list of floating-point s
cale\n" | 1055 DEFINE_bool2(verbose, v, false, "Print diagnostics (e.g. list each config to be
tested)."); |
| 1060 " factors to be used for tileGrid playback testing. Default value: 1.0\n" | 1056 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
| 1061 " [--writeJsonSummary <path>]: write a JSON-formatted result summary to this
file\n" | 1057 DEFINE_string2(writePicturePath, wp, "", "Write .skp files into this directory."
); |
| 1062 " [--verbose] print diagnostics (e.g. list each config to be tested)\n" | |
| 1063 " [--writePath|-w <path>]: write rendered images into this directory\n" | |
| 1064 " [--writePicturePath|-wp <path>]: write .skp files into this directory\n" | |
| 1065 ); | |
| 1066 } | |
| 1067 | 1058 |
| 1068 static int findConfig(const char config[]) { | 1059 static int findConfig(const char config[]) { |
| 1069 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { | 1060 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
| 1070 if (!strcmp(config, gRec[i].fName)) { | 1061 if (!strcmp(config, gRec[i].fName)) { |
| 1071 return i; | 1062 return i; |
| 1072 } | 1063 } |
| 1073 } | 1064 } |
| 1074 return -1; | 1065 return -1; |
| 1075 } | 1066 } |
| 1076 | 1067 |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1143 gPrintInstCount = true; | 1134 gPrintInstCount = true; |
| 1144 #endif | 1135 #endif |
| 1145 | 1136 |
| 1146 SkGraphics::Init(); | 1137 SkGraphics::Init(); |
| 1147 // we don't need to see this during a run | 1138 // we don't need to see this during a run |
| 1148 gSkSuppressFontCachePurgeSpew = true; | 1139 gSkSuppressFontCachePurgeSpew = true; |
| 1149 | 1140 |
| 1150 setSystemPreferences(); | 1141 setSystemPreferences(); |
| 1151 GMMain gmmain; | 1142 GMMain gmmain; |
| 1152 | 1143 |
| 1153 const char* writeJsonSummaryPath = NULL;// if non-null, where we write the J
SON summary | |
| 1154 const char* writePath = NULL; // if non-null, where we write the originals | |
| 1155 const char* writePicturePath = NULL; // if non-null, where we write seria
lized pictures | |
| 1156 const char* readPath = NULL; // if non-null, were we read from to compare | |
| 1157 const char* resourcePath = NULL;// if non-null, where we read from for image
resources | |
| 1158 | |
| 1159 // if true, emit a message when we can't find a reference image to compare | |
| 1160 bool notifyMissingReadReference = true; | |
| 1161 | |
| 1162 SkTDArray<const char*> fMatches; | |
| 1163 | |
| 1164 bool doPDF = true; | |
| 1165 bool doReplay = true; | |
| 1166 bool doPipe = true; | |
| 1167 bool doTiledPipe = false; | |
| 1168 bool doSerialize = true; | |
| 1169 bool doDeferred = true; | |
| 1170 bool doRTree = true; | |
| 1171 bool doTileGrid = true; | |
| 1172 bool doVerbose = false; | |
| 1173 | |
| 1174 SkTDArray<size_t> configs; | 1144 SkTDArray<size_t> configs; |
| 1175 SkTDArray<size_t> excludeConfigs; | 1145 SkTDArray<size_t> excludeConfigs; |
| 1176 SkTDArray<SkScalar> tileGridReplayScales; | 1146 SkTDArray<SkScalar> tileGridReplayScales; |
| 1177 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal
e 1.0 | 1147 *tileGridReplayScales.append() = SK_Scalar1; // By default only test at scal
e 1.0 |
| 1178 bool userConfig = false; | 1148 bool userConfig = false; |
| 1179 | 1149 |
| 1180 int moduloRemainder = -1; | 1150 SkString usage; |
| 1181 int moduloDivisor = -1; | 1151 usage.printf("Run the golden master tests.\n\t%s", configUsage().c_str()); |
| 1152 SkFlags::SetUsage(usage.c_str()); |
| 1153 SkFlags::ParseCommandLine(argc, argv); |
| 1182 | 1154 |
| 1183 #if SK_SUPPORT_GPU | |
| 1184 struct { | 1155 struct { |
| 1185 int fBytes; | 1156 int fBytes; |
| 1186 int fCount; | 1157 int fCount; |
| 1187 } gpuCacheSize = { -1, -1 }; // -1s mean use the default | 1158 } gpuCacheSize = { -1, -1 }; // -1s mean use the default |
| 1188 #endif | |
| 1189 | 1159 |
| 1190 const char* const commandName = argv[0]; | 1160 if (FLAGS_gpuCacheSize.count() > 0) { |
| 1191 char* const* stop = argv + argc; | 1161 if (FLAGS_gpuCacheSize.count() != 2) { |
| 1192 for (++argv; argv < stop; ++argv) { | 1162 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); |
| 1193 if (strcmp(*argv, "--config") == 0) { | |
| 1194 argv++; | |
| 1195 if (argv < stop) { | |
| 1196 int index = findConfig(*argv); | |
| 1197 if (index >= 0) { | |
| 1198 appendUnique<size_t>(&configs, index); | |
| 1199 userConfig = true; | |
| 1200 } else { | |
| 1201 gm_fprintf(stderr, "unrecognized config %s\n", *argv); | |
| 1202 usage(commandName); | |
| 1203 return -1; | |
| 1204 } | |
| 1205 } else { | |
| 1206 gm_fprintf(stderr, "missing arg for --config\n"); | |
| 1207 usage(commandName); | |
| 1208 return -1; | |
| 1209 } | |
| 1210 } else if (strcmp(*argv, "--exclude-config") == 0) { | |
| 1211 argv++; | |
| 1212 if (argv < stop) { | |
| 1213 int index = findConfig(*argv); | |
| 1214 if (index >= 0) { | |
| 1215 *excludeConfigs.append() = index; | |
| 1216 } else { | |
| 1217 gm_fprintf(stderr, "unrecognized exclude-config %s\n", *argv
); | |
| 1218 usage(commandName); | |
| 1219 return -1; | |
| 1220 } | |
| 1221 } else { | |
| 1222 gm_fprintf(stderr, "missing arg for --exclude-config\n"); | |
| 1223 usage(commandName); | |
| 1224 return -1; | |
| 1225 } | |
| 1226 } else if (strcmp(*argv, "--nodeferred") == 0) { | |
| 1227 doDeferred = false; | |
| 1228 } else if (strcmp(*argv, "--disable-missing-warning") == 0) { | |
| 1229 notifyMissingReadReference = false; | |
| 1230 } else if (strcmp(*argv, "--mismatchPath") == 0) { | |
| 1231 argv++; | |
| 1232 if (argv < stop && **argv) { | |
| 1233 gmmain.fMismatchPath = *argv; | |
| 1234 } | |
| 1235 } else if (strcmp(*argv, "--nortree") == 0) { | |
| 1236 doRTree = false; | |
| 1237 } else if (strcmp(*argv, "--notileGrid") == 0) { | |
| 1238 doTileGrid = false; | |
| 1239 } else if (strcmp(*argv, "--tileGridReplayScales") == 0) { | |
| 1240 tileGridReplayScales.reset(); | |
| 1241 ++argv; | |
| 1242 if (argv < stop) { | |
| 1243 char* token = strtok(*argv, ","); | |
| 1244 while (NULL != token) { | |
| 1245 double val = atof(token); | |
| 1246 if (0 < val) { | |
| 1247 *tileGridReplayScales.append() = SkDoubleToScalar(val); | |
| 1248 } | |
| 1249 token = strtok(NULL, ","); | |
| 1250 } | |
| 1251 } | |
| 1252 if (0 == tileGridReplayScales.count()) { | |
| 1253 // Should have at least one scale | |
| 1254 usage(commandName); | |
| 1255 return -1; | |
| 1256 } | |
| 1257 } else if (strcmp(*argv, "--enable-missing-warning") == 0) { | |
| 1258 notifyMissingReadReference = true; | |
| 1259 } else if (strcmp(*argv, "--forceBWtext") == 0) { | |
| 1260 gForceBWtext = true; | |
| 1261 #if SK_SUPPORT_GPU | |
| 1262 } else if (strcmp(*argv, "--gpuCacheSize") == 0) { | |
| 1263 if (stop - argv > 2) { | |
| 1264 gpuCacheSize.fBytes = atoi(*++argv); | |
| 1265 gpuCacheSize.fCount = atoi(*++argv); | |
| 1266 } else { | |
| 1267 gm_fprintf(stderr, "missing arg for --gpuCacheSize\n"); | |
| 1268 usage(commandName); | |
| 1269 return -1; | |
| 1270 } | |
| 1271 #endif | |
| 1272 } else if (strcmp(*argv, "--help") == 0 || strcmp(*argv, "-h") == 0) { | |
| 1273 usage(commandName); | |
| 1274 return -1; | 1163 return -1; |
| 1275 } else if (strcmp(*argv, "--hierarchy") == 0) { | 1164 } |
| 1276 gmmain.fUseFileHierarchy = true; | 1165 gpuCacheSize.fBytes = atoi(FLAGS_gpuCacheSize[0]); |
| 1277 } else if (strcmp(*argv, "--nohierarchy") == 0) { | 1166 gpuCacheSize.fCount = atoi(FLAGS_gpuCacheSize[1]); |
| 1278 gmmain.fUseFileHierarchy = false; | 1167 } |
| 1279 } else if (strcmp(*argv, "--match") == 0) { | |
| 1280 ++argv; | |
| 1281 if (argv < stop && **argv) { | |
| 1282 // just record the ptr, no need for a deep copy | |
| 1283 *fMatches.append() = *argv; | |
| 1284 } | |
| 1285 } else if (strcmp(*argv, "--modulo") == 0) { | |
| 1286 ++argv; | |
| 1287 if (argv >= stop) { | |
| 1288 continue; | |
| 1289 } | |
| 1290 moduloRemainder = atoi(*argv); | |
| 1291 | 1168 |
| 1292 ++argv; | 1169 gmmain.fUseFileHierarchy = FLAGS_hierarchy; |
| 1293 if (argv >= stop) { | 1170 if (FLAGS_mismatchPath.count() == 1) { |
| 1294 continue; | 1171 gmmain.fMismatchPath = FLAGS_mismatchPath[0]; |
| 1295 } | 1172 } |
| 1296 moduloDivisor = atoi(*argv); | 1173 |
| 1297 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >=
moduloDivisor) { | 1174 for (int i = 0; i < FLAGS_config.count(); i++) { |
| 1298 gm_fprintf(stderr, "invalid modulo values."); | 1175 int index = findConfig(FLAGS_config[i]); |
| 1299 return -1; | 1176 if (index >= 0) { |
| 1300 } | 1177 appendUnique<size_t>(&configs, index); |
| 1301 } else if (strcmp(*argv, "--nopdf") == 0) { | 1178 userConfig = true; |
| 1302 doPDF = false; | |
| 1303 } else if (strcmp(*argv, "--nopipe") == 0) { | |
| 1304 doPipe = false; | |
| 1305 } else if ((0 == strcmp(*argv, "--readPath")) || | |
| 1306 (0 == strcmp(*argv, "-r"))) { | |
| 1307 argv++; | |
| 1308 if (argv < stop && **argv) { | |
| 1309 readPath = *argv; | |
| 1310 } | |
| 1311 } else if (strcmp(*argv, "--noreplay") == 0) { | |
| 1312 doReplay = false; | |
| 1313 } else if ((0 == strcmp(*argv, "--resourcePath")) || | |
| 1314 (0 == strcmp(*argv, "-i"))) { | |
| 1315 argv++; | |
| 1316 if (argv < stop && **argv) { | |
| 1317 resourcePath = *argv; | |
| 1318 } | |
| 1319 } else if (strcmp(*argv, "--serialize") == 0) { | |
| 1320 doSerialize = true; | |
| 1321 } else if (strcmp(*argv, "--noserialize") == 0) { | |
| 1322 doSerialize = false; | |
| 1323 } else if (strcmp(*argv, "--tiledPipe") == 0) { | |
| 1324 doTiledPipe = true; | |
| 1325 } else if (!strcmp(*argv, "--verbose") || !strcmp(*argv, "-v")) { | |
| 1326 doVerbose = true; | |
| 1327 } else if ((0 == strcmp(*argv, "--writePath")) || | |
| 1328 (0 == strcmp(*argv, "-w"))) { | |
| 1329 argv++; | |
| 1330 if (argv < stop && **argv) { | |
| 1331 writePath = *argv; | |
| 1332 } | |
| 1333 } else if (0 == strcmp(*argv, "--writeJsonSummary")) { | |
| 1334 argv++; | |
| 1335 if (argv < stop && **argv) { | |
| 1336 writeJsonSummaryPath = *argv; | |
| 1337 } | |
| 1338 } else if ((0 == strcmp(*argv, "--writePicturePath")) || | |
| 1339 (0 == strcmp(*argv, "-wp"))) { | |
| 1340 argv++; | |
| 1341 if (argv < stop && **argv) { | |
| 1342 writePicturePath = *argv; | |
| 1343 } | |
| 1344 } else { | 1179 } else { |
| 1345 usage(commandName); | 1180 gm_fprintf(stderr, "unrecognized config %s\n", FLAGS_config[i]); |
| 1346 return -1; | 1181 return -1; |
| 1347 } | 1182 } |
| 1348 } | 1183 } |
| 1349 if (argv != stop) { | 1184 |
| 1350 usage(commandName); | 1185 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { |
| 1351 return -1; | 1186 int index = findConfig(FLAGS_excludeConfig[i]); |
| 1187 if (index >= 0) { |
| 1188 *excludeConfigs.append() = index; |
| 1189 } else { |
| 1190 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC
onfig[i]); |
| 1191 return -1; |
| 1192 } |
| 1193 } |
| 1194 |
| 1195 if (FLAGS_tileGridReplayScales.count() > 0) { |
| 1196 tileGridReplayScales.reset(); |
| 1197 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { |
| 1198 double val = atof(FLAGS_tileGridReplayScales[i]); |
| 1199 if (0 < val) { |
| 1200 *tileGridReplayScales.append() = SkDoubleToScalar(val); |
| 1201 } |
| 1202 } |
| 1203 if (0 == tileGridReplayScales.count()) { |
| 1204 // Should have at least one scale |
| 1205 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca
le.\n"); |
| 1206 return -1; |
| 1207 } |
| 1208 } |
| 1209 |
| 1210 int moduloRemainder = -1; |
| 1211 int moduloDivisor = -1; |
| 1212 |
| 1213 if (FLAGS_modulo.count() == 2) { |
| 1214 moduloRemainder = atoi(FLAGS_modulo[0]); |
| 1215 moduloDivisor = atoi(FLAGS_modulo[1]); |
| 1216 if (moduloRemainder < 0 || moduloDivisor <= 0 || moduloRemainder >= modu
loDivisor) { |
| 1217 gm_fprintf(stderr, "invalid modulo values."); |
| 1218 return -1; |
| 1219 } |
| 1352 } | 1220 } |
| 1353 | 1221 |
| 1354 if (!userConfig) { | 1222 if (!userConfig) { |
| 1355 // if no config is specified by user, we add them all. | 1223 // if no config is specified by user, we add them all. |
| 1356 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1224 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 1357 *configs.append() = i; | 1225 *configs.append() = i; |
| 1358 } | 1226 } |
| 1359 } | 1227 } |
| 1360 // now remove any explicitly excluded configs | 1228 // now remove any explicitly excluded configs |
| 1361 for (int i = 0; i < excludeConfigs.count(); ++i) { | 1229 for (int i = 0; i < excludeConfigs.count(); ++i) { |
| 1362 int index = configs.find(excludeConfigs[i]); | 1230 int index = configs.find(excludeConfigs[i]); |
| 1363 if (index >= 0) { | 1231 if (index >= 0) { |
| 1364 configs.remove(index); | 1232 configs.remove(index); |
| 1365 // now assert that there was only one copy in configs[] | 1233 // now assert that there was only one copy in configs[] |
| 1366 SkASSERT(configs.find(excludeConfigs[i]) < 0); | 1234 SkASSERT(configs.find(excludeConfigs[i]) < 0); |
| 1367 } | 1235 } |
| 1368 } | 1236 } |
| 1369 | 1237 |
| 1370 if (doVerbose) { | 1238 if (FLAGS_verbose) { |
| 1371 SkString str; | 1239 SkString str; |
| 1372 str.printf("%d configs:", configs.count()); | 1240 str.printf("%d configs:", configs.count()); |
| 1373 for (int i = 0; i < configs.count(); ++i) { | 1241 for (int i = 0; i < configs.count(); ++i) { |
| 1374 str.appendf(" %s", gRec[configs[i]].fName); | 1242 str.appendf(" %s", gRec[configs[i]].fName); |
| 1375 } | 1243 } |
| 1376 gm_fprintf(stderr, "%s\n", str.c_str()); | 1244 gm_fprintf(stderr, "%s\n", str.c_str()); |
| 1377 } | 1245 } |
| 1378 | 1246 |
| 1379 GM::SetResourcePath(resourcePath); | 1247 if (FLAGS_resourcePath.count() == 1) { |
| 1248 GM::SetResourcePath(FLAGS_resourcePath[0]); |
| 1249 } |
| 1380 | 1250 |
| 1381 if (readPath) { | 1251 if (FLAGS_readPath.count() == 1) { |
| 1252 const char* readPath = FLAGS_readPath[0]; |
| 1382 if (!sk_exists(readPath)) { | 1253 if (!sk_exists(readPath)) { |
| 1383 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); | 1254 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); |
| 1384 return -1; | 1255 return -1; |
| 1385 } | 1256 } |
| 1386 if (sk_isdir(readPath)) { | 1257 if (sk_isdir(readPath)) { |
| 1387 gm_fprintf(stdout, "reading from %s\n", readPath); | 1258 gm_fprintf(stdout, "reading from %s\n", readPath); |
| 1388 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1259 gmmain.fExpectationsSource.reset(SkNEW_ARGS( |
| 1389 IndividualImageExpectationsSource, | 1260 IndividualImageExpectationsSource, |
| 1390 (readPath, notifyMissingReadReference))); | 1261 (readPath, FLAGS_enableMissingWarning))); |
| 1391 } else { | 1262 } else { |
| 1392 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n
", readPath); | 1263 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n
", readPath); |
| 1393 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1264 gmmain.fExpectationsSource.reset(SkNEW_ARGS( |
| 1394 JsonExpectationsSource, (readPath))); | 1265 JsonExpectationsSource, (readPath))); |
| 1395 } | 1266 } |
| 1396 } | 1267 } |
| 1397 if (writePath) { | 1268 if (FLAGS_writePath.count() == 1) { |
| 1398 gm_fprintf(stdout, "writing to %s\n", writePath); | 1269 gm_fprintf(stderr, "writing to %s\n", FLAGS_writePath[0]); |
| 1399 } | 1270 } |
| 1400 if (writePicturePath) { | 1271 if (FLAGS_writePicturePath.count() == 1) { |
| 1401 gm_fprintf(stdout, "writing pictures to %s\n", writePicturePath); | 1272 gm_fprintf(stderr, "writing pictures to %s\n", FLAGS_writePicturePath[0]
); |
| 1402 } | 1273 } |
| 1403 if (resourcePath) { | 1274 if (FLAGS_resourcePath.count() == 1) { |
| 1404 gm_fprintf(stdout, "reading resources from %s\n", resourcePath); | 1275 gm_fprintf(stderr, "reading resources from %s\n", FLAGS_resourcePath[0])
; |
| 1405 } | 1276 } |
| 1406 | 1277 |
| 1407 if (moduloDivisor <= 0) { | 1278 if (moduloDivisor <= 0) { |
| 1408 moduloRemainder = -1; | 1279 moduloRemainder = -1; |
| 1409 } | 1280 } |
| 1410 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { | 1281 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { |
| 1411 moduloRemainder = -1; | 1282 moduloRemainder = -1; |
| 1412 } | 1283 } |
| 1413 | 1284 |
| 1414 // Accumulate success of all tests. | 1285 // Accumulate success of all tests. |
| 1415 int testsRun = 0; | 1286 int testsRun = 0; |
| 1416 int testsPassed = 0; | 1287 int testsPassed = 0; |
| 1417 int testsFailed = 0; | 1288 int testsFailed = 0; |
| 1418 int testsMissingReferenceImages = 0; | 1289 int testsMissingReferenceImages = 0; |
| 1419 | 1290 |
| 1420 #if SK_SUPPORT_GPU | 1291 #if SK_SUPPORT_GPU |
| 1421 GrContextFactory* grFactory = new GrContextFactory; | 1292 GrContextFactory* grFactory = new GrContextFactory; |
| 1422 #endif | 1293 #endif |
| 1423 | 1294 |
| 1424 int gmIndex = -1; | 1295 int gmIndex = -1; |
| 1425 SkString moduloStr; | 1296 SkString moduloStr; |
| 1426 | 1297 |
| 1427 // If we will be writing out files, prepare subdirectories. | 1298 // If we will be writing out files, prepare subdirectories. |
| 1428 if (writePath) { | 1299 if (FLAGS_writePath.count() == 1) { |
| 1429 if (!sk_mkdir(writePath)) { | 1300 if (!sk_mkdir(FLAGS_writePath[0])) { |
| 1430 return -1; | 1301 return -1; |
| 1431 } | 1302 } |
| 1432 if (gmmain.fUseFileHierarchy) { | 1303 if (gmmain.fUseFileHierarchy) { |
| 1433 for (int i = 0; i < configs.count(); i++) { | 1304 for (int i = 0; i < configs.count(); i++) { |
| 1434 ConfigData config = gRec[configs[i]]; | 1305 ConfigData config = gRec[configs[i]]; |
| 1435 SkString subdir; | 1306 SkString subdir; |
| 1436 subdir.appendf("%s%c%s", writePath, SkPATH_SEPARATOR, | 1307 subdir.appendf("%s%c%s", FLAGS_writePath[0], SkPATH_SEPARATOR, |
| 1437 config.fName); | 1308 config.fName); |
| 1438 if (!sk_mkdir(subdir.c_str())) { | 1309 if (!sk_mkdir(subdir.c_str())) { |
| 1439 return -1; | 1310 return -1; |
| 1440 } | 1311 } |
| 1441 } | 1312 } |
| 1442 } | 1313 } |
| 1443 } | 1314 } |
| 1444 | 1315 |
| 1445 Iter iter; | 1316 Iter iter; |
| 1446 GM* gm; | 1317 GM* gm; |
| 1447 while ((gm = iter.next()) != NULL) { | 1318 while ((gm = iter.next()) != NULL) { |
| 1448 | 1319 |
| 1449 ++gmIndex; | 1320 ++gmIndex; |
| 1450 if (moduloRemainder >= 0) { | 1321 if (moduloRemainder >= 0) { |
| 1451 if ((gmIndex % moduloDivisor) != moduloRemainder) { | 1322 if ((gmIndex % moduloDivisor) != moduloRemainder) { |
| 1452 continue; | 1323 continue; |
| 1453 } | 1324 } |
| 1454 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); | 1325 moduloStr.printf("[%d.%d] ", gmIndex, moduloDivisor); |
| 1455 } | 1326 } |
| 1456 | 1327 |
| 1457 const char* shortName = gm->shortName(); | 1328 const char* shortName = gm->shortName(); |
| 1458 if (skip_name(fMatches, shortName)) { | 1329 if (skip_name(FLAGS_match, shortName)) { |
| 1459 SkDELETE(gm); | 1330 SkDELETE(gm); |
| 1460 continue; | 1331 continue; |
| 1461 } | 1332 } |
| 1462 | 1333 |
| 1463 SkISize size = gm->getISize(); | 1334 SkISize size = gm->getISize(); |
| 1464 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, | 1335 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, |
| 1465 size.width(), size.height()); | 1336 size.width(), size.height()); |
| 1466 | 1337 |
| 1467 ErrorBitfield testErrors = kEmptyErrorBitfield; | 1338 ErrorBitfield testErrors = kEmptyErrorBitfield; |
| 1468 uint32_t gmFlags = gm->getFlags(); | 1339 uint32_t gmFlags = gm->getFlags(); |
| 1469 | 1340 |
| 1470 for (int i = 0; i < configs.count(); i++) { | 1341 for (int i = 0; i < configs.count(); i++) { |
| 1471 ConfigData config = gRec[configs[i]]; | 1342 ConfigData config = gRec[configs[i]]; |
| 1472 | 1343 |
| 1473 // Skip any tests that we don't even need to try. | 1344 // Skip any tests that we don't even need to try. |
| 1474 if ((kPDF_Backend == config.fBackend) && | 1345 if ((kPDF_Backend == config.fBackend) && |
| 1475 (!doPDF || (gmFlags & GM::kSkipPDF_Flag))) | 1346 (!FLAGS_pdf|| (gmFlags & GM::kSkipPDF_Flag))) |
| 1476 { | 1347 { |
| 1477 continue; | 1348 continue; |
| 1478 } | 1349 } |
| 1479 if ((gmFlags & GM::kSkip565_Flag) && | 1350 if ((gmFlags & GM::kSkip565_Flag) && |
| 1480 (kRaster_Backend == config.fBackend) && | 1351 (kRaster_Backend == config.fBackend) && |
| 1481 (SkBitmap::kRGB_565_Config == config.fConfig)) { | 1352 (SkBitmap::kRGB_565_Config == config.fConfig)) { |
| 1482 continue; | 1353 continue; |
| 1483 } | 1354 } |
| 1484 if ((gmFlags & GM::kSkipGPU_Flag) && | 1355 if ((gmFlags & GM::kSkipGPU_Flag) && |
| 1485 kGPU_Backend == config.fBackend) { | 1356 kGPU_Backend == config.fBackend) { |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1527 gr->setTextureCacheLimits(count, bytes); | 1398 gr->setTextureCacheLimits(count, bytes); |
| 1528 } | 1399 } |
| 1529 if (!grSuccess) { | 1400 if (!grSuccess) { |
| 1530 renderErrors |= kNoGpuContext_ErrorBitmask; | 1401 renderErrors |= kNoGpuContext_ErrorBitmask; |
| 1531 } | 1402 } |
| 1532 } | 1403 } |
| 1533 #endif | 1404 #endif |
| 1534 | 1405 |
| 1535 SkBitmap comparisonBitmap; | 1406 SkBitmap comparisonBitmap; |
| 1536 | 1407 |
| 1408 const char* writePath; |
| 1409 if (FLAGS_writePath.count() == 1) { |
| 1410 writePath = FLAGS_writePath[0]; |
| 1411 } else { |
| 1412 writePath = NULL; |
| 1413 } |
| 1537 if (kEmptyErrorBitfield == renderErrors) { | 1414 if (kEmptyErrorBitfield == renderErrors) { |
| 1538 renderErrors |= gmmain.test_drawing(gm, config, writePath, | 1415 renderErrors |= gmmain.test_drawing(gm, config, writePath, |
| 1539 GetGr(), | 1416 GetGr(), |
| 1540 renderTarget, | 1417 renderTarget, |
| 1541 &comparisonBitmap); | 1418 &comparisonBitmap); |
| 1542 } | 1419 } |
| 1543 | 1420 |
| 1544 if (doDeferred && !renderErrors && | 1421 if (FLAGS_deferred && !renderErrors && |
| 1545 (kGPU_Backend == config.fBackend || | 1422 (kGPU_Backend == config.fBackend || |
| 1546 kRaster_Backend == config.fBackend)) { | 1423 kRaster_Backend == config.fBackend)) { |
| 1547 renderErrors |= gmmain.test_deferred_drawing(gm, config, | 1424 renderErrors |= gmmain.test_deferred_drawing(gm, config, |
| 1548 comparisonBitmap, | 1425 comparisonBitmap, |
| 1549 GetGr(), | 1426 GetGr(), |
| 1550 renderTarget); | 1427 renderTarget); |
| 1551 } | 1428 } |
| 1552 | 1429 |
| 1553 testErrors |= renderErrors; | 1430 testErrors |= renderErrors; |
| 1554 } | 1431 } |
| 1555 | 1432 |
| 1556 SkBitmap comparisonBitmap; | 1433 SkBitmap comparisonBitmap; |
| 1557 const ConfigData compareConfig = | 1434 const ConfigData compareConfig = |
| 1558 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT
ype, 0, kRW_ConfigFlag, "comparison" }; | 1435 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT
ype, 0, kRW_ConfigFlag, "comparison" }; |
| 1559 testErrors |= gmmain.generate_image(gm, compareConfig, NULL, NULL, &comp
arisonBitmap, false); | 1436 testErrors |= gmmain.generate_image(gm, compareConfig, NULL, NULL, &comp
arisonBitmap, false); |
| 1560 | 1437 |
| 1561 // run the picture centric GM steps | 1438 // run the picture centric GM steps |
| 1562 if (!(gmFlags & GM::kSkipPicture_Flag)) { | 1439 if (!(gmFlags & GM::kSkipPicture_Flag)) { |
| 1563 | 1440 |
| 1564 ErrorBitfield pictErrors = kEmptyErrorBitfield; | 1441 ErrorBitfield pictErrors = kEmptyErrorBitfield; |
| 1565 | 1442 |
| 1566 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); | 1443 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); |
| 1567 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); | 1444 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); |
| 1568 SkAutoUnref aur(pict); | 1445 SkAutoUnref aur(pict); |
| 1569 | 1446 |
| 1570 if ((kEmptyErrorBitfield == testErrors) && doReplay) { | 1447 if ((kEmptyErrorBitfield == testErrors) && FLAGS_replay) { |
| 1571 SkBitmap bitmap; | 1448 SkBitmap bitmap; |
| 1572 gmmain.generate_image_from_picture(gm, compareConfig, pict, | 1449 gmmain.generate_image_from_picture(gm, compareConfig, pict, |
| 1573 &bitmap); | 1450 &bitmap); |
| 1574 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | 1451 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( |
| 1575 gm, compareConfig, "-replay", bitmap, &comparisonBitmap); | 1452 gm, compareConfig, "-replay", bitmap, &comparisonBitmap); |
| 1576 } | 1453 } |
| 1577 | 1454 |
| 1578 if ((kEmptyErrorBitfield == testErrors) && | 1455 if ((kEmptyErrorBitfield == testErrors) && |
| 1579 (kEmptyErrorBitfield == pictErrors) && | 1456 (kEmptyErrorBitfield == pictErrors) && |
| 1580 doSerialize) { | 1457 FLAGS_serialize) { |
| 1581 SkPicture* repict = gmmain.stream_to_new_picture(*pict); | 1458 SkPicture* repict = gmmain.stream_to_new_picture(*pict); |
| 1582 SkAutoUnref aurr(repict); | 1459 SkAutoUnref aurr(repict); |
| 1583 | 1460 |
| 1584 SkBitmap bitmap; | 1461 SkBitmap bitmap; |
| 1585 gmmain.generate_image_from_picture(gm, compareConfig, repict, | 1462 gmmain.generate_image_from_picture(gm, compareConfig, repict, |
| 1586 &bitmap); | 1463 &bitmap); |
| 1587 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( | 1464 pictErrors |= gmmain.compare_test_results_to_reference_bitmap( |
| 1588 gm, compareConfig, "-serialize", bitmap, &comparisonBitmap); | 1465 gm, compareConfig, "-serialize", bitmap, &comparisonBitmap); |
| 1589 } | 1466 } |
| 1590 | 1467 |
| 1591 if (writePicturePath) { | 1468 if (FLAGS_writePicturePath.count() == 1) { |
| 1592 const char* pictureSuffix = "skp"; | 1469 const char* pictureSuffix = "skp"; |
| 1593 SkString path = make_filename(writePicturePath, "", | 1470 SkString path = make_filename(FLAGS_writePicturePath[0], "", |
| 1594 gm->shortName(), | 1471 gm->shortName(), |
| 1595 pictureSuffix); | 1472 pictureSuffix); |
| 1596 SkFILEWStream stream(path.c_str()); | 1473 SkFILEWStream stream(path.c_str()); |
| 1597 pict->serialize(&stream); | 1474 pict->serialize(&stream); |
| 1598 } | 1475 } |
| 1599 | 1476 |
| 1600 testErrors |= pictErrors; | 1477 testErrors |= pictErrors; |
| 1601 } | 1478 } |
| 1602 | 1479 |
| 1603 // TODO: add a test in which the RTree rendering results in a | 1480 // TODO: add a test in which the RTree rendering results in a |
| 1604 // different bitmap than the standard rendering. It should | 1481 // different bitmap than the standard rendering. It should |
| 1605 // show up as failed in the JSON summary, and should be listed | 1482 // show up as failed in the JSON summary, and should be listed |
| 1606 // in the stdout also. | 1483 // in the stdout also. |
| 1607 if (!(gmFlags & GM::kSkipPicture_Flag) && doRTree) { | 1484 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_rtree) { |
| 1608 SkPicture* pict = gmmain.generate_new_picture( | 1485 SkPicture* pict = gmmain.generate_new_picture( |
| 1609 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl
ag); | 1486 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl
ag); |
| 1610 SkAutoUnref aur(pict); | 1487 SkAutoUnref aur(pict); |
| 1611 SkBitmap bitmap; | 1488 SkBitmap bitmap; |
| 1612 gmmain.generate_image_from_picture(gm, compareConfig, pict, | 1489 gmmain.generate_image_from_picture(gm, compareConfig, pict, |
| 1613 &bitmap); | 1490 &bitmap); |
| 1614 testErrors |= gmmain.compare_test_results_to_reference_bitmap( | 1491 testErrors |= gmmain.compare_test_results_to_reference_bitmap( |
| 1615 gm, compareConfig, "-rtree", bitmap, &comparisonBitmap); | 1492 gm, compareConfig, "-rtree", bitmap, &comparisonBitmap); |
| 1616 } | 1493 } |
| 1617 | 1494 |
| 1618 if (!(gmFlags & GM::kSkipPicture_Flag) && doTileGrid) { | 1495 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_tileGrid) { |
| 1619 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); +
+scaleIndex) { | 1496 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); +
+scaleIndex) { |
| 1620 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | 1497 SkScalar replayScale = tileGridReplayScales[scaleIndex]; |
| 1621 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) | 1498 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) |
| 1622 continue; | 1499 continue; |
| 1623 // We record with the reciprocal scale to obtain a replay | 1500 // We record with the reciprocal scale to obtain a replay |
| 1624 // result that can be validated against comparisonBitmap. | 1501 // result that can be validated against comparisonBitmap. |
| 1625 SkScalar recordScale = SkScalarInvert(replayScale); | 1502 SkScalar recordScale = SkScalarInvert(replayScale); |
| 1626 SkPicture* pict = gmmain.generate_new_picture( | 1503 SkPicture* pict = gmmain.generate_new_picture( |
| 1627 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco
rdingFlag, | 1504 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco
rdingFlag, |
| 1628 recordScale); | 1505 recordScale); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1639 gm, compareConfig, suffix.c_str(), bitmap, | 1516 gm, compareConfig, suffix.c_str(), bitmap, |
| 1640 &comparisonBitmap); | 1517 &comparisonBitmap); |
| 1641 } | 1518 } |
| 1642 } | 1519 } |
| 1643 | 1520 |
| 1644 // run the pipe centric GM steps | 1521 // run the pipe centric GM steps |
| 1645 if (!(gmFlags & GM::kSkipPipe_Flag)) { | 1522 if (!(gmFlags & GM::kSkipPipe_Flag)) { |
| 1646 | 1523 |
| 1647 ErrorBitfield pipeErrors = kEmptyErrorBitfield; | 1524 ErrorBitfield pipeErrors = kEmptyErrorBitfield; |
| 1648 | 1525 |
| 1649 if ((kEmptyErrorBitfield == testErrors) && doPipe) { | 1526 if ((kEmptyErrorBitfield == testErrors) && FLAGS_pipe) { |
| 1650 pipeErrors |= gmmain.test_pipe_playback(gm, compareConfig, | 1527 pipeErrors |= gmmain.test_pipe_playback(gm, compareConfig, |
| 1651 comparisonBitmap); | 1528 comparisonBitmap); |
| 1652 } | 1529 } |
| 1653 | 1530 |
| 1654 if ((kEmptyErrorBitfield == testErrors) && | 1531 if ((kEmptyErrorBitfield == testErrors) && |
| 1655 (kEmptyErrorBitfield == pipeErrors) && | 1532 (kEmptyErrorBitfield == pipeErrors) && |
| 1656 doTiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { | 1533 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { |
| 1657 pipeErrors |= gmmain.test_tiled_pipe_playback(gm, compareConfig, | 1534 pipeErrors |= gmmain.test_tiled_pipe_playback(gm, compareConfig, |
| 1658 comparisonBitmap); | 1535 comparisonBitmap); |
| 1659 } | 1536 } |
| 1660 | 1537 |
| 1661 testErrors |= pipeErrors; | 1538 testErrors |= pipeErrors; |
| 1662 } | 1539 } |
| 1663 | 1540 |
| 1664 // Update overall results. | 1541 // Update overall results. |
| 1665 // We only tabulate the particular error types that we currently | 1542 // We only tabulate the particular error types that we currently |
| 1666 // care about (e.g., missing reference images). Later on, if we | 1543 // care about (e.g., missing reference images). Later on, if we |
| 1667 // want to also tabulate other error types, we can do so. | 1544 // want to also tabulate other error types, we can do so. |
| 1668 testsRun++; | 1545 testsRun++; |
| 1669 if (!gmmain.fExpectationsSource.get() || | 1546 if (!gmmain.fExpectationsSource.get() || |
| 1670 (kEmptyErrorBitfield != (kMissingExpectations_ErrorBitmask & testErr
ors))) { | 1547 (kEmptyErrorBitfield != (kMissingExpectations_ErrorBitmask & testErr
ors))) { |
| 1671 testsMissingReferenceImages++; | 1548 testsMissingReferenceImages++; |
| 1672 } | 1549 } |
| 1673 if (testErrors == (testErrors & kIgnorable_ErrorBitmask)) { | 1550 if (testErrors == (testErrors & kIgnorable_ErrorBitmask)) { |
| 1674 testsPassed++; | 1551 testsPassed++; |
| 1675 } else { | 1552 } else { |
| 1676 testsFailed++; | 1553 testsFailed++; |
| 1677 } | 1554 } |
| 1678 | 1555 |
| 1679 SkDELETE(gm); | 1556 SkDELETE(gm); |
| 1680 } | 1557 } |
| 1681 gm_fprintf(stdout, "Ran %d tests: %d passed, %d failed, %d missing reference
images\n", | 1558 gm_fprintf(stdout, "Ran %d tests: %d passed, %d failed, %d missing reference
images\n", |
| 1682 testsRun, testsPassed, testsFailed, testsMissingReferenceImages); | 1559 testsRun, testsPassed, testsFailed, testsMissingReferenceImages); |
| 1683 gmmain.ListErrors(); | 1560 gmmain.ListErrors(); |
| 1684 | 1561 |
| 1685 if (NULL != writeJsonSummaryPath) { | 1562 if (FLAGS_writeJsonSummaryPath.count() == 1) { |
| 1686 Json::Value actualResults; | 1563 Json::Value actualResults; |
| 1687 actualResults[kJsonKey_ActualResults_Failed] = | 1564 actualResults[kJsonKey_ActualResults_Failed] = |
| 1688 gmmain.fJsonActualResults_Failed; | 1565 gmmain.fJsonActualResults_Failed; |
| 1689 actualResults[kJsonKey_ActualResults_FailureIgnored] = | 1566 actualResults[kJsonKey_ActualResults_FailureIgnored] = |
| 1690 gmmain.fJsonActualResults_FailureIgnored; | 1567 gmmain.fJsonActualResults_FailureIgnored; |
| 1691 actualResults[kJsonKey_ActualResults_NoComparison] = | 1568 actualResults[kJsonKey_ActualResults_NoComparison] = |
| 1692 gmmain.fJsonActualResults_NoComparison; | 1569 gmmain.fJsonActualResults_NoComparison; |
| 1693 actualResults[kJsonKey_ActualResults_Succeeded] = | 1570 actualResults[kJsonKey_ActualResults_Succeeded] = |
| 1694 gmmain.fJsonActualResults_Succeeded; | 1571 gmmain.fJsonActualResults_Succeeded; |
| 1695 Json::Value root; | 1572 Json::Value root; |
| 1696 root[kJsonKey_ActualResults] = actualResults; | 1573 root[kJsonKey_ActualResults] = actualResults; |
| 1697 root[kJsonKey_ExpectedResults] = gmmain.fJsonExpectedResults; | 1574 root[kJsonKey_ExpectedResults] = gmmain.fJsonExpectedResults; |
| 1698 std::string jsonStdString = root.toStyledString(); | 1575 std::string jsonStdString = root.toStyledString(); |
| 1699 SkFILEWStream stream(writeJsonSummaryPath); | 1576 SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); |
| 1700 stream.write(jsonStdString.c_str(), jsonStdString.length()); | 1577 stream.write(jsonStdString.c_str(), jsonStdString.length()); |
| 1701 } | 1578 } |
| 1702 | 1579 |
| 1703 #if SK_SUPPORT_GPU | 1580 #if SK_SUPPORT_GPU |
| 1704 | 1581 |
| 1705 #if GR_CACHE_STATS | 1582 #if GR_CACHE_STATS |
| 1706 for (int i = 0; i < configs.count(); i++) { | 1583 for (int i = 0; i < configs.count(); i++) { |
| 1707 ConfigData config = gRec[configs[i]]; | 1584 ConfigData config = gRec[configs[i]]; |
| 1708 | 1585 |
| 1709 if (kGPU_Backend == config.fBackend) { | 1586 if (kGPU_Backend == config.fBackend) { |
| 1710 GrContext* gr = grFactory->get(config.fGLContextType); | 1587 GrContext* gr = grFactory->get(config.fGLContextType); |
| 1711 | 1588 |
| 1712 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); | 1589 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); |
| 1713 gr->printCacheStats(); | 1590 gr->printCacheStats(); |
| 1714 } | 1591 } |
| 1715 } | 1592 } |
| 1716 #endif | 1593 #endif |
| 1717 | 1594 |
| 1718 delete grFactory; | 1595 delete grFactory; |
| 1719 #endif | 1596 #endif |
| 1720 SkGraphics::Term(); | 1597 SkGraphics::Term(); |
| 1721 | 1598 |
| 1722 return (0 == testsFailed) ? 0 : -1; | 1599 return (0 == testsFailed) ? 0 : -1; |
| 1723 } | 1600 } |
| 1724 | 1601 |
| 1602 void GMMain::installFilter(SkCanvas* canvas) { |
| 1603 if (FLAGS_forceBWtext) { |
| 1604 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 1605 } |
| 1606 } |
| 1607 |
| 1725 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1608 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 1726 int main(int argc, char * const argv[]) { | 1609 int main(int argc, char * const argv[]) { |
| 1727 return tool_main(argc, (char**) argv); | 1610 return tool_main(argc, (char**) argv); |
| 1728 } | 1611 } |
| 1729 #endif | 1612 #endif |
| OLD | NEW |