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 12 matching lines...) Expand all Loading... | |
23 #include "SkData.h" | 23 #include "SkData.h" |
24 #include "SkDeferredCanvas.h" | 24 #include "SkDeferredCanvas.h" |
25 #include "SkDevice.h" | 25 #include "SkDevice.h" |
26 #include "SkDrawFilter.h" | 26 #include "SkDrawFilter.h" |
27 #include "SkForceLinking.h" | 27 #include "SkForceLinking.h" |
28 #include "SkGPipe.h" | 28 #include "SkGPipe.h" |
29 #include "SkGraphics.h" | 29 #include "SkGraphics.h" |
30 #include "SkImageDecoder.h" | 30 #include "SkImageDecoder.h" |
31 #include "SkImageEncoder.h" | 31 #include "SkImageEncoder.h" |
32 #include "SkOSFile.h" | 32 #include "SkOSFile.h" |
33 #include "SkPDFRasterizer.h" | |
33 #include "SkPicture.h" | 34 #include "SkPicture.h" |
34 #include "SkRefCnt.h" | 35 #include "SkRefCnt.h" |
35 #include "SkStream.h" | 36 #include "SkStream.h" |
36 #include "SkTArray.h" | 37 #include "SkTArray.h" |
37 #include "SkTDict.h" | 38 #include "SkTDict.h" |
38 #include "SkTileGridPicture.h" | 39 #include "SkTileGridPicture.h" |
39 #include "SamplePipeControllers.h" | 40 #include "SamplePipeControllers.h" |
40 | 41 |
41 __SK_FORCE_IMAGE_DECODER_LINKING; | 42 __SK_FORCE_IMAGE_DECODER_LINKING; |
42 | 43 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
76 | 77 |
77 // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , | 78 // Until we resolve http://code.google.com/p/skia/issues/detail?id=455 , |
78 // stop writing out XPS-format image baselines in gm. | 79 // stop writing out XPS-format image baselines in gm. |
79 #undef SK_SUPPORT_XPS | 80 #undef SK_SUPPORT_XPS |
80 #ifdef SK_SUPPORT_XPS | 81 #ifdef SK_SUPPORT_XPS |
81 #include "SkXPSDevice.h" | 82 #include "SkXPSDevice.h" |
82 #endif | 83 #endif |
83 | 84 |
84 #ifdef SK_BUILD_FOR_MAC | 85 #ifdef SK_BUILD_FOR_MAC |
85 #include "SkCGUtils.h" | 86 #include "SkCGUtils.h" |
86 #define CAN_IMAGE_PDF 1 | |
87 #else | |
88 #define CAN_IMAGE_PDF 0 | |
89 #endif | 87 #endif |
90 | 88 |
91 using namespace skiagm; | 89 using namespace skiagm; |
92 | 90 |
93 class Iter { | 91 class Iter { |
94 public: | 92 public: |
95 Iter() { | 93 Iter() { |
96 this->reset(); | 94 this->reset(); |
97 } | 95 } |
98 | 96 |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
153 struct ConfigData { | 151 struct ConfigData { |
154 SkBitmap::Config fConfig; | 152 SkBitmap::Config fConfig; |
155 Backend fBackend; | 153 Backend fBackend; |
156 GLContextType fGLContextType; // GPU backend only | 154 GLContextType fGLContextType; // GPU backend only |
157 int fSampleCnt; // GPU backend only | 155 int fSampleCnt; // GPU backend only |
158 ConfigFlags fFlags; | 156 ConfigFlags fFlags; |
159 const char* fName; | 157 const char* fName; |
160 bool fRunByDefault; | 158 bool fRunByDefault; |
161 }; | 159 }; |
162 | 160 |
161 struct PDFRasterizerData { | |
162 bool (*fRasterizerFunction)(SkStream*, SkBitmap*); | |
163 const char* fName; | |
164 bool fRunByDefault; | |
vandebo (ex-Chrome)
2013/08/12 17:41:56
spacing here too
ducky
2013/08/12 21:57:10
Done.
| |
165 }; | |
166 | |
163 class BWTextDrawFilter : public SkDrawFilter { | 167 class BWTextDrawFilter : public SkDrawFilter { |
164 public: | 168 public: |
165 virtual bool filter(SkPaint*, Type) SK_OVERRIDE; | 169 virtual bool filter(SkPaint*, Type) SK_OVERRIDE; |
166 }; | 170 }; |
167 bool BWTextDrawFilter::filter(SkPaint* p, Type t) { | 171 bool BWTextDrawFilter::filter(SkPaint* p, Type t) { |
168 if (kText_Type == t) { | 172 if (kText_Type == t) { |
169 p->setAntiAlias(false); | 173 p->setAntiAlias(false); |
170 } | 174 } |
171 return true; | 175 return true; |
172 } | 176 } |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
275 | 279 |
276 static void force_all_opaque_8888(const SkBitmap& bitmap) { | 280 static void force_all_opaque_8888(const SkBitmap& bitmap) { |
277 SkAutoLockPixels lock(bitmap); | 281 SkAutoLockPixels lock(bitmap); |
278 for (int y = 0; y < bitmap.height(); y++) { | 282 for (int y = 0; y < bitmap.height(); y++) { |
279 for (int x = 0; x < bitmap.width(); x++) { | 283 for (int x = 0; x < bitmap.width(); x++) { |
280 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 284 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
281 } | 285 } |
282 } | 286 } |
283 } | 287 } |
284 | 288 |
285 static bool write_bitmap(const SkString& path, const SkBitmap& bitmap) { | 289 static ErrorCombination write_bitmap(const SkString& path, const SkBitmap& b itmap) { |
286 // TODO(epoger): Now that we have removed force_all_opaque() | 290 // TODO(epoger): Now that we have removed force_all_opaque() |
287 // from this method, we should be able to get rid of the | 291 // from this method, we should be able to get rid of the |
288 // transformation to 8888 format also. | 292 // transformation to 8888 format also. |
289 SkBitmap copy; | 293 SkBitmap copy; |
290 bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); | 294 bitmap.copyTo(©, SkBitmap::kARGB_8888_Config); |
291 return SkImageEncoder::EncodeFile(path.c_str(), copy, | 295 bool success = SkImageEncoder::EncodeFile(path.c_str(), copy, |
vandebo (ex-Chrome)
2013/08/12 17:41:56
Since you don't use success except in the conditio
ducky
2013/08/12 21:57:10
Done. The original intent behind a separate succes
| |
292 SkImageEncoder::kPNG_Type, 100); | 296 SkImageEncoder::kPNG_Type, |
297 100); | |
298 if (success) { | |
299 return kEmpty_ErrorCombination; | |
300 } else { | |
301 gm_fprintf(stderr, "FAILED to write bitmap: %s\n", path.c_str()); | |
302 return ErrorCombination(kWritingReferenceImage_ErrorType); | |
303 } | |
293 } | 304 } |
294 | 305 |
295 /** | 306 /** |
296 * Add all render modes encountered thus far to the "modes" array. | 307 * Add all render modes encountered thus far to the "modes" array. |
297 */ | 308 */ |
298 void GetRenderModesEncountered(SkTArray<SkString> &modes) { | 309 void GetRenderModesEncountered(SkTArray<SkString> &modes) { |
299 SkTDict<int>::Iter iter(this->fRenderModesEncountered); | 310 SkTDict<int>::Iter iter(this->fRenderModesEncountered); |
300 const char* mode; | 311 const char* mode; |
301 while ((mode = iter.next(NULL)) != NULL) { | 312 while ((mode = iter.next(NULL)) != NULL) { |
302 SkString modeAsString = SkString(mode); | 313 SkString modeAsString = SkString(mode); |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
403 } | 414 } |
404 gm_fprintf(stdout, "%s\n", summary.c_str()); | 415 gm_fprintf(stdout, "%s\n", summary.c_str()); |
405 | 416 |
406 // Now, for each failure type, list the tests that failed that way. | 417 // Now, for each failure type, list the tests that failed that way. |
407 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 418 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
408 this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verb ose); | 419 this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verb ose); |
409 } | 420 } |
410 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v alue)\n"); | 421 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v alue)\n"); |
411 } | 422 } |
412 | 423 |
413 static bool write_document(const SkString& path, SkStreamAsset* asset) { | 424 static ErrorCombination write_document(const SkString& path, SkStreamAsset* asset) { |
414 SkFILEWStream stream(path.c_str()); | 425 SkFILEWStream stream(path.c_str()); |
415 return stream.writeStream(asset, asset->getLength()); | 426 bool success = stream.writeStream(asset, asset->getLength()); |
vandebo (ex-Chrome)
2013/08/12 17:41:56
And here
ducky
2013/08/12 21:57:10
Done.
| |
427 if (success) { | |
428 return kEmpty_ErrorCombination; | |
429 } else { | |
430 gm_fprintf(stderr, "FAILED to write document: %s\n", path.c_str()); | |
431 return ErrorCombination(kWritingReferenceImage_ErrorType); | |
432 } | |
416 } | 433 } |
417 | 434 |
418 /** | 435 /** |
419 * Prepare an SkBitmap to render a GM into. | 436 * Prepare an SkBitmap to render a GM into. |
420 * | 437 * |
421 * After you've rendered the GM into the SkBitmap, you must call | 438 * After you've rendered the GM into the SkBitmap, you must call |
422 * complete_bitmap()! | 439 * complete_bitmap()! |
423 * | 440 * |
424 * @todo thudson 22 April 2011 - could refactor this to take in | 441 * @todo thudson 22 April 2011 - could refactor this to take in |
425 * a factory to generate the context, always call readPixels() | 442 * a factory to generate the context, always call readPixels() |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
652 SkCanvas c(dev); | 669 SkCanvas c(dev); |
653 dev->beginPortfolio(&xps); | 670 dev->beginPortfolio(&xps); |
654 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); | 671 dev->beginSheet(unitsPerMeter, pixelsPerMeter, trimSize); |
655 invokeGM(gm, &c, false, false); | 672 invokeGM(gm, &c, false, false); |
656 dev->endSheet(); | 673 dev->endSheet(); |
657 dev->endPortfolio(); | 674 dev->endPortfolio(); |
658 | 675 |
659 #endif | 676 #endif |
660 } | 677 } |
661 | 678 |
662 ErrorCombination write_reference_image(const ConfigData& gRec, const char wr itePath [], | |
663 const char renderModeDescriptor [], | |
664 const char *shortName, | |
665 const BitmapAndDigest* bitmapAndDiges t, | |
666 SkStreamAsset* document) { | |
667 SkString path; | |
668 bool success = false; | |
669 if (gRec.fBackend == kRaster_Backend || | |
670 gRec.fBackend == kGPU_Backend || | |
671 (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) { | |
672 | |
673 path = make_bitmap_filename(writePath, shortName, gRec.fName, render ModeDescriptor, | |
674 bitmapAndDigest->fDigest); | |
675 success = write_bitmap(path, bitmapAndDigest->fBitmap); | |
676 } | |
677 if (kPDF_Backend == gRec.fBackend) { | |
678 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, | |
679 "pdf"); | |
680 success = write_document(path, document); | |
681 } | |
682 if (kXPS_Backend == gRec.fBackend) { | |
683 path = make_filename(writePath, shortName, gRec.fName, renderModeDes criptor, | |
684 "xps"); | |
685 success = write_document(path, document); | |
686 } | |
687 if (success) { | |
688 return kEmpty_ErrorCombination; | |
689 } else { | |
690 gm_fprintf(stderr, "FAILED to write %s\n", path.c_str()); | |
691 ErrorCombination errors(kWritingReferenceImage_ErrorType); | |
692 // TODO(epoger): Don't call RecordTestResults() here... | |
693 // Instead, we should make sure to call RecordTestResults | |
694 // exactly ONCE per test. (Otherwise, gmmain.fTestsRun | |
695 // will be incremented twice for this test: once in | |
696 // compare_test_results_to_stored_expectations() before | |
697 // that method calls this one, and again here.) | |
698 // | |
699 // When we make that change, we should probably add a | |
700 // WritingReferenceImage test to the gm self-tests.) | |
701 RecordTestResults(errors, make_shortname_plus_config(shortName, gRec .fName), | |
702 renderModeDescriptor); | |
703 return errors; | |
704 } | |
705 } | |
706 | |
707 /** | 679 /** |
708 * Log more detail about the mistmatch between expectedBitmap and | 680 * Log more detail about the mistmatch between expectedBitmap and |
709 * actualBitmap. | 681 * actualBitmap. |
710 */ | 682 */ |
711 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, | 683 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act ualBitmap, |
712 const char *testName) { | 684 const char *testName) { |
713 const int expectedWidth = expectedBitmap.width(); | 685 const int expectedWidth = expectedBitmap.width(); |
714 const int expectedHeight = expectedBitmap.height(); | 686 const int expectedHeight = expectedBitmap.height(); |
715 const int width = actualBitmap.width(); | 687 const int width = actualBitmap.width(); |
716 const int height = actualBitmap.height(); | 688 const int height = actualBitmap.height(); |
(...skipping 184 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
901 * | 873 * |
902 * @param gm which test generated the actualBitmap | 874 * @param gm which test generated the actualBitmap |
903 * @param gRec | 875 * @param gRec |
904 * @param writePath unless this is NULL, write out actual images into this | 876 * @param writePath unless this is NULL, write out actual images into this |
905 * directory | 877 * directory |
906 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL | 878 * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL |
907 * if we don't have a usable bitmap representation | 879 * if we don't have a usable bitmap representation |
908 * @param document pdf or xps representation, if appropriate | 880 * @param document pdf or xps representation, if appropriate |
909 */ | 881 */ |
910 ErrorCombination compare_test_results_to_stored_expectations( | 882 ErrorCombination compare_test_results_to_stored_expectations( |
911 GM* gm, const ConfigData& gRec, const char writePath[], | 883 GM* gm, const ConfigData& gRec, |
912 const BitmapAndDigest* actualBitmapAndDigest, SkStreamAsset* document) { | 884 const BitmapAndDigest* actualBitmapAndDigest) { |
913 | 885 |
914 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); | 886 SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName( ), gRec.fName); |
915 SkString nameWithExtension(shortNamePlusConfig); | |
916 nameWithExtension.append("."); | |
917 nameWithExtension.append(kPNG_FileExtension); | |
918 | 887 |
919 ErrorCombination errors; | 888 ErrorCombination errors; |
920 | 889 |
921 if (NULL == actualBitmapAndDigest) { | 890 if (NULL == actualBitmapAndDigest) { |
922 // Note that we intentionally skipped validating the results for | 891 // Note that we intentionally skipped validating the results for |
923 // this test, because we don't know how to generate an SkBitmap | 892 // this test, because we don't know how to generate an SkBitmap |
924 // version of the output. | 893 // version of the output. |
925 RecordTestResults(ErrorCombination(kIntentionallySkipped_ErrorType), | 894 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); |
926 shortNamePlusConfig, ""); | |
927 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { | 895 } else if (!(gRec.fFlags & kWrite_ConfigFlag)) { |
928 // We don't record the results for this test or compare them | 896 // We don't record the results for this test or compare them |
929 // against any expectations, because the output image isn't | 897 // against any expectations, because the output image isn't |
930 // meaningful. | 898 // meaningful. |
931 // See https://code.google.com/p/skia/issues/detail?id=1410 ('some | 899 // See https://code.google.com/p/skia/issues/detail?id=1410 ('some |
932 // GM result images not available for download from Google Storage') | 900 // GM result images not available for download from Google Storage') |
933 RecordTestResults(ErrorCombination(kIntentionallySkipped_ErrorType), | 901 errors.add(ErrorCombination(kIntentionallySkipped_ErrorType)); |
934 shortNamePlusConfig, ""); | |
935 } else { | 902 } else { |
936 ExpectationsSource *expectationsSource = this->fExpectationsSource.g et(); | 903 ExpectationsSource *expectationsSource = this->fExpectationsSource.g et(); |
904 SkString nameWithExtension(shortNamePlusConfig); | |
905 nameWithExtension.append("."); | |
906 nameWithExtension.append(kPNG_FileExtension); | |
907 | |
937 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { | 908 if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { |
938 /* | 909 /* |
939 * Get the expected results for this test, as one or more allowe d | 910 * Get the expected results for this test, as one or more allowe d |
940 * hash digests. The current implementation of expectationsSourc e | 911 * hash digests. The current implementation of expectationsSourc e |
941 * get this by computing the hash digest of a single PNG file on disk. | 912 * get this by computing the hash digest of a single PNG file on disk. |
942 * | 913 * |
943 * TODO(epoger): This relies on the fact that | 914 * TODO(epoger): This relies on the fact that |
944 * force_all_opaque() was called on the bitmap before it | 915 * force_all_opaque() was called on the bitmap before it |
945 * was written to disk as a PNG in the first place. If | 916 * was written to disk as a PNG in the first place. If |
946 * not, the hash digest returned here may not match the | 917 * not, the hash digest returned here may not match the |
947 * hash digest of actualBitmap, which *has* been run through | 918 * hash digest of actualBitmap, which *has* been run through |
948 * force_all_opaque(). | 919 * force_all_opaque(). |
949 * See comments above complete_bitmap() for more detail. | 920 * See comments above complete_bitmap() for more detail. |
950 */ | 921 */ |
951 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str()); | 922 Expectations expectations = expectationsSource->get(nameWithExte nsion.c_str()); |
952 errors.add(compare_to_expectations(expectations, *actualBitmapAn dDigest, | 923 errors.add(compare_to_expectations(expectations, *actualBitmapAn dDigest, |
953 gm->shortName(), gRec.fName, "", true)); | 924 gm->shortName(), gRec.fName, "", true)); |
954 } else { | 925 } else { |
955 // If we are running without expectations, we still want to | 926 // If we are running without expectations, we still want to |
956 // record the actual results. | 927 // record the actual results. |
957 add_actual_results_to_json_summary(nameWithExtension.c_str(), | 928 add_actual_results_to_json_summary(nameWithExtension.c_str(), |
958 actualBitmapAndDigest->fDiges t, | 929 actualBitmapAndDigest->fDiges t, |
959 ErrorCombination(kMissingExpe ctations_ErrorType), | 930 ErrorCombination(kMissingExpe ctations_ErrorType), |
960 false); | 931 false); |
961 RecordTestResults(ErrorCombination(kMissingExpectations_ErrorTyp e), | 932 errors.add(ErrorCombination(kMissingExpectations_ErrorType)); |
962 shortNamePlusConfig, ""); | |
963 } | 933 } |
964 } | 934 } |
965 | |
966 // TODO: Consider moving this into compare_to_expectations(), | |
967 // similar to fMismatchPath... for now, we don't do that, because | |
968 // we don't want to write out the actual bitmaps for all | |
969 // renderModes of all tests! That would be a lot of files. | |
970 if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { | |
971 errors.add(write_reference_image(gRec, writePath, "", gm->shortName( ), | |
972 actualBitmapAndDigest, document)); | |
973 } | |
974 | |
975 return errors; | 935 return errors; |
976 } | 936 } |
977 | 937 |
978 /** | 938 /** |
979 * Compare actualBitmap to referenceBitmap. | 939 * Compare actualBitmap to referenceBitmap. |
980 * | 940 * |
981 * @param shortName test name, e.g. "selftest1" | 941 * @param shortName test name, e.g. "selftest1" |
982 * @param configName configuration name, e.g. "8888" | 942 * @param configName configuration name, e.g. "8888" |
983 * @param renderModeDescriptor | 943 * @param renderModeDescriptor |
984 * @param actualBitmap actual bitmap generated by this run | 944 * @param actualBitmap actual bitmap generated by this run |
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1025 static SkPicture* stream_to_new_picture(const SkPicture& src) { | 985 static SkPicture* stream_to_new_picture(const SkPicture& src) { |
1026 SkDynamicMemoryWStream storage; | 986 SkDynamicMemoryWStream storage; |
1027 src.serialize(&storage); | 987 src.serialize(&storage); |
1028 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); | 988 SkAutoTUnref<SkStreamAsset> pictReadback(storage.detachAsStream()); |
1029 SkPicture* retval = SkPicture::CreateFromStream(pictReadback); | 989 SkPicture* retval = SkPicture::CreateFromStream(pictReadback); |
1030 return retval; | 990 return retval; |
1031 } | 991 } |
1032 | 992 |
1033 // Test: draw into a bitmap or pdf. | 993 // Test: draw into a bitmap or pdf. |
1034 // Depending on flags, possibly compare to an expected image. | 994 // Depending on flags, possibly compare to an expected image. |
1035 ErrorCombination test_drawing(GM* gm, | 995 ErrorCombination test_drawing(GM* gm, const ConfigData& gRec, |
1036 const ConfigData& gRec, | 996 const SkTDArray<const PDFRasterizerData*> &pdf Rasterizers, |
1037 const char writePath [], | 997 const char writePath [], |
1038 GrSurface* gpuTarget, | 998 GrSurface* gpuTarget, |
1039 SkBitmap* bitmap) { | 999 SkBitmap* bitmap) { |
1000 ErrorCombination errors; | |
1040 SkDynamicMemoryWStream document; | 1001 SkDynamicMemoryWStream document; |
1002 SkString path; | |
1041 | 1003 |
1042 if (gRec.fBackend == kRaster_Backend || | 1004 if (gRec.fBackend == kRaster_Backend || |
1043 gRec.fBackend == kGPU_Backend) { | 1005 gRec.fBackend == kGPU_Backend) { |
1044 // Early exit if we can't generate the image. | 1006 // Early exit if we can't generate the image. |
1045 ErrorCombination errors = generate_image(gm, gRec, gpuTarget, bitmap , false); | 1007 errors.add(generate_image(gm, gRec, gpuTarget, bitmap, false)); |
1046 if (!errors.isEmpty()) { | 1008 if (!errors.isEmpty()) { |
1047 // TODO: Add a test to exercise what the stdout and | 1009 // TODO: Add a test to exercise what the stdout and |
1048 // JSON look like if we get an "early error" while | 1010 // JSON look like if we get an "early error" while |
1049 // trying to generate the image. | 1011 // trying to generate the image. |
1050 return errors; | 1012 return errors; |
1051 } | 1013 } |
1014 BitmapAndDigest bitmapAndDigest(*bitmap); | |
1015 errors.add(compare_test_results_to_stored_expectations( | |
1016 gm, gRec, &bitmapAndDigest)); | |
1017 | |
1018 if (gRec.fFlags & kWrite_ConfigFlag) { | |
1019 path = make_bitmap_filename(writePath, gm->shortName(), gRec.fNa me, | |
1020 "", bitmapAndDigest.fDigest); | |
1021 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); | |
1022 } | |
1052 } else if (gRec.fBackend == kPDF_Backend) { | 1023 } else if (gRec.fBackend == kPDF_Backend) { |
1053 generate_pdf(gm, document); | 1024 generate_pdf(gm, document); |
1054 #if CAN_IMAGE_PDF | 1025 |
1055 SkAutoDataUnref data(document.copyToData()); | 1026 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); |
1056 SkMemoryStream stream(data->data(), data->size()); | 1027 if (gRec.fFlags & kWrite_ConfigFlag) { |
1057 SkPDFDocumentToBitmap(&stream, bitmap); | 1028 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "pdf"); |
1058 #else | 1029 errors.add(write_document(path, documentStream)); |
1059 bitmap = NULL; // we don't generate a bitmap rendering of the PDF f ile | 1030 } |
1060 #endif | 1031 |
1032 for (int i = 0; i < pdfRasterizers.count(); i++) { | |
1033 SkBitmap pdfBitmap; | |
1034 SkASSERT(documentStream->rewind()); | |
1035 bool success = (*pdfRasterizers[i]->fRasterizerFunction) | |
1036 (documentStream.get(), &pdfBitmap); | |
vandebo (ex-Chrome)
2013/08/12 17:41:56
nit: ( should be on previous line.
ducky
2013/08/12 21:57:10
Done.
| |
1037 if (!success) { | |
1038 gm_fprintf(stderr, "FAILED to render PDF for %s using render er %s\n", | |
1039 gm->shortName(), | |
1040 pdfRasterizers[i]->fName); | |
1041 continue; | |
1042 } | |
1043 | |
1044 BitmapAndDigest bitmapAndDigest(pdfBitmap); | |
1045 errors.add(compare_test_results_to_stored_expectations( | |
1046 gm, gRec, &bitmapAndDigest)); | |
1047 | |
1048 SkString configName(gRec.fName); | |
1049 configName.append("_"); | |
1050 configName.append(pdfRasterizers[i]->fName); | |
1051 | |
1052 if (gRec.fFlags & kWrite_ConfigFlag) { | |
1053 path = make_bitmap_filename(writePath, gm->shortName(), conf igName.c_str(), | |
1054 "", bitmapAndDigest.fDigest); | |
1055 errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); | |
1056 } | |
1057 } | |
1061 } else if (gRec.fBackend == kXPS_Backend) { | 1058 } else if (gRec.fBackend == kXPS_Backend) { |
1062 generate_xps(gm, document); | 1059 generate_xps(gm, document); |
1063 bitmap = NULL; // we don't generate a bitmap rendering of the XPS f ile | 1060 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream() ); |
1061 | |
1062 if (gRec.fFlags & kWrite_ConfigFlag) { | |
1063 path = make_filename(writePath, gm->shortName(), gRec.fName, "", "xps"); | |
1064 errors.add(write_document(path, documentStream)); | |
1065 } | |
vandebo (ex-Chrome)
2013/08/12 17:41:56
You've dropped the compare_test_results_to_stored_
ducky
2013/08/12 21:57:10
I don't think anything (useful) happens in that ca
vandebo (ex-Chrome)
2013/08/13 17:48:00
Preferably, refactor CLs should not change functio
ducky
2013/08/14 00:37:11
Ok, I added it back in. I realized that it does ad
| |
1066 } else { | |
1067 SkASSERT(false); | |
1064 } | 1068 } |
1065 | 1069 return errors; |
1066 SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream()); | |
1067 if (NULL == bitmap) { | |
1068 return compare_test_results_to_stored_expectations( | |
1069 gm, gRec, writePath, NULL, documentStream); | |
1070 } else { | |
1071 BitmapAndDigest bitmapAndDigest(*bitmap); | |
1072 return compare_test_results_to_stored_expectations( | |
1073 gm, gRec, writePath, &bitmapAndDigest, documentStream); | |
1074 } | |
1075 } | 1070 } |
1076 | 1071 |
1077 ErrorCombination test_deferred_drawing(GM* gm, | 1072 ErrorCombination test_deferred_drawing(GM* gm, |
1078 const ConfigData& gRec, | 1073 const ConfigData& gRec, |
1079 const SkBitmap& referenceBitmap, | 1074 const SkBitmap& referenceBitmap, |
1080 GrSurface* gpuTarget) { | 1075 GrSurface* gpuTarget) { |
1081 if (gRec.fBackend == kRaster_Backend || | 1076 if (gRec.fBackend == kRaster_Backend || |
1082 gRec.fBackend == kGPU_Backend) { | 1077 gRec.fBackend == kGPU_Backend) { |
1083 const char renderModeDescriptor[] = "-deferred"; | 1078 const char renderModeDescriptor[] = "-deferred"; |
1084 SkBitmap bitmap; | 1079 SkBitmap bitmap; |
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1216 Json::Value fJsonActualResults_Succeeded; | 1211 Json::Value fJsonActualResults_Succeeded; |
1217 | 1212 |
1218 }; // end of GMMain class definition | 1213 }; // end of GMMain class definition |
1219 | 1214 |
1220 #if SK_SUPPORT_GPU | 1215 #if SK_SUPPORT_GPU |
1221 static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_G LContextType; | 1216 static const GLContextType kDontCare_GLContextType = GrContextFactory::kNative_G LContextType; |
1222 #else | 1217 #else |
1223 static const GLContextType kDontCare_GLContextType = 0; | 1218 static const GLContextType kDontCare_GLContextType = 0; |
1224 #endif | 1219 #endif |
1225 | 1220 |
1221 #if defined(SK_BUILD_FOR_MAC) || defined(SK_BUILD_POPPLER) | |
vandebo (ex-Chrome)
2013/08/12 17:41:56
You should probably get rid of CAN_IMAGE_PDF, sinc
ducky
2013/08/12 21:57:10
Done.
This was left in to have an accurate Config
| |
1222 #define CAN_IMAGE_PDF 1 | |
1223 #else | |
1224 #define CAN_IMAGE_PDF 0 | |
1225 #endif | |
1226 // If the platform does not support writing PNGs of PDFs then there will be no | 1226 // If the platform does not support writing PNGs of PDFs then there will be no |
1227 // reference images to read. However, we can always write the .pdf files | 1227 // reference images to read. However, we can always write the .pdf files |
1228 static const ConfigFlags kPDFConfigFlags = CAN_IMAGE_PDF ? kRW_ConfigFlag : | 1228 static const ConfigFlags kPDFConfigFlags = CAN_IMAGE_PDF ? kRW_ConfigFlag : |
1229 kWrite_ConfigFlag; | 1229 kWrite_ConfigFlag; |
1230 | 1230 |
1231 static const ConfigData gRec[] = { | 1231 static const ConfigData gRec[] = { |
1232 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "8888", true }, | 1232 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "8888", true }, |
1233 #if 0 // stop testing this (for now at least) since we want to remove support for it (soon please!!!) | 1233 #if 0 // stop testing this (for now at least) since we want to remove support for it (soon please!!!) |
1234 { SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "4444", true }, | 1234 { SkBitmap::kARGB_4444_Config, kRaster_Backend, kDontCare_GLContextType, 0, kRW_ConfigFlag, "4444", true }, |
1235 #endif | 1235 #endif |
(...skipping 20 matching lines...) Expand all Loading... | |
1256 #endif // SK_SUPPORT_GPU | 1256 #endif // SK_SUPPORT_GPU |
1257 #ifdef SK_SUPPORT_XPS | 1257 #ifdef SK_SUPPORT_XPS |
1258 /* At present we have no way of comparing XPS files (either natively or by c onverting to PNG). */ | 1258 /* At present we have no way of comparing XPS files (either natively or by c onverting to PNG). */ |
1259 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps", true }, | 1259 { SkBitmap::kARGB_8888_Config, kXPS_Backend, kDontCare_GLContextType, 0, kWrite_ConfigFlag, "xps", true }, |
1260 #endif // SK_SUPPORT_XPS | 1260 #endif // SK_SUPPORT_XPS |
1261 #ifdef SK_SUPPORT_PDF | 1261 #ifdef SK_SUPPORT_PDF |
1262 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf", true }, | 1262 { SkBitmap::kARGB_8888_Config, kPDF_Backend, kDontCare_GLContextType, 0, kPDFConfigFlags, "pdf", true }, |
1263 #endif // SK_SUPPORT_PDF | 1263 #endif // SK_SUPPORT_PDF |
1264 }; | 1264 }; |
1265 | 1265 |
1266 static const PDFRasterizerData kPDFRasterizers[] = { | |
1267 #ifdef SK_BUILD_FOR_MAC | |
1268 { &SkPDFDocumentToBitmap, "macnative", true }, | |
1269 #endif | |
1270 #ifdef SK_BUILD_POPPLER | |
1271 { &SkPopplerRasterizePDF, "poppler", true }, | |
1272 #endif | |
1273 }; | |
1274 | |
1266 static const char kDefaultsConfigStr[] = "defaults"; | 1275 static const char kDefaultsConfigStr[] = "defaults"; |
1267 static const char kExcludeConfigChar = '~'; | 1276 static const char kExcludeConfigChar = '~'; |
1268 | 1277 |
1269 static SkString configUsage() { | 1278 static SkString configUsage() { |
1270 SkString result; | 1279 SkString result; |
1271 result.appendf("Space delimited list of which configs to run. Possible optio ns: ["); | 1280 result.appendf("Space delimited list of which configs to run. Possible optio ns: ["); |
1272 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1281 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
1273 SkASSERT(gRec[i].fName != kDefaultsConfigStr); | 1282 SkASSERT(gRec[i].fName != kDefaultsConfigStr); |
1274 if (i > 0) { | 1283 if (i > 0) { |
1275 result.append("|"); | 1284 result.append("|"); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1307 result.appendf("E.g. \"--config %s %c%s %s\" will run these configs:\n\t%s % s", | 1316 result.appendf("E.g. \"--config %s %c%s %s\" will run these configs:\n\t%s % s", |
1308 kDefaultsConfigStr, | 1317 kDefaultsConfigStr, |
1309 kExcludeConfigChar, | 1318 kExcludeConfigChar, |
1310 firstDefault.c_str(), | 1319 firstDefault.c_str(), |
1311 nonDefault.c_str(), | 1320 nonDefault.c_str(), |
1312 allButFirstDefaults.c_str(), | 1321 allButFirstDefaults.c_str(), |
1313 nonDefault.c_str()); | 1322 nonDefault.c_str()); |
1314 return result; | 1323 return result; |
1315 } | 1324 } |
1316 | 1325 |
1326 static SkString pdfRasterizerUsage() { | |
1327 SkString result; | |
1328 result.appendf("Space delimited list of which PDF rasterizers to run. Possib le options: ["); | |
1329 for (size_t i = 0; i < SK_ARRAY_COUNT(kPDFRasterizers); ++i) { | |
1330 if (i > 0) { | |
1331 result.append("|"); | |
vandebo (ex-Chrome)
2013/08/12 17:41:56
"|" -> ", "
ducky
2013/08/12 21:57:10
Done.
Side note: this style makes more sense, but
| |
1332 } | |
1333 result.append(kPDFRasterizers[i].fName); | |
1334 } | |
1335 result.append("]\n"); | |
1336 result.append("The default value is: \""); | |
1337 for (size_t i = 0; i < SK_ARRAY_COUNT(kPDFRasterizers); ++i) { | |
1338 if (kPDFRasterizers[i].fRunByDefault) { | |
1339 if (i > 0) { | |
1340 result.append(" "); | |
vandebo (ex-Chrome)
2013/08/12 17:41:56
" " -> ", "
ducky
2013/08/12 21:57:10
I think the space makes more sense, since this out
| |
1341 } | |
1342 result.append(kPDFRasterizers[i].fName); | |
1343 } | |
1344 } | |
1345 result.append("\""); | |
1346 return result; | |
1347 } | |
1348 | |
1317 // Macro magic to convert a numeric preprocessor token into a string. | 1349 // Macro magic to convert a numeric preprocessor token into a string. |
1318 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor -token-to-a-string | 1350 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor -token-to-a-string |
1319 // This should probably be moved into one of our common headers... | 1351 // This should probably be moved into one of our common headers... |
1320 #define TOSTRING_INTERNAL(x) #x | 1352 #define TOSTRING_INTERNAL(x) #x |
1321 #define TOSTRING(x) TOSTRING_INTERNAL(x) | 1353 #define TOSTRING(x) TOSTRING_INTERNAL(x) |
1322 | 1354 |
1323 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). | 1355 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). |
1324 DEFINE_string(config, "", configUsage().c_str()); | 1356 DEFINE_string(config, "", configUsage().c_str()); |
1357 DEFINE_string(pdfRasterizers, "", pdfRasterizerUsage().c_str()); | |
1325 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); | 1358 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); |
1326 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); | 1359 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); |
1327 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); | 1360 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); |
1328 #if SK_SUPPORT_GPU | 1361 #if SK_SUPPORT_GPU |
1329 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or " | 1362 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si ze or " |
1330 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means " | 1363 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value means " |
1331 "use the default. 0 for either disables the cache."); | 1364 "use the default. 0 for either disables the cache."); |
1332 #endif | 1365 #endif |
1333 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " | 1366 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " |
1334 "when reading/writing files."); | 1367 "when reading/writing files."); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1403 | 1436 |
1404 static int findConfig(const char config[]) { | 1437 static int findConfig(const char config[]) { |
1405 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { | 1438 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
1406 if (!strcmp(config, gRec[i].fName)) { | 1439 if (!strcmp(config, gRec[i].fName)) { |
1407 return (int) i; | 1440 return (int) i; |
1408 } | 1441 } |
1409 } | 1442 } |
1410 return -1; | 1443 return -1; |
1411 } | 1444 } |
1412 | 1445 |
1446 static const PDFRasterizerData* findPDFRasterizer(const char rasterizer[]) { | |
1447 for (size_t i = 0; i < SK_ARRAY_COUNT(kPDFRasterizers); i++) { | |
1448 if (!strcmp(rasterizer, kPDFRasterizers[i].fName)) { | |
1449 return &kPDFRasterizers[i]; | |
1450 } | |
1451 } | |
1452 return NULL; | |
1453 } | |
1454 | |
1413 namespace skiagm { | 1455 namespace skiagm { |
1414 #if SK_SUPPORT_GPU | 1456 #if SK_SUPPORT_GPU |
1415 SkAutoTUnref<GrContext> gGrContext; | 1457 SkAutoTUnref<GrContext> gGrContext; |
1416 /** | 1458 /** |
1417 * Sets the global GrContext, accessible by individual GMs | 1459 * Sets the global GrContext, accessible by individual GMs |
1418 */ | 1460 */ |
1419 static void SetGr(GrContext* grContext) { | 1461 static void SetGr(GrContext* grContext) { |
1420 SkSafeRef(grContext); | 1462 SkSafeRef(grContext); |
1421 gGrContext.reset(grContext); | 1463 gGrContext.reset(grContext); |
1422 } | 1464 } |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1459 } | 1501 } |
1460 } | 1502 } |
1461 | 1503 |
1462 /** | 1504 /** |
1463 * Run this test in a number of different configs (8888, 565, PDF, | 1505 * Run this test in a number of different configs (8888, 565, PDF, |
1464 * etc.), confirming that the resulting bitmaps match expectations | 1506 * etc.), confirming that the resulting bitmaps match expectations |
1465 * (which may be different for each config). | 1507 * (which may be different for each config). |
1466 * | 1508 * |
1467 * Returns all errors encountered while doing so. | 1509 * Returns all errors encountered while doing so. |
1468 */ | 1510 */ |
1469 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, | 1511 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, |
1512 const SkTDArray<size_t> &configs, | |
1513 const SkTDArray<const PDFRasterizerData*> &pdfRasterizers, | |
1470 GrContextFactory *grFactory); | 1514 GrContextFactory *grFactory); |
1471 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, const SkTDArray<si ze_t> &configs, | 1515 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, |
1516 const SkTDArray<size_t> &configs, | |
1517 const SkTDArray<const PDFRasterizerData*> &pdfRasterizers, | |
1472 GrContextFactory *grFactory) { | 1518 GrContextFactory *grFactory) { |
1473 const char renderModeDescriptor[] = ""; | 1519 const char renderModeDescriptor[] = ""; |
1474 ErrorCombination errorsForAllConfigs; | 1520 ErrorCombination errorsForAllConfigs; |
1475 uint32_t gmFlags = gm->getFlags(); | 1521 uint32_t gmFlags = gm->getFlags(); |
1476 | 1522 |
1477 for (int i = 0; i < configs.count(); i++) { | 1523 for (int i = 0; i < configs.count(); i++) { |
1478 ConfigData config = gRec[configs[i]]; | 1524 ConfigData config = gRec[configs[i]]; |
1479 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(g m->shortName(), | 1525 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(g m->shortName(), |
1480 c onfig.fName); | 1526 c onfig.fName); |
1481 | 1527 |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1552 #endif | 1598 #endif |
1553 | 1599 |
1554 SkBitmap comparisonBitmap; | 1600 SkBitmap comparisonBitmap; |
1555 | 1601 |
1556 const char* writePath; | 1602 const char* writePath; |
1557 if (FLAGS_writePath.count() == 1) { | 1603 if (FLAGS_writePath.count() == 1) { |
1558 writePath = FLAGS_writePath[0]; | 1604 writePath = FLAGS_writePath[0]; |
1559 } else { | 1605 } else { |
1560 writePath = NULL; | 1606 writePath = NULL; |
1561 } | 1607 } |
1608 | |
1562 if (errorsForThisConfig.isEmpty()) { | 1609 if (errorsForThisConfig.isEmpty()) { |
1563 errorsForThisConfig.add(gmmain.test_drawing(gm,config, writePath, gp uTarget, | 1610 errorsForThisConfig.add(gmmain.test_drawing(gm, config, pdfRasterize rs, |
1611 writePath, gpuTarget, | |
1564 &comparisonBitmap)); | 1612 &comparisonBitmap)); |
1613 gmmain.RecordTestResults(errorsForThisConfig, shortNamePlusConfig, " "); | |
1565 } | 1614 } |
1566 | 1615 |
1567 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && | 1616 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && |
1568 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) { | 1617 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) { |
1569 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap, | 1618 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap, |
1570 gpuTarget)); | 1619 gpuTarget)); |
1571 } | 1620 } |
1572 | 1621 |
1573 errorsForAllConfigs.add(errorsForThisConfig); | 1622 errorsForAllConfigs.add(errorsForThisConfig); |
1574 } | 1623 } |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1863 SkString configStr("These configs will be run: "); | 1912 SkString configStr("These configs will be run: "); |
1864 // show the user the config that will run. | 1913 // show the user the config that will run. |
1865 for (int i = 0; i < outConfigs->count(); ++i) { | 1914 for (int i = 0; i < outConfigs->count(); ++i) { |
1866 configStr.appendf("%s ", gRec[(*outConfigs)[i]].fName); | 1915 configStr.appendf("%s ", gRec[(*outConfigs)[i]].fName); |
1867 } | 1916 } |
1868 gm_fprintf(stdout, "%s\n", configStr.c_str()); | 1917 gm_fprintf(stdout, "%s\n", configStr.c_str()); |
1869 | 1918 |
1870 return true; | 1919 return true; |
1871 } | 1920 } |
1872 | 1921 |
1922 static bool parse_flags_pdf_rasterizers(SkTDArray<const PDFRasterizerData*>* out Rasterizers) { | |
1923 for (int i = 0; i < FLAGS_pdfRasterizers.count(); i++) { | |
1924 const char* rasterizer = FLAGS_pdfRasterizers[i]; | |
1925 const PDFRasterizerData* rasterizerPtr = findPDFRasterizer(rasterizer); | |
1926 | |
1927 if (rasterizer != NULL) { | |
1928 appendUnique<const PDFRasterizerData*>(outRasterizers, | |
1929 rasterizerPtr); | |
1930 } else { | |
1931 gm_fprintf(stderr, "unrecognized rasterizer %s\n", rasterizer); | |
1932 return false; | |
1933 } | |
1934 } | |
1935 | |
1936 if (outRasterizers->count() == 0) { | |
vandebo (ex-Chrome)
2013/08/12 17:41:56
Should this test that the pdf rasterizer flag wasn
ducky
2013/08/12 21:57:10
That would be ideal, but I'm not sure how to do th
| |
1937 // if no config is specified by user, add the defaults | |
1938 for (size_t i = 0; i < SK_ARRAY_COUNT(kPDFRasterizers); ++i) { | |
1939 if (kPDFRasterizers[i].fRunByDefault) { | |
1940 *outRasterizers->append() = &kPDFRasterizers[i]; | |
1941 } | |
1942 } | |
1943 } | |
1944 | |
1945 // now show the user the set of configs that will be run. | |
1946 SkString configStr("These PDF rasterizers will be run: "); | |
1947 // show the user the config that will run. | |
1948 for (int i = 0; i < outRasterizers->count(); ++i) { | |
1949 configStr.appendf("%s ", (*outRasterizers)[i]->fName); | |
1950 } | |
1951 gm_fprintf(stdout, "%s\n", configStr.c_str()); | |
1952 | |
1953 return true; | |
1954 } | |
1955 | |
1873 static bool parse_flags_ignore_error_types(ErrorCombination* outErrorTypes) { | 1956 static bool parse_flags_ignore_error_types(ErrorCombination* outErrorTypes) { |
1874 if (FLAGS_ignoreErrorTypes.count() > 0) { | 1957 if (FLAGS_ignoreErrorTypes.count() > 0) { |
1875 *outErrorTypes = ErrorCombination(); | 1958 *outErrorTypes = ErrorCombination(); |
1876 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { | 1959 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { |
1877 ErrorType type; | 1960 ErrorType type; |
1878 const char *name = FLAGS_ignoreErrorTypes[i]; | 1961 const char *name = FLAGS_ignoreErrorTypes[i]; |
1879 if (!getErrorTypeByName(name, &type)) { | 1962 if (!getErrorTypeByName(name, &type)) { |
1880 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e); | 1963 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam e); |
1881 return false; | 1964 return false; |
1882 } else { | 1965 } else { |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2005 | 2088 |
2006 setSystemPreferences(); | 2089 setSystemPreferences(); |
2007 GMMain gmmain; | 2090 GMMain gmmain; |
2008 | 2091 |
2009 SkString usage; | 2092 SkString usage; |
2010 usage.printf("Run the golden master tests.\n"); | 2093 usage.printf("Run the golden master tests.\n"); |
2011 SkCommandLineFlags::SetUsage(usage.c_str()); | 2094 SkCommandLineFlags::SetUsage(usage.c_str()); |
2012 SkCommandLineFlags::Parse(argc, argv); | 2095 SkCommandLineFlags::Parse(argc, argv); |
2013 | 2096 |
2014 SkTDArray<size_t> configs; | 2097 SkTDArray<size_t> configs; |
2098 | |
2015 int moduloRemainder = -1; | 2099 int moduloRemainder = -1; |
2016 int moduloDivisor = -1; | 2100 int moduloDivisor = -1; |
2101 SkTDArray<const PDFRasterizerData*> pdfRasterizers; | |
2017 SkTDArray<SkScalar> tileGridReplayScales; | 2102 SkTDArray<SkScalar> tileGridReplayScales; |
2018 #if SK_SUPPORT_GPU | 2103 #if SK_SUPPORT_GPU |
2019 GrContextFactory* grFactory = new GrContextFactory; | 2104 GrContextFactory* grFactory = new GrContextFactory; |
2020 #else | 2105 #else |
2021 GrContextFactory* grFactory = NULL; | 2106 GrContextFactory* grFactory = NULL; |
2022 #endif | 2107 #endif |
2023 SkTDArray<const char*> matchStrs; | 2108 SkTDArray<const char*> matchStrs; |
2024 | 2109 |
2025 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || | 2110 if (!parse_flags_modulo(&moduloRemainder, &moduloDivisor) || |
2026 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || | 2111 !parse_flags_ignore_error_types(&gmmain.fIgnorableErrorTypes) || |
2027 #if SK_SUPPORT_GPU | 2112 #if SK_SUPPORT_GPU |
2028 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || | 2113 !parse_flags_gpu_cache(&gGpuCacheSizeBytes, &gGpuCacheSizeCount) || |
2029 #endif | 2114 #endif |
2030 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || | 2115 !parse_flags_tile_grid_replay_scales(&tileGridReplayScales) || |
2031 !parse_flags_gmmain_paths(&gmmain) || | 2116 !parse_flags_gmmain_paths(&gmmain) || |
2032 !parse_flags_resource_path() || | 2117 !parse_flags_resource_path() || |
2033 !parse_flags_match_strs(&matchStrs) || | 2118 !parse_flags_match_strs(&matchStrs) || |
2034 !parse_flags_jpeg_quality() || | 2119 !parse_flags_jpeg_quality() || |
2035 !parse_flags_configs(&configs, grFactory)) { | 2120 !parse_flags_configs(&configs, grFactory) || |
2121 !parse_flags_pdf_rasterizers(&pdfRasterizers)) { | |
2036 return -1; | 2122 return -1; |
2037 } | 2123 } |
2038 | 2124 |
2039 if (FLAGS_verbose) { | 2125 if (FLAGS_verbose) { |
2040 if (FLAGS_writePath.count() == 1) { | 2126 if (FLAGS_writePath.count() == 1) { |
2041 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); | 2127 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); |
2042 } | 2128 } |
2043 if (NULL != gmmain.fMismatchPath) { | 2129 if (NULL != gmmain.fMismatchPath) { |
2044 gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPat h); | 2130 gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPat h); |
2045 } | 2131 } |
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2093 | 2179 |
2094 if (SkCommandLineFlags::ShouldSkip(matchStrs, shortName)) { | 2180 if (SkCommandLineFlags::ShouldSkip(matchStrs, shortName)) { |
2095 continue; | 2181 continue; |
2096 } | 2182 } |
2097 | 2183 |
2098 gmsRun++; | 2184 gmsRun++; |
2099 SkISize size = gm->getISize(); | 2185 SkISize size = gm->getISize(); |
2100 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, | 2186 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, |
2101 size.width(), size.height()); | 2187 size.width(), size.height()); |
2102 | 2188 |
2103 run_multiple_configs(gmmain, gm, configs, grFactory); | 2189 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, grFactory); |
2104 | 2190 |
2105 SkBitmap comparisonBitmap; | 2191 SkBitmap comparisonBitmap; |
2106 const ConfigData compareConfig = | 2192 const ConfigData compareConfig = |
2107 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false }; | 2193 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT ype, 0, kRW_ConfigFlag, "comparison", false }; |
2108 gmmain.generate_image(gm, compareConfig, NULL, &comparisonBitmap, false) ; | 2194 gmmain.generate_image(gm, compareConfig, NULL, &comparisonBitmap, false) ; |
2109 | 2195 |
2110 // TODO(epoger): only run this if gmmain.generate_image() succeeded? | 2196 // TODO(epoger): only run this if gmmain.generate_image() succeeded? |
2111 // Otherwise, what are we comparing against? | 2197 // Otherwise, what are we comparing against? |
2112 run_multiple_modes(gmmain, gm, compareConfig, comparisonBitmap, tileGrid ReplayScales); | 2198 run_multiple_modes(gmmain, gm, compareConfig, comparisonBitmap, tileGrid ReplayScales); |
2113 } | 2199 } |
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2177 if (FLAGS_forceBWtext) { | 2263 if (FLAGS_forceBWtext) { |
2178 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2264 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2179 } | 2265 } |
2180 } | 2266 } |
2181 | 2267 |
2182 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2268 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2183 int main(int argc, char * const argv[]) { | 2269 int main(int argc, char * const argv[]) { |
2184 return tool_main(argc, (char**) argv); | 2270 return tool_main(argc, (char**) argv); |
2185 } | 2271 } |
2186 #endif | 2272 #endif |
OLD | NEW |