OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright 2011 Google Inc. | 2 * Copyright 2011 Google Inc. |
3 * | 3 * |
4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
6 */ | 6 */ |
7 | 7 |
8 /* | 8 /* |
9 * Code for the "gm" (Golden Master) rendering comparison tool. | 9 * Code for the "gm" (Golden Master) rendering comparison tool. |
10 * | 10 * |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag }, | 172 { " cross-process", SkGPipeWriter::kCrossProcess_Flag }, |
173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag | 173 { " cross-process, shared address", SkGPipeWriter::kCrossProcess_Flag |
174 | SkGPipeWriter::kSharedAddressSpace_Flag } | 174 | SkGPipeWriter::kSharedAddressSpace_Flag } |
175 }; | 175 }; |
176 | 176 |
177 class GMMain { | 177 class GMMain { |
178 public: | 178 public: |
179 GMMain() : fUseFileHierarchy(false), fMismatchPath(NULL), fTestsRun(0), | 179 GMMain() : fUseFileHierarchy(false), fMismatchPath(NULL), fTestsRun(0), |
180 fRenderModesEncountered(1) { | 180 fRenderModesEncountered(1) { |
181 fIgnorableErrorCombination.add(kMissingExpectations_ErrorType); | 181 fIgnorableErrorCombination.add(kMissingExpectations_ErrorType); |
182 fIgnorableErrorCombination.add(kIntentionallySkipped_ErrorType); | |
182 } | 183 } |
183 | 184 |
184 SkString make_name(const char shortName[], const char configName[]) { | 185 SkString make_name(const char shortName[], const char configName[]) { |
185 SkString name; | 186 SkString name; |
186 if (0 == strlen(configName)) { | 187 if (0 == strlen(configName)) { |
187 name.append(shortName); | 188 name.append(shortName); |
188 } else if (fUseFileHierarchy) { | 189 } else if (fUseFileHierarchy) { |
189 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); | 190 name.appendf("%s%c%s", configName, SkPATH_SEPARATOR, shortName); |
190 } else { | 191 } else { |
191 name.appendf("%s_%s", shortName, configName); | 192 name.appendf("%s_%s", shortName, configName); |
(...skipping 665 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
857 errors.add(write_reference_image(gRec, writePath, "", | 858 errors.add(write_reference_image(gRec, writePath, "", |
858 name, actualBitmap, pdf)); | 859 name, actualBitmap, pdf)); |
859 } | 860 } |
860 | 861 |
861 return errors; | 862 return errors; |
862 } | 863 } |
863 | 864 |
864 /** | 865 /** |
865 * Compare actualBitmap to referenceBitmap. | 866 * Compare actualBitmap to referenceBitmap. |
866 * | 867 * |
867 * @param gm which test generated the bitmap | 868 * @param baseNameString name of test without renderModeDescriptor added |
868 * @param gRec | |
869 * @param renderModeDescriptor | 869 * @param renderModeDescriptor |
870 * @param actualBitmap actual bitmap generated by this run | 870 * @param actualBitmap actual bitmap generated by this run |
871 * @param referenceBitmap bitmap we expected to be generated | 871 * @param referenceBitmap bitmap we expected to be generated |
872 */ | 872 */ |
873 ErrorCombination compare_test_results_to_reference_bitmap( | 873 ErrorCombination compare_test_results_to_reference_bitmap( |
874 GM* gm, const ConfigData& gRec, const char renderModeDescriptor [], | 874 const SkString& baseNameString, const char renderModeDescriptor[], |
875 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { | 875 SkBitmap& actualBitmap, const SkBitmap* referenceBitmap) { |
876 | 876 |
877 SkASSERT(referenceBitmap); | 877 SkASSERT(referenceBitmap); |
878 SkString name = make_name(gm->shortName(), gRec.fName); | |
879 Expectations expectations(*referenceBitmap); | 878 Expectations expectations(*referenceBitmap); |
880 return compare_to_expectations(expectations, actualBitmap, | 879 return compare_to_expectations(expectations, actualBitmap, |
881 name, renderModeDescriptor, false); | 880 baseNameString, renderModeDescriptor, fal se); |
882 } | 881 } |
883 | 882 |
884 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags, | 883 static SkPicture* generate_new_picture(GM* gm, BbhType bbhType, uint32_t rec ordFlags, |
885 SkScalar scale = SK_Scalar1) { | 884 SkScalar scale = SK_Scalar1) { |
886 // Pictures are refcounted so must be on heap | 885 // Pictures are refcounted so must be on heap |
887 SkPicture* pict; | 886 SkPicture* pict; |
888 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale)); | 887 int width = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize().w idth()), scale)); |
889 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale)); | 888 int height = SkScalarCeilToInt(SkScalarMul(SkIntToScalar(gm->getISize(). height()), scale)); |
890 | 889 |
891 if (kTileGrid_BbhType == bbhType) { | 890 if (kTileGrid_BbhType == bbhType) { |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
964 } | 963 } |
965 | 964 |
966 ErrorCombination test_deferred_drawing(GM* gm, | 965 ErrorCombination test_deferred_drawing(GM* gm, |
967 const ConfigData& gRec, | 966 const ConfigData& gRec, |
968 const SkBitmap& referenceBitmap, | 967 const SkBitmap& referenceBitmap, |
969 GrSurface* gpuTarget) { | 968 GrSurface* gpuTarget) { |
970 SkDynamicMemoryWStream document; | 969 SkDynamicMemoryWStream document; |
971 | 970 |
972 if (gRec.fBackend == kRaster_Backend || | 971 if (gRec.fBackend == kRaster_Backend || |
973 gRec.fBackend == kGPU_Backend) { | 972 gRec.fBackend == kGPU_Backend) { |
973 const char renderModeDescriptor[] = "-deferred"; | |
974 SkBitmap bitmap; | 974 SkBitmap bitmap; |
975 // Early exit if we can't generate the image, but this is | 975 // Early exit if we can't generate the image, but this is |
976 // expected in some cases, so don't report a test failure. | 976 // expected in some cases, so don't report a test failure. |
977 ErrorCombination errors = generate_image(gm, gRec, gpuTarget, &bitma p, true); | 977 ErrorCombination errors = generate_image(gm, gRec, gpuTarget, &bitma p, true); |
978 // TODO(epoger): This logic is the opposite of what is | 978 // TODO(epoger): This logic is the opposite of what is |
979 // described above... if we succeeded in generating the | 979 // described above... if we succeeded in generating the |
980 // -deferred image, we exit early! We should fix this | 980 // -deferred image, we exit early! We should fix this |
981 // ASAP, because it is hiding -deferred errors... but for | 981 // ASAP, because it is hiding -deferred errors... but for |
982 // now, I'm leaving the logic as it is so that the | 982 // now, I'm leaving the logic as it is so that the |
983 // refactoring change | 983 // refactoring change |
984 // https://codereview.chromium.org/12992003/ is unblocked. | 984 // https://codereview.chromium.org/12992003/ is unblocked. |
985 // | 985 // |
986 // Filed as https://code.google.com/p/skia/issues/detail?id=1180 | 986 // Filed as https://code.google.com/p/skia/issues/detail?id=1180 |
987 // ('image-surface gm test is failing in "deferred" mode, | 987 // ('image-surface gm test is failing in "deferred" mode, |
988 // and gm is not reporting the failure') | 988 // and gm is not reporting the failure') |
989 if (errors.isEmpty()) { | 989 if (errors.isEmpty()) { |
990 // TODO(epoger): Report this as a new ErrorType, | 990 // TODO(epoger): Report this as a new ErrorType, |
991 // something like kImageGeneration_ErrorType? | 991 // something like kImageGeneration_ErrorType? |
992 return kEmpty_ErrorCombination; | 992 return kEmpty_ErrorCombination; |
993 } | 993 } |
994 const SkString name = make_name(gm->shortName(), gRec.fName); | |
994 return compare_test_results_to_reference_bitmap( | 995 return compare_test_results_to_reference_bitmap( |
995 gm, gRec, "-deferred", bitmap, &referenceBitmap); | 996 name, renderModeDescriptor, bitmap, &referenceBitmap); |
996 } | 997 } |
997 return kEmpty_ErrorCombination; | 998 return kEmpty_ErrorCombination; |
998 } | 999 } |
999 | 1000 |
1000 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, | 1001 ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, |
1001 const SkBitmap& referenceBitmap, bool si mulateFailure) { | 1002 const SkBitmap& referenceBitmap, bool si mulateFailure) { |
1003 const SkString name = make_name(gm->shortName(), gRec.fName); | |
1002 ErrorCombination errors; | 1004 ErrorCombination errors; |
1003 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1005 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
1004 SkBitmap bitmap; | 1006 SkString renderModeDescriptor("-pipe"); |
1005 SkISize size = gm->getISize(); | 1007 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
1006 setup_bitmap(gRec, size, &bitmap); | 1008 |
1007 SkCanvas canvas(bitmap); | 1009 if (gm->getFlags() & GM::kSkipPipe_Flag) { |
1008 installFilter(&canvas); | 1010 RecordTestResults(kIntentionallySkipped_ErrorType, name, |
epoger
2013/04/09 17:57:57
patchset 4 now looks for cases where we are intent
| |
1009 PipeController pipeController(&canvas); | 1011 renderModeDescriptor.c_str()); |
1010 SkGPipeWriter writer; | 1012 errors.add(kIntentionallySkipped_ErrorType); |
1011 SkCanvas* pipeCanvas = writer.startRecording( | 1013 } else { |
1012 &pipeController, gPipeWritingFlagCombos[i].flags); | 1014 SkBitmap bitmap; |
1013 if (!simulateFailure) { | 1015 SkISize size = gm->getISize(); |
1014 invokeGM(gm, pipeCanvas, false, false); | 1016 setup_bitmap(gRec, size, &bitmap); |
1015 } | 1017 SkCanvas canvas(bitmap); |
1016 complete_bitmap(&bitmap); | 1018 installFilter(&canvas); |
1017 writer.endRecording(); | 1019 PipeController pipeController(&canvas); |
1018 SkString string("-pipe"); | 1020 SkGPipeWriter writer; |
1019 string.append(gPipeWritingFlagCombos[i].name); | 1021 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, |
1020 errors.add(compare_test_results_to_reference_bitmap( | 1022 gPipeWritingFlagCom bos[i].flags); |
1021 gm, gRec, string.c_str(), bitmap, &referenceBitmap)); | 1023 if (!simulateFailure) { |
1022 if (!errors.isEmpty()) { | 1024 invokeGM(gm, pipeCanvas, false, false); |
1023 break; | 1025 } |
1026 complete_bitmap(&bitmap); | |
1027 writer.endRecording(); | |
1028 errors.add(compare_test_results_to_reference_bitmap( | |
1029 name, renderModeDescriptor.c_str(), bitmap, &referenceBitmap )); | |
1030 if (!errors.isEmpty()) { | |
1031 break; | |
1032 } | |
1024 } | 1033 } |
1025 } | 1034 } |
1026 return errors; | 1035 return errors; |
1027 } | 1036 } |
1028 | 1037 |
1029 ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec, | 1038 ErrorCombination test_tiled_pipe_playback(GM* gm, const ConfigData& gRec, |
1030 const SkBitmap& referenceBitmap) { | 1039 const SkBitmap& referenceBitmap) { |
1040 const SkString name = make_name(gm->shortName(), gRec.fName); | |
1031 ErrorCombination errors; | 1041 ErrorCombination errors; |
1032 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1042 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
1033 SkBitmap bitmap; | 1043 SkString renderModeDescriptor("-tiled pipe"); |
1034 SkISize size = gm->getISize(); | 1044 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
1035 setup_bitmap(gRec, size, &bitmap); | 1045 |
1036 SkCanvas canvas(bitmap); | 1046 if ((gm->getFlags() & GM::kSkipPipe_Flag) || |
1037 installFilter(&canvas); | 1047 (gm->getFlags() & GM::kSkipTiled_Flag)) { |
1038 TiledPipeController pipeController(bitmap); | 1048 RecordTestResults(kIntentionallySkipped_ErrorType, name, |
1039 SkGPipeWriter writer; | 1049 renderModeDescriptor.c_str()); |
1040 SkCanvas* pipeCanvas = writer.startRecording( | 1050 errors.add(kIntentionallySkipped_ErrorType); |
1041 &pipeController, gPipeWritingFlagCombos[i].flags); | 1051 } else { |
1042 invokeGM(gm, pipeCanvas, false, false); | 1052 SkBitmap bitmap; |
1043 complete_bitmap(&bitmap); | 1053 SkISize size = gm->getISize(); |
1044 writer.endRecording(); | 1054 setup_bitmap(gRec, size, &bitmap); |
1045 SkString string("-tiled pipe"); | 1055 SkCanvas canvas(bitmap); |
1046 string.append(gPipeWritingFlagCombos[i].name); | 1056 installFilter(&canvas); |
1047 errors.add(compare_test_results_to_reference_bitmap( | 1057 TiledPipeController pipeController(bitmap); |
1048 gm, gRec, string.c_str(), bitmap, &referenceBitmap)); | 1058 SkGPipeWriter writer; |
1049 if (!errors.isEmpty()) { | 1059 SkCanvas* pipeCanvas = writer.startRecording(&pipeController, |
1050 break; | 1060 gPipeWritingFlagCom bos[i].flags); |
1061 invokeGM(gm, pipeCanvas, false, false); | |
1062 complete_bitmap(&bitmap); | |
1063 writer.endRecording(); | |
1064 errors.add(compare_test_results_to_reference_bitmap(name, | |
1065 renderModeDe scriptor.c_str(), | |
1066 bitmap, &ref erenceBitmap)); | |
1067 if (!errors.isEmpty()) { | |
1068 break; | |
1069 } | |
1051 } | 1070 } |
1052 } | 1071 } |
1053 return errors; | 1072 return errors; |
1054 } | 1073 } |
1055 | 1074 |
1056 // | 1075 // |
1057 // member variables. | 1076 // member variables. |
1058 // They are public for now, to allow easier setting by tool_main(). | 1077 // They are public for now, to allow easier setting by tool_main(). |
1059 // | 1078 // |
1060 | 1079 |
(...skipping 204 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1265 * Run this test in a number of different configs (8888, 565, PDF, | 1284 * Run this test in a number of different configs (8888, 565, PDF, |
1266 * etc.), confirming that the resulting bitmaps match expectations | 1285 * etc.), confirming that the resulting bitmaps match expectations |
1267 * (which may be different for each config). | 1286 * (which may be different for each config). |
1268 * | 1287 * |
1269 * Returns all errors encountered while doing so. | 1288 * Returns all errors encountered while doing so. |
1270 */ | 1289 */ |
1271 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, | 1290 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, |
1272 GrContextFactory *grFactory); | 1291 GrContextFactory *grFactory); |
1273 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, | 1292 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, |
1274 GrContextFactory *grFactory) { | 1293 GrContextFactory *grFactory) { |
1294 const char renderModeDescriptor[] = ""; | |
1275 ErrorCombination errorsForAllConfigs; | 1295 ErrorCombination errorsForAllConfigs; |
1276 uint32_t gmFlags = gm->getFlags(); | 1296 uint32_t gmFlags = gm->getFlags(); |
1277 | 1297 |
1278 for (int i = 0; i < configs.count(); i++) { | 1298 for (int i = 0; i < configs.count(); i++) { |
1279 ConfigData config = gRec[configs[i]]; | 1299 ConfigData config = gRec[configs[i]]; |
1300 const SkString name = gmmain.make_name(gm->shortName(), config.fName); | |
1280 | 1301 |
1281 // Skip any tests that we don't even need to try. | 1302 // Skip any tests that we don't even need to try. |
1282 if ((kPDF_Backend == config.fBackend) && | 1303 // If any of these were skipped on a per-GM basis, record them as |
1283 (!FLAGS_pdf|| (gmFlags & GM::kSkipPDF_Flag))) { | 1304 // kIntentionallySkipped. |
1305 if (kPDF_Backend == config.fBackend) { | |
1306 if (!FLAGS_pdf) { | |
1284 continue; | 1307 continue; |
1285 } | 1308 } |
1309 if (gmFlags & GM::kSkipPDF_Flag) { | |
1310 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, | |
1311 renderModeDescriptor); | |
1312 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1313 continue; | |
1314 } | |
1315 } | |
1286 if ((gmFlags & GM::kSkip565_Flag) && | 1316 if ((gmFlags & GM::kSkip565_Flag) && |
1287 (kRaster_Backend == config.fBackend) && | 1317 (kRaster_Backend == config.fBackend) && |
1288 (SkBitmap::kRGB_565_Config == config.fConfig)) { | 1318 (SkBitmap::kRGB_565_Config == config.fConfig)) { |
1319 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, | |
1320 renderModeDescriptor); | |
1321 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1289 continue; | 1322 continue; |
1290 } | 1323 } |
1291 if ((gmFlags & GM::kSkipGPU_Flag) && | 1324 if ((gmFlags & GM::kSkipGPU_Flag) && |
1292 kGPU_Backend == config.fBackend) { | 1325 kGPU_Backend == config.fBackend) { |
1326 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, | |
1327 renderModeDescriptor); | |
1328 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1293 continue; | 1329 continue; |
1294 } | 1330 } |
1295 | 1331 |
1296 // Now we know that we want to run this test and record its | 1332 // Now we know that we want to run this test and record its |
1297 // success or failure. | 1333 // success or failure. |
1298 ErrorCombination errorsForThisConfig; | 1334 ErrorCombination errorsForThisConfig; |
1299 GrSurface* gpuTarget = NULL; | 1335 GrSurface* gpuTarget = NULL; |
1300 #if SK_SUPPORT_GPU | 1336 #if SK_SUPPORT_GPU |
1301 SkAutoTUnref<GrSurface> auGpuTarget; | 1337 SkAutoTUnref<GrSurface> auGpuTarget; |
1302 AutoResetGr autogr; | 1338 AutoResetGr autogr; |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1367 * Returns all errors encountered while doing so. | 1403 * Returns all errors encountered while doing so. |
1368 */ | 1404 */ |
1369 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, | 1405 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
1370 const SkBitmap &comparisonBitmap, | 1406 const SkBitmap &comparisonBitmap, |
1371 const SkTDArray<SkScalar> &tileGridReplaySca les); | 1407 const SkTDArray<SkScalar> &tileGridReplaySca les); |
1372 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, | 1408 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
1373 const SkBitmap &comparisonBitmap, | 1409 const SkBitmap &comparisonBitmap, |
1374 const SkTDArray<SkScalar> &tileGridReplaySca les) { | 1410 const SkTDArray<SkScalar> &tileGridReplaySca les) { |
1375 ErrorCombination errorsForAllModes; | 1411 ErrorCombination errorsForAllModes; |
1376 uint32_t gmFlags = gm->getFlags(); | 1412 uint32_t gmFlags = gm->getFlags(); |
1413 const SkString name = gmmain.make_name(gm->shortName(), compareConfig.fName) ; | |
1377 | 1414 |
1378 // TODO(epoger): We should start recording any per-GM skipped | 1415 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); |
1379 // modes (i.e. those we skipped due to gmFlags) with a new | 1416 SkAutoUnref aur(pict); |
1380 // ErrorType, perhaps named kIntentionallySkipped_ErrorType. | 1417 if (FLAGS_replay) { |
1381 if (!(gmFlags & GM::kSkipPicture_Flag)) { | 1418 const char renderModeDescriptor[] = "-replay"; |
1382 | 1419 if (gmFlags & GM::kSkipPicture_Flag) { |
1383 ErrorCombination pictErrors; | 1420 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); |
1384 | 1421 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
1385 //SkAutoTUnref<SkPicture> pict(generate_new_picture(gm)); | 1422 } else { |
1386 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); | |
1387 SkAutoUnref aur(pict); | |
1388 | |
1389 if (FLAGS_replay) { | |
1390 SkBitmap bitmap; | 1423 SkBitmap bitmap; |
1391 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | 1424 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; |
1392 pictErrors.add(gmmain.compare_test_results_to_reference_bitmap( | 1425 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
1393 gm, compareConfig, "-replay", bitmap, &comparisonBitmap)); | 1426 name, renderModeDescriptor, bitmap, &comparisonBitmap)); |
1394 } | 1427 } |
1428 } | |
1395 | 1429 |
1396 if ((pictErrors.isEmpty()) && FLAGS_serialize) { | 1430 if (FLAGS_serialize) { |
1431 const char renderModeDescriptor[] = "-serialize"; | |
1432 if (gmFlags & GM::kSkipPicture_Flag) { | |
1433 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); | |
1434 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | |
1435 } else { | |
1397 SkPicture* repict = gmmain.stream_to_new_picture(*pict); | 1436 SkPicture* repict = gmmain.stream_to_new_picture(*pict); |
1398 SkAutoUnref aurr(repict); | 1437 SkAutoUnref aurr(repict); |
1399 | |
1400 SkBitmap bitmap; | 1438 SkBitmap bitmap; |
1401 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); | 1439 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); |
1402 pictErrors.add(gmmain.compare_test_results_to_reference_bitmap( | 1440 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
1403 gm, compareConfig, "-serialize", bitmap, &comparisonBitmap)); | 1441 name, renderModeDescriptor, bitmap, &comparisonBitmap)); |
1404 } | 1442 } |
1405 | |
1406 if (FLAGS_writePicturePath.count() == 1) { | |
1407 const char* pictureSuffix = "skp"; | |
1408 SkString path = make_filename(FLAGS_writePicturePath[0], "", | |
1409 gm->shortName(), pictureSuffix); | |
1410 SkFILEWStream stream(path.c_str()); | |
1411 pict->serialize(&stream); | |
1412 } | |
1413 | |
1414 errorsForAllModes.add(pictErrors); | |
1415 } | 1443 } |
1416 | 1444 |
1417 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_rtree) { | 1445 if ((1 == FLAGS_writePicturePath.count()) && |
1418 SkPicture* pict = gmmain.generate_new_picture( | 1446 !(gmFlags & GM::kSkipPicture_Flag)) { |
1419 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFlag); | 1447 const char* pictureSuffix = "skp"; |
1420 SkAutoUnref aur(pict); | 1448 SkString path = make_filename(FLAGS_writePicturePath[0], "", |
1421 SkBitmap bitmap; | 1449 gm->shortName(), pictureSuffix); |
1422 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap); | 1450 SkFILEWStream stream(path.c_str()); |
1423 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitmap( | 1451 pict->serialize(&stream); |
1424 gm, compareConfig, "-rtree", bitmap, &comparisonBitmap)); | |
1425 } | 1452 } |
1426 | 1453 |
1427 if (!(gmFlags & GM::kSkipPicture_Flag) && FLAGS_tileGrid) { | 1454 if (FLAGS_rtree) { |
1455 const char renderModeDescriptor[] = "-rtree"; | |
1456 if (gmFlags & GM::kSkipPicture_Flag) { | |
1457 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); | |
1458 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | |
1459 } else { | |
1460 SkPicture* pict = gmmain.generate_new_picture( | |
1461 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag); | |
1462 SkAutoUnref aur(pict); | |
1463 SkBitmap bitmap; | |
1464 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | |
1465 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | |
1466 name, renderModeDescriptor, bitmap, &comparisonBitmap)); | |
1467 } | |
1468 } | |
1469 | |
1470 if (FLAGS_tileGrid) { | |
1428 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { | 1471 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { |
1429 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | 1472 SkScalar replayScale = tileGridReplayScales[scaleIndex]; |
1430 if ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1) { | 1473 SkString renderModeDescriptor("-tilegrid"); |
1431 continue; | 1474 if (SK_Scalar1 != replayScale) { |
1475 renderModeDescriptor += "-scale-"; | |
1476 renderModeDescriptor.appendScalar(replayScale); | |
1432 } | 1477 } |
1433 // We record with the reciprocal scale to obtain a replay | 1478 |
1434 // result that can be validated against comparisonBitmap. | 1479 if ((gmFlags & GM::kSkipPicture_Flag) || |
1435 SkScalar recordScale = SkScalarInvert(replayScale); | 1480 ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) { |
1436 SkPicture* pict = gmmain.generate_new_picture( | 1481 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, |
1437 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Recordin gFlag, recordScale); | 1482 renderModeDescriptor.c_str()); |
1438 SkAutoUnref aur(pict); | 1483 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
1439 SkBitmap bitmap; | 1484 } else { |
1440 // We cannot yet pass 'true' to generate_image_from_picture to | 1485 // We record with the reciprocal scale to obtain a replay |
1441 // perform actual tiled rendering (see Issue 1198 - | 1486 // result that can be validated against comparisonBitmap. |
1442 // https://code.google.com/p/skia/issues/detail?id=1198) | 1487 SkScalar recordScale = SkScalarInvert(replayScale); |
epoger
2013/04/09 17:57:57
many of the changed lines around here are just re-
| |
1443 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap, | 1488 SkPicture* pict = gmmain.generate_new_picture( |
1444 replayScale /*, true */); | 1489 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag, |
1445 SkString suffix("-tilegrid"); | 1490 recordScale); |
1446 if (SK_Scalar1 != replayScale) { | 1491 SkAutoUnref aur(pict); |
1447 suffix += "-scale-"; | 1492 SkBitmap bitmap; |
1448 suffix.appendScalar(replayScale); | 1493 // We cannot yet pass 'true' to generate_image_from_picture to |
1494 // perform actual tiled rendering (see Issue 1198 - | |
1495 // https://code.google.com/p/skia/issues/detail?id=1198) | |
1496 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bit map, | |
1497 replayScale /*, true */); | |
1498 errorsForAllModes.add(gmmain.compare_test_results_to_reference_b itmap( | |
1499 name, renderModeDescriptor.c_str(), bitmap, &comparisonBitma p)); | |
1449 } | 1500 } |
1450 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | |
1451 gm, compareConfig, suffix.c_str(), bitmap, &comparisonBitmap)); | |
1452 } | 1501 } |
1453 } | 1502 } |
1454 | 1503 |
1455 // run the pipe centric GM steps | 1504 // run the pipe centric GM steps |
1456 if (!(gmFlags & GM::kSkipPipe_Flag)) { | 1505 if (FLAGS_pipe) { |
1457 | 1506 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa risonBitmap, |
1458 ErrorCombination pipeErrors; | 1507 FLAGS_simulatePipePlayba ckFailure)); |
1459 | 1508 if (FLAGS_tiledPipe) { |
1460 if (FLAGS_pipe) { | 1509 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, |
1461 pipeErrors.add(gmmain.test_pipe_playback(gm, compareConfig, comparis onBitmap, | 1510 comparisonBitm ap)); |
1462 FLAGS_simulatePipePlaybackF ailure)); | |
1463 } | 1511 } |
1464 | |
1465 if ((pipeErrors.isEmpty()) && | |
1466 FLAGS_tiledPipe && !(gmFlags & GM::kSkipTiled_Flag)) { | |
1467 pipeErrors.add(gmmain.test_tiled_pipe_playback(gm, compareConfig, co mparisonBitmap)); | |
1468 } | |
1469 | |
1470 errorsForAllModes.add(pipeErrors); | |
1471 } | 1512 } |
1472 return errorsForAllModes; | 1513 return errorsForAllModes; |
1473 } | 1514 } |
1474 | 1515 |
1475 /** | 1516 /** |
1476 * Return a list of all entries in an array of strings as a single string | 1517 * Return a list of all entries in an array of strings as a single string |
1477 * of this form: | 1518 * of this form: |
1478 * "item1", "item2", "item3" | 1519 * "item1", "item2", "item3" |
1479 */ | 1520 */ |
1480 SkString list_all(const SkTArray<SkString> &stringArray); | 1521 SkString list_all(const SkTArray<SkString> &stringArray); |
(...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1760 list_all_config_names(configs).c_str()); | 1801 list_all_config_names(configs).c_str()); |
1761 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_all(mo des).c_str()); | 1802 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_all(mo des).c_str()); |
1762 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", | 1803 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", |
1763 gmsRun * (configs.count() + modes.count())); | 1804 gmsRun * (configs.count() + modes.count())); |
1764 | 1805 |
1765 // TODO(epoger): Ultimately, we should signal an error if the | 1806 // TODO(epoger): Ultimately, we should signal an error if the |
1766 // expected total number of tests (displayed above) does not match | 1807 // expected total number of tests (displayed above) does not match |
1767 // gmmain.fTestsRun. But for now, there are cases where those | 1808 // gmmain.fTestsRun. But for now, there are cases where those |
1768 // numbers won't match: specifically, if some configs/modes are | 1809 // numbers won't match: specifically, if some configs/modes are |
1769 // skipped on a per-GM basis (due to gm->getFlags() for a specific | 1810 // skipped on a per-GM basis (due to gm->getFlags() for a specific |
1770 // GM). Later on, we should record tests like that using some new | 1811 // GM). |
1771 // ErrorType, like kIntentionallySkipped_ErrorType. Then we could | 1812 // Update: now that we have added the new kIntentionallySkipped_ErrorType, |
1772 // signal an error if the totals didn't match up. | 1813 // we should be OK to signal an error if these don't match. |
1773 gmmain.ListErrors(); | 1814 gmmain.ListErrors(); |
1774 | 1815 |
1775 if (FLAGS_writeJsonSummaryPath.count() == 1) { | 1816 if (FLAGS_writeJsonSummaryPath.count() == 1) { |
1776 Json::Value actualResults; | 1817 Json::Value actualResults; |
1777 actualResults[kJsonKey_ActualResults_Failed] = | 1818 actualResults[kJsonKey_ActualResults_Failed] = |
1778 gmmain.fJsonActualResults_Failed; | 1819 gmmain.fJsonActualResults_Failed; |
1779 actualResults[kJsonKey_ActualResults_FailureIgnored] = | 1820 actualResults[kJsonKey_ActualResults_FailureIgnored] = |
1780 gmmain.fJsonActualResults_FailureIgnored; | 1821 gmmain.fJsonActualResults_FailureIgnored; |
1781 actualResults[kJsonKey_ActualResults_NoComparison] = | 1822 actualResults[kJsonKey_ActualResults_NoComparison] = |
1782 gmmain.fJsonActualResults_NoComparison; | 1823 gmmain.fJsonActualResults_NoComparison; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1816 if (FLAGS_forceBWtext) { | 1857 if (FLAGS_forceBWtext) { |
1817 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1858 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
1818 } | 1859 } |
1819 } | 1860 } |
1820 | 1861 |
1821 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1862 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1822 int main(int argc, char * const argv[]) { | 1863 int main(int argc, char * const argv[]) { |
1823 return tool_main(argc, (char**) argv); | 1864 return tool_main(argc, (char**) argv); |
1824 } | 1865 } |
1825 #endif | 1866 #endif |
OLD | NEW |