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 1171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1182 | 1182 |
1183 // Macro magic to convert a numeric preprocessor token into a string. | 1183 // Macro magic to convert a numeric preprocessor token into a string. |
1184 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor
-token-to-a-string | 1184 // Adapted from http://stackoverflow.com/questions/240353/convert-a-preprocessor
-token-to-a-string |
1185 // This should probably be moved into one of our common headers... | 1185 // This should probably be moved into one of our common headers... |
1186 #define TOSTRING_INTERNAL(x) #x | 1186 #define TOSTRING_INTERNAL(x) #x |
1187 #define TOSTRING(x) TOSTRING_INTERNAL(x) | 1187 #define TOSTRING(x) TOSTRING_INTERNAL(x) |
1188 | 1188 |
1189 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). | 1189 // Alphabetized ignoring "no" prefix ("readPath", "noreplay", "resourcePath"). |
1190 DEFINE_string(config, "", configUsage().c_str()); | 1190 DEFINE_string(config, "", configUsage().c_str()); |
1191 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); | 1191 DEFINE_bool(deferred, true, "Exercise the deferred rendering test pass."); |
1192 DEFINE_bool(enableMissingWarning, true, "Print message to stderr (but don't fail
) if " | |
1193 "unable to read a reference image for any tests."); | |
1194 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); | 1192 DEFINE_string(excludeConfig, "", "Space delimited list of configs to skip."); |
1195 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); | 1193 DEFINE_bool(forceBWtext, false, "Disable text anti-aliasing."); |
1196 #if SK_SUPPORT_GPU | 1194 #if SK_SUPPORT_GPU |
1197 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si
ze or " | 1195 DEFINE_string(gpuCacheSize, "", "<bytes> <count>: Limit the gpu cache to byte si
ze or " |
1198 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value
means " | 1196 "object count. " TOSTRING(DEFAULT_CACHE_VALUE) " for either value
means " |
1199 "use the default. 0 for either disables the cache."); | 1197 "use the default. 0 for either disables the cache."); |
1200 #endif | 1198 #endif |
1201 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " | 1199 DEFINE_bool(hierarchy, false, "Whether to use multilevel directory structure " |
1202 "when reading/writing files."); | 1200 "when reading/writing files."); |
1203 DEFINE_string(match, "", "Only run tests whose name includes this substring/the
se substrings " | 1201 DEFINE_string(match, "", "Only run tests whose name includes this substring/the
se substrings " |
1204 "(more than one can be supplied, separated by spaces)."); | 1202 "(more than one can be supplied, separated by spaces)."); |
1205 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " | 1203 DEFINE_string(mismatchPath, "", "Write images for tests that failed due to " |
1206 "pixel mismatches into this directory."); | 1204 "pixel mismatches into this directory."); |
1207 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " | 1205 DEFINE_string(modulo, "", "[--modulo <remainder> <divisor>]: only run tests for
which " |
1208 "testIndex %% divisor == remainder."); | 1206 "testIndex %% divisor == remainder."); |
1209 DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass."); | 1207 DEFINE_bool(pdf, true, "Exercise the pdf rendering test pass."); |
1210 DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass."); | 1208 DEFINE_bool(pipe, true, "Exercise the SkGPipe replay test pass."); |
1211 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report
" | 1209 DEFINE_string2(readPath, r, "", "Read reference images from this dir, and report
" |
1212 "any differences between those and the newly generated ones."); | 1210 "any differences between those and the newly generated ones."); |
1213 DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass."); | 1211 DEFINE_bool(replay, true, "Exercise the SkPicture replay test pass."); |
1214 DEFINE_string2(resourcePath, i, "", "Directory that stores image resources."); | 1212 DEFINE_string2(resourcePath, i, "", "Directory that stores image resources."); |
1215 DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass."); | 1213 DEFINE_bool(rtree, true, "Exercise the R-Tree variant of SkPicture test pass."); |
1216 DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserializa
tion test pass."); | 1214 DEFINE_bool(serialize, true, "Exercise the SkPicture serialization & deserializa
tion test pass."); |
1217 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); | 1215 DEFINE_bool(simulatePipePlaybackFailure, false, "Simulate a rendering failure in
pipe mode only."); |
1218 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); | 1216 DEFINE_bool(tiledPipe, false, "Exercise tiled SkGPipe replay."); |
1219 DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture."); | 1217 DEFINE_bool(tileGrid, true, "Exercise the tile grid variant of SkPicture."); |
1220 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point
scale " | 1218 DEFINE_string(tileGridReplayScales, "", "Space separated list of floating-point
scale " |
1221 "factors to be used for tileGrid playback testing. Default value:
1.0"); | 1219 "factors to be used for tileGrid playback testing. Default value:
1.0"); |
1222 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t
o this file."); | 1220 DEFINE_string(writeJsonSummaryPath, "", "Write a JSON-formatted result summary t
o this file."); |
1223 DEFINE_bool2(verbose, v, false, "Print diagnostics (e.g. list each config to be
tested)."); | 1221 DEFINE_bool2(verbose, v, false, "Give more detail (e.g. list all GMs run, more i
nfo about " |
| 1222 "each test)."); |
1224 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); | 1223 DEFINE_string2(writePath, w, "", "Write rendered images into this directory."); |
1225 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.")
; | 1224 DEFINE_string2(writePicturePath, p, "", "Write .skp files into this directory.")
; |
1226 | 1225 |
1227 static int findConfig(const char config[]) { | 1226 static int findConfig(const char config[]) { |
1228 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { | 1227 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); i++) { |
1229 if (!strcmp(config, gRec[i].fName)) { | 1228 if (!strcmp(config, gRec[i].fName)) { |
1230 return (int) i; | 1229 return (int) i; |
1231 } | 1230 } |
1232 } | 1231 } |
1233 return -1; | 1232 return -1; |
(...skipping 444 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1678 } | 1677 } |
1679 } | 1678 } |
1680 | 1679 |
1681 #if SK_SUPPORT_GPU | 1680 #if SK_SUPPORT_GPU |
1682 GrContextFactory* grFactory = new GrContextFactory; | 1681 GrContextFactory* grFactory = new GrContextFactory; |
1683 for (int i = 0; i < configs.count(); ++i) { | 1682 for (int i = 0; i < configs.count(); ++i) { |
1684 size_t index = configs[i]; | 1683 size_t index = configs[i]; |
1685 if (kGPU_Backend == gRec[index].fBackend) { | 1684 if (kGPU_Backend == gRec[index].fBackend) { |
1686 GrContext* ctx = grFactory->get(gRec[index].fGLContextType); | 1685 GrContext* ctx = grFactory->get(gRec[index].fGLContextType); |
1687 if (NULL == ctx) { | 1686 if (NULL == ctx) { |
1688 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.", | 1687 gm_fprintf(stderr, "GrContext could not be created for config %s
." |
1689 gRec[index].fName); | 1688 " Config will be skipped.\n", gRec[index].fName); |
1690 configs.remove(i); | 1689 configs.remove(i); |
1691 --i; | 1690 --i; |
1692 } | 1691 } |
1693 if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { | 1692 if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { |
1694 SkDebugf("Sample count (%d) of config %s is not supported. Confi
g will be skipped.", | 1693 gm_fprintf(stderr, "Sample count (%d) of config %s is not suppor
ted." |
1695 gRec[index].fSampleCnt, gRec[index].fName); | 1694 " Config will be skipped.\n", gRec[index].fSampleCnt,
gRec[index].fName); |
1696 configs.remove(i); | 1695 configs.remove(i); |
1697 --i; | 1696 --i; |
1698 } | 1697 } |
1699 } | 1698 } |
1700 } | 1699 } |
1701 #else | 1700 #else |
1702 GrContextFactory* grFactory = NULL; | 1701 GrContextFactory* grFactory = NULL; |
1703 #endif | 1702 #endif |
1704 | 1703 |
1705 if (FLAGS_resourcePath.count() == 1) { | 1704 if (FLAGS_resourcePath.count() == 1) { |
1706 GM::SetResourcePath(FLAGS_resourcePath[0]); | 1705 GM::SetResourcePath(FLAGS_resourcePath[0]); |
1707 } | 1706 } |
1708 | 1707 |
1709 if (FLAGS_readPath.count() == 1) { | 1708 if (FLAGS_readPath.count() == 1) { |
1710 const char* readPath = FLAGS_readPath[0]; | 1709 const char* readPath = FLAGS_readPath[0]; |
1711 if (!sk_exists(readPath)) { | 1710 if (!sk_exists(readPath)) { |
1712 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); | 1711 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); |
1713 return -1; | 1712 return -1; |
1714 } | 1713 } |
1715 if (sk_isdir(readPath)) { | 1714 if (sk_isdir(readPath)) { |
1716 gm_fprintf(stdout, "reading from %s\n", readPath); | 1715 if (FLAGS_verbose) { |
| 1716 gm_fprintf(stdout, "reading from %s\n", readPath); |
| 1717 } |
1717 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1718 gmmain.fExpectationsSource.reset(SkNEW_ARGS( |
1718 IndividualImageExpectationsSource, | 1719 IndividualImageExpectationsSource, (readPath))); |
1719 (readPath, FLAGS_enableMissingWarning))); | |
1720 } else { | 1720 } else { |
1721 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n
", readPath); | 1721 if (FLAGS_verbose) { |
| 1722 gm_fprintf(stdout, "reading expectations from JSON summary file
%s\n", readPath); |
| 1723 } |
1722 gmmain.fExpectationsSource.reset(SkNEW_ARGS( | 1724 gmmain.fExpectationsSource.reset(SkNEW_ARGS( |
1723 JsonExpectationsSource, (readPath))); | 1725 JsonExpectationsSource, (readPath))); |
1724 } | 1726 } |
1725 } | 1727 } |
1726 if (FLAGS_writePath.count() == 1) { | 1728 if (FLAGS_verbose) { |
1727 gm_fprintf(stderr, "writing to %s\n", FLAGS_writePath[0]); | 1729 if (FLAGS_writePath.count() == 1) { |
1728 } | 1730 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); |
1729 if (FLAGS_writePicturePath.count() == 1) { | 1731 } |
1730 gm_fprintf(stderr, "writing pictures to %s\n", FLAGS_writePicturePath[0]
); | 1732 if (FLAGS_writePicturePath.count() == 1) { |
1731 } | 1733 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat
h[0]); |
1732 if (FLAGS_resourcePath.count() == 1) { | 1734 } |
1733 gm_fprintf(stderr, "reading resources from %s\n", FLAGS_resourcePath[0])
; | 1735 if (FLAGS_resourcePath.count() == 1) { |
| 1736 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath
[0]); |
| 1737 } |
1734 } | 1738 } |
1735 | 1739 |
1736 if (moduloDivisor <= 0) { | 1740 if (moduloDivisor <= 0) { |
1737 moduloRemainder = -1; | 1741 moduloRemainder = -1; |
1738 } | 1742 } |
1739 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { | 1743 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { |
1740 moduloRemainder = -1; | 1744 moduloRemainder = -1; |
1741 } | 1745 } |
1742 | 1746 |
1743 int gmsRun = 0; | 1747 int gmsRun = 0; |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1775 } | 1779 } |
1776 | 1780 |
1777 const char* shortName = gm->shortName(); | 1781 const char* shortName = gm->shortName(); |
1778 if (skip_name(FLAGS_match, shortName)) { | 1782 if (skip_name(FLAGS_match, shortName)) { |
1779 SkDELETE(gm); | 1783 SkDELETE(gm); |
1780 continue; | 1784 continue; |
1781 } | 1785 } |
1782 | 1786 |
1783 gmsRun++; | 1787 gmsRun++; |
1784 SkISize size = gm->getISize(); | 1788 SkISize size = gm->getISize(); |
1785 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, | 1789 if (FLAGS_verbose) { |
1786 size.width(), size.height()); | 1790 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), s
hortName, |
| 1791 size.width(), size.height()); |
| 1792 } |
1787 | 1793 |
1788 run_multiple_configs(gmmain, gm, configs, grFactory); | 1794 run_multiple_configs(gmmain, gm, configs, grFactory); |
1789 | 1795 |
1790 SkBitmap comparisonBitmap; | 1796 SkBitmap comparisonBitmap; |
1791 const ConfigData compareConfig = | 1797 const ConfigData compareConfig = |
1792 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT
ype, 0, kRW_ConfigFlag, "comparison", false }; | 1798 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT
ype, 0, kRW_ConfigFlag, "comparison", false }; |
1793 gmmain.generate_image(gm, compareConfig, NULL, &comparisonBitmap, false)
; | 1799 gmmain.generate_image(gm, compareConfig, NULL, &comparisonBitmap, false)
; |
1794 | 1800 |
1795 // TODO(epoger): only run this if gmmain.generate_image() succeeded? | 1801 // TODO(epoger): only run this if gmmain.generate_image() succeeded? |
1796 // Otherwise, what are we comparing against? | 1802 // Otherwise, what are we comparing against? |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1843 SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); | 1849 SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); |
1844 stream.write(jsonStdString.c_str(), jsonStdString.length()); | 1850 stream.write(jsonStdString.c_str(), jsonStdString.length()); |
1845 } | 1851 } |
1846 | 1852 |
1847 #if SK_SUPPORT_GPU | 1853 #if SK_SUPPORT_GPU |
1848 | 1854 |
1849 #if GR_CACHE_STATS | 1855 #if GR_CACHE_STATS |
1850 for (int i = 0; i < configs.count(); i++) { | 1856 for (int i = 0; i < configs.count(); i++) { |
1851 ConfigData config = gRec[configs[i]]; | 1857 ConfigData config = gRec[configs[i]]; |
1852 | 1858 |
1853 if (kGPU_Backend == config.fBackend) { | 1859 if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) { |
1854 GrContext* gr = grFactory->get(config.fGLContextType); | 1860 GrContext* gr = grFactory->get(config.fGLContextType); |
1855 | 1861 |
1856 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); | 1862 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); |
1857 gr->printCacheStats(); | 1863 gr->printCacheStats(); |
1858 } | 1864 } |
1859 } | 1865 } |
1860 #endif | 1866 #endif |
1861 | 1867 |
1862 delete grFactory; | 1868 delete grFactory; |
1863 #endif | 1869 #endif |
1864 SkGraphics::Term(); | 1870 SkGraphics::Term(); |
1865 | 1871 |
1866 return (reportError) ? -1 : 0; | 1872 return (reportError) ? -1 : 0; |
1867 } | 1873 } |
1868 | 1874 |
1869 void GMMain::installFilter(SkCanvas* canvas) { | 1875 void GMMain::installFilter(SkCanvas* canvas) { |
1870 if (FLAGS_forceBWtext) { | 1876 if (FLAGS_forceBWtext) { |
1871 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 1877 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
1872 } | 1878 } |
1873 } | 1879 } |
1874 | 1880 |
1875 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 1881 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
1876 int main(int argc, char * const argv[]) { | 1882 int main(int argc, char * const argv[]) { |
1877 return tool_main(argc, (char**) argv); | 1883 return tool_main(argc, (char**) argv); |
1878 } | 1884 } |
1879 #endif | 1885 #endif |
OLD | NEW |