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 300 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
311 while ((mode = iter.next(NULL)) != NULL) { | 311 while ((mode = iter.next(NULL)) != NULL) { |
312 SkString modeAsString = SkString(mode); | 312 SkString modeAsString = SkString(mode); |
313 // TODO(epoger): It seems a bit silly that all of these modes were | 313 // TODO(epoger): It seems a bit silly that all of these modes were |
314 // recorded with a leading "-" which we have to remove here | 314 // recorded with a leading "-" which we have to remove here |
315 // (except for mode "", which means plain old original mode). | 315 // (except for mode "", which means plain old original mode). |
316 // But that's how renderModeDescriptor has been passed into | 316 // But that's how renderModeDescriptor has been passed into |
317 // compare_test_results_to_reference_bitmap() historically, | 317 // compare_test_results_to_reference_bitmap() historically, |
318 // and changing that now may affect other parts of our code. | 318 // and changing that now may affect other parts of our code. |
319 if (modeAsString.startsWith("-")) { | 319 if (modeAsString.startsWith("-")) { |
320 modeAsString.remove(0, 1); | 320 modeAsString.remove(0, 1); |
321 modes.push_back(modeAsString); | |
322 } | 321 } |
| 322 modes.push_back(modeAsString); |
323 } | 323 } |
324 } | 324 } |
325 | 325 |
326 /** | 326 /** |
327 * Returns true if failures on this test should be ignored. | 327 * Returns true if failures on this test should be ignored. |
328 */ | 328 */ |
329 bool ShouldIgnoreTest(const SkString &name) const { | 329 bool ShouldIgnoreTest(const SkString &name) const { |
330 for (int i = 0; i < fIgnorableTestSubstrings.count(); i++) { | 330 for (int i = 0; i < fIgnorableTestSubstrings.count(); i++) { |
331 if (name.contains(fIgnorableTestSubstrings[i].c_str())) { | 331 if (name.contains(fIgnorableTestSubstrings[i].c_str())) { |
332 return true; | 332 return true; |
333 } | 333 } |
334 } | 334 } |
335 return false; | 335 return false; |
336 } | 336 } |
337 | 337 |
338 /** | 338 /** |
| 339 * Calls RecordTestResults to record that we skipped a test. |
| 340 * |
| 341 * Depending on the backend, this may mean that we skipped a single rendermo
de, or all |
| 342 * rendermodes; see http://skbug.com/1994 and https://codereview.chromium.or
g/129203002/ |
| 343 */ |
| 344 void RecordSkippedTest(const SkString& shortNamePlusConfig, |
| 345 const char renderModeDescriptor [], Backend backend)
{ |
| 346 if (kRaster_Backend == backend) { |
| 347 // Skipping a test on kRaster_Backend means that we will skip ALL re
nderModes |
| 348 // (as opposed to other backends, on which we only run the default r
enderMode). |
| 349 // |
| 350 // We cannot call RecordTestResults yet, because we won't know the f
ull set of |
| 351 // renderModes until we have run all tests. |
| 352 fTestsSkippedOnAllRenderModes.push_back(shortNamePlusConfig); |
| 353 } else { |
| 354 this->RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePl
usConfig, |
| 355 renderModeDescriptor); |
| 356 } |
| 357 } |
| 358 |
| 359 /** |
339 * Records the results of this test in fTestsRun and fFailedTests. | 360 * Records the results of this test in fTestsRun and fFailedTests. |
340 * | 361 * |
341 * We even record successes, and errors that we regard as | 362 * We even record successes, and errors that we regard as |
342 * "ignorable"; we can filter them out later. | 363 * "ignorable"; we can filter them out later. |
343 */ | 364 */ |
344 void RecordTestResults(const ErrorCombination& errorCombination, | 365 void RecordTestResults(const ErrorCombination& errorCombination, |
345 const SkString& shortNamePlusConfig, | 366 const SkString& shortNamePlusConfig, |
346 const char renderModeDescriptor []) { | 367 const char renderModeDescriptor []) { |
347 // Things to do regardless of errorCombination. | 368 // Things to do regardless of errorCombination. |
348 fTestsRun++; | 369 fTestsRun++; |
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1233 | 1254 |
1234 bool fUseFileHierarchy, fWriteChecksumBasedFilenames; | 1255 bool fUseFileHierarchy, fWriteChecksumBasedFilenames; |
1235 ErrorCombination fIgnorableErrorTypes; | 1256 ErrorCombination fIgnorableErrorTypes; |
1236 SkTArray<SkString> fIgnorableTestSubstrings; | 1257 SkTArray<SkString> fIgnorableTestSubstrings; |
1237 | 1258 |
1238 const char* fMismatchPath; | 1259 const char* fMismatchPath; |
1239 const char* fMissingExpectationsPath; | 1260 const char* fMissingExpectationsPath; |
1240 | 1261 |
1241 // collection of tests that have failed with each ErrorType | 1262 // collection of tests that have failed with each ErrorType |
1242 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; | 1263 SkTArray<SkString> fFailedTests[kLast_ErrorType+1]; |
| 1264 SkTArray<SkString> fTestsSkippedOnAllRenderModes; |
1243 int fTestsRun; | 1265 int fTestsRun; |
1244 SkTDict<int> fRenderModesEncountered; | 1266 SkTDict<int> fRenderModesEncountered; |
1245 | 1267 |
1246 // Where to read expectations (expected image hash digests, etc.) from. | 1268 // Where to read expectations (expected image hash digests, etc.) from. |
1247 // If unset, we don't do comparisons. | 1269 // If unset, we don't do comparisons. |
1248 SkAutoTUnref<ExpectationsSource> fExpectationsSource; | 1270 SkAutoTUnref<ExpectationsSource> fExpectationsSource; |
1249 | 1271 |
1250 // JSON summaries that we generate as we go (just for output). | 1272 // JSON summaries that we generate as we go (just for output). |
1251 Json::Value fJsonExpectedResults; | 1273 Json::Value fJsonExpectedResults; |
1252 Json::Value fJsonActualResults_Failed; | 1274 Json::Value fJsonActualResults_Failed; |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1508 } | 1530 } |
1509 | 1531 |
1510 template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) { | 1532 template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) { |
1511 int index = array->find(value); | 1533 int index = array->find(value); |
1512 if (index < 0) { | 1534 if (index < 0) { |
1513 *array->append() = value; | 1535 *array->append() = value; |
1514 } | 1536 } |
1515 } | 1537 } |
1516 | 1538 |
1517 /** | 1539 /** |
1518 * Run this test in a number of different configs (8888, 565, PDF, | |
1519 * etc.), confirming that the resulting bitmaps match expectations | |
1520 * (which may be different for each config). | |
1521 * | |
1522 * Returns all errors encountered while doing so. | |
1523 */ | |
1524 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, | |
1525 const SkTDArray<size_t> &configs, | |
1526 const SkTDArray<const PDFRasterizerData*>
&pdfRasterizers, | |
1527 GrContextFactory *grFactory); | |
1528 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, | |
1529 const SkTDArray<size_t> &configs, | |
1530 const SkTDArray<const PDFRasterizerData*>
&pdfRasterizers, | |
1531 GrContextFactory *grFactory) { | |
1532 const char renderModeDescriptor[] = ""; | |
1533 ErrorCombination errorsForAllConfigs; | |
1534 uint32_t gmFlags = gm->getFlags(); | |
1535 | |
1536 for (int i = 0; i < configs.count(); i++) { | |
1537 ConfigData config = gRec[configs[i]]; | |
1538 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(g
m->shortName(), | |
1539 c
onfig.fName); | |
1540 | |
1541 // Skip any tests that we don't even need to try. | |
1542 // If any of these were skipped on a per-GM basis, record them as | |
1543 // kIntentionallySkipped. | |
1544 if (kPDF_Backend == config.fBackend) { | |
1545 if (gmFlags & GM::kSkipPDF_Flag) { | |
1546 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortN
amePlusConfig, | |
1547 renderModeDescriptor); | |
1548 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1549 continue; | |
1550 } | |
1551 } | |
1552 if ((gmFlags & GM::kSkip565_Flag) && | |
1553 (kRaster_Backend == config.fBackend) && | |
1554 (SkBitmap::kRGB_565_Config == config.fConfig)) { | |
1555 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP
lusConfig, | |
1556 renderModeDescriptor); | |
1557 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1558 continue; | |
1559 } | |
1560 if (((gmFlags & GM::kSkipGPU_Flag) && kGPU_Backend == config.fBackend) |
| | |
1561 ((gmFlags & GM::kGPUOnly_Flag) && kGPU_Backend != config.fBackend))
{ | |
1562 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP
lusConfig, | |
1563 renderModeDescriptor); | |
1564 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1565 continue; | |
1566 } | |
1567 | |
1568 // Now we know that we want to run this test and record its | |
1569 // success or failure. | |
1570 ErrorCombination errorsForThisConfig; | |
1571 GrSurface* gpuTarget = NULL; | |
1572 #if SK_SUPPORT_GPU | |
1573 SkAutoTUnref<GrSurface> auGpuTarget; | |
1574 if ((errorsForThisConfig.isEmpty()) && (kGPU_Backend == config.fBackend)
) { | |
1575 if (FLAGS_resetGpuContext) { | |
1576 grFactory->destroyContexts(); | |
1577 } | |
1578 GrContext* gr = grFactory->get(config.fGLContextType); | |
1579 bool grSuccess = false; | |
1580 if (gr) { | |
1581 // create a render target to back the device | |
1582 GrTextureDesc desc; | |
1583 desc.fConfig = kSkia8888_GrPixelConfig; | |
1584 desc.fFlags = kRenderTarget_GrTextureFlagBit; | |
1585 desc.fWidth = gm->getISize().width(); | |
1586 desc.fHeight = gm->getISize().height(); | |
1587 desc.fSampleCnt = config.fSampleCnt; | |
1588 auGpuTarget.reset(gr->createUncachedTexture(desc, NULL, 0)); | |
1589 if (NULL != auGpuTarget) { | |
1590 gpuTarget = auGpuTarget; | |
1591 grSuccess = true; | |
1592 // Set the user specified cache limits if non-default. | |
1593 size_t bytes; | |
1594 int count; | |
1595 gr->getTextureCacheLimits(&count, &bytes); | |
1596 if (DEFAULT_CACHE_VALUE != gGpuCacheSizeBytes) { | |
1597 bytes = static_cast<size_t>(gGpuCacheSizeBytes); | |
1598 } | |
1599 if (DEFAULT_CACHE_VALUE != gGpuCacheSizeCount) { | |
1600 count = gGpuCacheSizeCount; | |
1601 } | |
1602 gr->setTextureCacheLimits(count, bytes); | |
1603 } | |
1604 } | |
1605 if (!grSuccess) { | |
1606 errorsForThisConfig.add(kNoGpuContext_ErrorType); | |
1607 } | |
1608 } | |
1609 #endif | |
1610 | |
1611 SkBitmap comparisonBitmap; | |
1612 | |
1613 const char* writePath; | |
1614 if (FLAGS_writePath.count() == 1) { | |
1615 writePath = FLAGS_writePath[0]; | |
1616 } else { | |
1617 writePath = NULL; | |
1618 } | |
1619 | |
1620 if (errorsForThisConfig.isEmpty()) { | |
1621 errorsForThisConfig.add(gmmain.test_drawing(gm, config, pdfRasterize
rs, | |
1622 writePath, gpuTarget, | |
1623 &comparisonBitmap)); | |
1624 gmmain.RecordTestResults(errorsForThisConfig, shortNamePlusConfig, "
"); | |
1625 } | |
1626 | |
1627 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && | |
1628 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke
nd)) { | |
1629 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com
parisonBitmap, | |
1630 gpuTarget)); | |
1631 } | |
1632 | |
1633 errorsForAllConfigs.add(errorsForThisConfig); | |
1634 } | |
1635 return errorsForAllConfigs; | |
1636 } | |
1637 | |
1638 /** | |
1639 * Run this test in a number of different drawing modes (pipe, | 1540 * Run this test in a number of different drawing modes (pipe, |
1640 * deferred, tiled, etc.), confirming that the resulting bitmaps all | 1541 * deferred, tiled, etc.), confirming that the resulting bitmaps all |
1641 * *exactly* match comparisonBitmap. | 1542 * *exactly* match comparisonBitmap. |
1642 * | 1543 * |
1643 * Returns all errors encountered while doing so. | 1544 * Returns all errors encountered while doing so. |
1644 */ | 1545 */ |
1645 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co
mpareConfig, | 1546 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co
mpareConfig, |
1646 const SkBitmap &comparisonBitmap, | 1547 const SkBitmap &comparisonBitmap, |
1647 const SkTDArray<SkScalar> &tileGridReplaySca
les); | 1548 const SkTDArray<SkScalar> &tileGridReplaySca
les); |
1648 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co
mpareConfig, | 1549 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co
mpareConfig, |
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1761 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa
risonBitmap, | 1662 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa
risonBitmap, |
1762 FLAGS_simulatePipePlayba
ckFailure)); | 1663 FLAGS_simulatePipePlayba
ckFailure)); |
1763 if (FLAGS_tiledPipe) { | 1664 if (FLAGS_tiledPipe) { |
1764 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon
fig, | 1665 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon
fig, |
1765 comparisonBitm
ap)); | 1666 comparisonBitm
ap)); |
1766 } | 1667 } |
1767 } | 1668 } |
1768 return errorsForAllModes; | 1669 return errorsForAllModes; |
1769 } | 1670 } |
1770 | 1671 |
| 1672 |
| 1673 /** |
| 1674 * Run this test in a number of different configs (8888, 565, PDF, |
| 1675 * etc.), confirming that the resulting bitmaps match expectations |
| 1676 * (which may be different for each config). |
| 1677 * |
| 1678 * Returns all errors encountered while doing so. |
| 1679 */ |
| 1680 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, |
| 1681 const SkTDArray<size_t> &configs, |
| 1682 const SkTDArray<const PDFRasterizerData*>
&pdfRasterizers, |
| 1683 const SkTDArray<SkScalar> &tileGridReplayS
cales, |
| 1684 GrContextFactory *grFactory); |
| 1685 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, |
| 1686 const SkTDArray<size_t> &configs, |
| 1687 const SkTDArray<const PDFRasterizerData*>
&pdfRasterizers, |
| 1688 const SkTDArray<SkScalar> &tileGridReplayS
cales, |
| 1689 GrContextFactory *grFactory) { |
| 1690 const char renderModeDescriptor[] = ""; |
| 1691 ErrorCombination errorsForAllConfigs; |
| 1692 uint32_t gmFlags = gm->getFlags(); |
| 1693 |
| 1694 for (int i = 0; i < configs.count(); i++) { |
| 1695 ConfigData config = gRec[configs[i]]; |
| 1696 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(g
m->shortName(), |
| 1697 c
onfig.fName); |
| 1698 |
| 1699 // Skip any tests that we don't even need to try. |
| 1700 // If any of these were skipped on a per-GM basis, record them as |
| 1701 // kIntentionallySkipped. |
| 1702 if (kPDF_Backend == config.fBackend) { |
| 1703 if (gmFlags & GM::kSkipPDF_Flag) { |
| 1704 gmmain.RecordSkippedTest(shortNamePlusConfig, |
| 1705 renderModeDescriptor, |
| 1706 config.fBackend); |
| 1707 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1708 continue; |
| 1709 } |
| 1710 } |
| 1711 if ((gmFlags & GM::kSkip565_Flag) && |
| 1712 (kRaster_Backend == config.fBackend) && |
| 1713 (SkBitmap::kRGB_565_Config == config.fConfig)) { |
| 1714 gmmain.RecordSkippedTest(shortNamePlusConfig, |
| 1715 renderModeDescriptor, |
| 1716 config.fBackend); |
| 1717 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1718 continue; |
| 1719 } |
| 1720 if (((gmFlags & GM::kSkipGPU_Flag) && kGPU_Backend == config.fBackend) |
| |
| 1721 ((gmFlags & GM::kGPUOnly_Flag) && kGPU_Backend != config.fBackend))
{ |
| 1722 gmmain.RecordSkippedTest(shortNamePlusConfig, |
| 1723 renderModeDescriptor, |
| 1724 config.fBackend); |
| 1725 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); |
| 1726 continue; |
| 1727 } |
| 1728 |
| 1729 // Now we know that we want to run this test and record its |
| 1730 // success or failure. |
| 1731 ErrorCombination errorsForThisConfig; |
| 1732 GrSurface* gpuTarget = NULL; |
| 1733 #if SK_SUPPORT_GPU |
| 1734 SkAutoTUnref<GrSurface> auGpuTarget; |
| 1735 if ((errorsForThisConfig.isEmpty()) && (kGPU_Backend == config.fBackend)
) { |
| 1736 if (FLAGS_resetGpuContext) { |
| 1737 grFactory->destroyContexts(); |
| 1738 } |
| 1739 GrContext* gr = grFactory->get(config.fGLContextType); |
| 1740 bool grSuccess = false; |
| 1741 if (gr) { |
| 1742 // create a render target to back the device |
| 1743 GrTextureDesc desc; |
| 1744 desc.fConfig = kSkia8888_GrPixelConfig; |
| 1745 desc.fFlags = kRenderTarget_GrTextureFlagBit; |
| 1746 desc.fWidth = gm->getISize().width(); |
| 1747 desc.fHeight = gm->getISize().height(); |
| 1748 desc.fSampleCnt = config.fSampleCnt; |
| 1749 auGpuTarget.reset(gr->createUncachedTexture(desc, NULL, 0)); |
| 1750 if (NULL != auGpuTarget) { |
| 1751 gpuTarget = auGpuTarget; |
| 1752 grSuccess = true; |
| 1753 // Set the user specified cache limits if non-default. |
| 1754 size_t bytes; |
| 1755 int count; |
| 1756 gr->getTextureCacheLimits(&count, &bytes); |
| 1757 if (DEFAULT_CACHE_VALUE != gGpuCacheSizeBytes) { |
| 1758 bytes = static_cast<size_t>(gGpuCacheSizeBytes); |
| 1759 } |
| 1760 if (DEFAULT_CACHE_VALUE != gGpuCacheSizeCount) { |
| 1761 count = gGpuCacheSizeCount; |
| 1762 } |
| 1763 gr->setTextureCacheLimits(count, bytes); |
| 1764 } |
| 1765 } |
| 1766 if (!grSuccess) { |
| 1767 errorsForThisConfig.add(kNoGpuContext_ErrorType); |
| 1768 } |
| 1769 } |
| 1770 #endif |
| 1771 |
| 1772 SkBitmap comparisonBitmap; |
| 1773 |
| 1774 const char* writePath; |
| 1775 if (FLAGS_writePath.count() == 1) { |
| 1776 writePath = FLAGS_writePath[0]; |
| 1777 } else { |
| 1778 writePath = NULL; |
| 1779 } |
| 1780 |
| 1781 if (errorsForThisConfig.isEmpty()) { |
| 1782 errorsForThisConfig.add(gmmain.test_drawing(gm, config, pdfRasterize
rs, |
| 1783 writePath, gpuTarget, |
| 1784 &comparisonBitmap)); |
| 1785 gmmain.RecordTestResults(errorsForThisConfig, shortNamePlusConfig, "
"); |
| 1786 } |
| 1787 |
| 1788 // TODO: run only if gmmain.test_drawing succeeded. |
| 1789 if (kRaster_Backend == config.fBackend) { |
| 1790 run_multiple_modes(gmmain, gm, config, comparisonBitmap, tileGridRep
layScales); |
| 1791 } |
| 1792 |
| 1793 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && |
| 1794 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke
nd)) { |
| 1795 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com
parisonBitmap, |
| 1796 gpuTarget)); |
| 1797 } |
| 1798 |
| 1799 errorsForAllConfigs.add(errorsForThisConfig); |
| 1800 } |
| 1801 return errorsForAllConfigs; |
| 1802 } |
| 1803 |
| 1804 |
1771 /** | 1805 /** |
1772 * Read individual lines from a file, pushing them into the given array. | 1806 * Read individual lines from a file, pushing them into the given array. |
1773 * | 1807 * |
1774 * @param filename path to the file to read | 1808 * @param filename path to the file to read |
1775 * @param lines array of strings to add the lines to | 1809 * @param lines array of strings to add the lines to |
1776 * @returns true if able to read lines from the file | 1810 * @returns true if able to read lines from the file |
1777 */ | 1811 */ |
1778 static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines
) { | 1812 static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines
) { |
1779 SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); | 1813 SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); |
1780 SkStream *stream = streamWrapper.get(); | 1814 SkStream *stream = streamWrapper.get(); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 | 2312 |
2279 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { | 2313 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { |
2280 continue; | 2314 continue; |
2281 } | 2315 } |
2282 | 2316 |
2283 gmsRun++; | 2317 gmsRun++; |
2284 SkISize size = gm->getISize(); | 2318 SkISize size = gm->getISize(); |
2285 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, | 2319 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, |
2286 size.width(), size.height()); | 2320 size.width(), size.height()); |
2287 | 2321 |
2288 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, grFactory); | 2322 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplay
Scales, grFactory); |
2289 | |
2290 SkBitmap comparisonBitmap; | |
2291 const ConfigData compareConfig = | |
2292 { SkBitmap::kARGB_8888_Config, kRaster_Backend, kDontCare_GLContextT
ype, 0, kRW_ConfigFlag, "comparison", false }; | |
2293 gmmain.generate_image(gm, compareConfig, NULL, &comparisonBitmap, false)
; | |
2294 | |
2295 // TODO(epoger): only run this if gmmain.generate_image() succeeded? | |
2296 // Otherwise, what are we comparing against? | |
2297 run_multiple_modes(gmmain, gm, compareConfig, comparisonBitmap, tileGrid
ReplayScales); | |
2298 } | 2323 } |
2299 | 2324 |
2300 SkTArray<SkString> modes; | 2325 SkTArray<SkString> modes; |
2301 gmmain.GetRenderModesEncountered(modes); | 2326 gmmain.GetRenderModesEncountered(modes); |
| 2327 int modeCount = modes.count(); |
| 2328 |
| 2329 // Now that we have run all the tests and thus know the full set of renderMo
des that we |
| 2330 // tried to run, we can call RecordTestResults() to record the cases in whic
h we skipped |
| 2331 // ALL renderModes. |
| 2332 // See http://skbug.com/1994 and https://codereview.chromium.org/129203002/ |
| 2333 int testCount = gmmain.fTestsSkippedOnAllRenderModes.count(); |
| 2334 for (int testNum = 0; testNum < testCount; ++testNum) { |
| 2335 const SkString &shortNamePlusConfig = gmmain.fTestsSkippedOnAllRenderMod
es[testNum]; |
| 2336 for (int modeNum = 0; modeNum < modeCount; ++modeNum) { |
| 2337 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP
lusConfig, |
| 2338 modes[modeNum].c_str()); |
| 2339 } |
| 2340 } |
| 2341 |
2302 bool reportError = false; | 2342 bool reportError = false; |
2303 if (gmmain.NumSignificantErrors() > 0) { | 2343 if (gmmain.NumSignificantErrors() > 0) { |
2304 reportError = true; | 2344 reportError = true; |
2305 } | 2345 } |
2306 int expectedNumberOfTests = gmsRun * (configs.count() + modes.count()); | 2346 |
| 2347 // We test every GM against every config, and for every raster config also t
est every mode. |
| 2348 int rasterConfigs = 0; |
| 2349 for (int i = 0; i < configs.count(); i++) { |
| 2350 if (gRec[configs[i]].fBackend == kRaster_Backend) { |
| 2351 rasterConfigs++; |
| 2352 } |
| 2353 } |
| 2354 // For raster configs, we run all renderModes; for non-raster configs, just
default renderMode |
| 2355 const int expectedNumberOfTests = rasterConfigs * gmsRun * modeCount |
| 2356 + (configs.count() - rasterConfigs) * gmsRun
; |
2307 | 2357 |
2308 // Output summary to stdout. | 2358 // Output summary to stdout. |
2309 if (FLAGS_verbose) { | 2359 if (FLAGS_verbose) { |
2310 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); | 2360 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); |
2311 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), | 2361 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), |
2312 list_all_config_names(configs).c_str()); | 2362 list_all_config_names(configs).c_str()); |
2313 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_al
l(modes).c_str()); | 2363 gm_fprintf(stdout, "... and %2d modes [%s]\n", modeCount, list_all(mo
des).c_str()); |
2314 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe
ctedNumberOfTests); | 2364 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe
ctedNumberOfTests); |
2315 } | 2365 } |
2316 gmmain.ListErrors(FLAGS_verbose); | 2366 gmmain.ListErrors(FLAGS_verbose); |
2317 | 2367 |
2318 // TODO(epoger): Enable this check for Android, too, once we resolve | 2368 // TODO(epoger): Enable this check for Android, too, once we resolve |
2319 // https://code.google.com/p/skia/issues/detail?id=1222 | 2369 // https://code.google.com/p/skia/issues/detail?id=1222 |
2320 // ('GM is unexpectedly skipping tests on Android') | 2370 // ('GM is unexpectedly skipping tests on Android') |
2321 #ifndef SK_BUILD_FOR_ANDROID | 2371 #ifndef SK_BUILD_FOR_ANDROID |
2322 if (expectedNumberOfTests != gmmain.fTestsRun) { | 2372 if (expectedNumberOfTests != gmmain.fTestsRun) { |
2323 gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", | 2373 gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2362 if (FLAGS_forceBWtext) { | 2412 if (FLAGS_forceBWtext) { |
2363 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2413 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2364 } | 2414 } |
2365 } | 2415 } |
2366 | 2416 |
2367 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2417 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2368 int main(int argc, char * const argv[]) { | 2418 int main(int argc, char * const argv[]) { |
2369 return tool_main(argc, (char**) argv); | 2419 return tool_main(argc, (char**) argv); |
2370 } | 2420 } |
2371 #endif | 2421 #endif |
OLD | NEW |