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