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 318 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
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 for a single ren dermode. | |
340 */ | |
341 void RecordSkippedTest(const SkString& shortNamePlusConfig, | |
342 const char renderModeDescriptor []) { | |
343 this->RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlusCo nfig, | |
344 renderModeDescriptor); | |
345 } | |
346 | |
347 /** | |
339 * Records the results of this test in fTestsRun and fFailedTests. | 348 * Records the results of this test in fTestsRun and fFailedTests. |
340 * | 349 * |
341 * We even record successes, and errors that we regard as | 350 * We even record successes, and errors that we regard as |
342 * "ignorable"; we can filter them out later. | 351 * "ignorable"; we can filter them out later. |
343 */ | 352 */ |
344 void RecordTestResults(const ErrorCombination& errorCombination, | 353 void RecordTestResults(const ErrorCombination& errorCombination, |
345 const SkString& shortNamePlusConfig, | 354 const SkString& shortNamePlusConfig, |
346 const char renderModeDescriptor []) { | 355 const char renderModeDescriptor []) { |
347 // Things to do regardless of errorCombination. | 356 // Things to do regardless of errorCombination. |
348 fTestsRun++; | 357 fTestsRun++; |
(...skipping 799 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1148 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(), | 1157 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(), |
1149 gRec.fNa me); | 1158 gRec.fNa me); |
1150 ErrorCombination errors; | 1159 ErrorCombination errors; |
1151 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1160 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
1152 SkString renderModeDescriptor("-pipe"); | 1161 SkString renderModeDescriptor("-pipe"); |
1153 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); | 1162 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
1154 | 1163 |
1155 if (gm->getFlags() & GM::kSkipPipe_Flag | 1164 if (gm->getFlags() & GM::kSkipPipe_Flag |
1156 || (gPipeWritingFlagCombos[i].flags == SkGPipeWriter::kCrossProc ess_Flag | 1165 || (gPipeWritingFlagCombos[i].flags == SkGPipeWriter::kCrossProc ess_Flag |
1157 && gm->getFlags() & GM::kSkipPipeCrossProcess_Flag)) { | 1166 && gm->getFlags() & GM::kSkipPipeCrossProcess_Flag)) { |
1158 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus Config, | 1167 RecordSkippedTest(shortNamePlusConfig, |
epoger
2014/01/10 19:36:39
Patchset 5: created a new RecordSkippedTest() meth
| |
1159 renderModeDescriptor.c_str()); | 1168 renderModeDescriptor.c_str()); |
1160 errors.add(kIntentionallySkipped_ErrorType); | 1169 errors.add(kIntentionallySkipped_ErrorType); |
1161 } else { | 1170 } else { |
1162 SkBitmap bitmap; | 1171 SkBitmap bitmap; |
1163 SkISize size = gm->getISize(); | 1172 SkISize size = gm->getISize(); |
1164 setup_bitmap(gRec, size, &bitmap); | 1173 setup_bitmap(gRec, size, &bitmap); |
1165 SkCanvas canvas(bitmap); | 1174 SkCanvas canvas(bitmap); |
1166 installFilter(&canvas); | 1175 installFilter(&canvas); |
1167 // Pass a decoding function so the factory GM (which has an SkBi tmap | 1176 // Pass a decoding function so the factory GM (which has an SkBi tmap |
1168 // with encoded data) will not fail playback. | 1177 // with encoded data) will not fail playback. |
(...skipping 22 matching lines...) Expand all Loading... | |
1191 const SkBitmap& referenceBitmap) { | 1200 const SkBitmap& referenceBitmap) { |
1192 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(), | 1201 const SkString shortNamePlusConfig = make_shortname_plus_config(gm->shor tName(), |
1193 gRec.fNa me); | 1202 gRec.fNa me); |
1194 ErrorCombination errors; | 1203 ErrorCombination errors; |
1195 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { | 1204 for (size_t i = 0; i < SK_ARRAY_COUNT(gPipeWritingFlagCombos); ++i) { |
1196 SkString renderModeDescriptor("-tiled pipe"); | 1205 SkString renderModeDescriptor("-tiled pipe"); |
1197 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); | 1206 renderModeDescriptor.append(gPipeWritingFlagCombos[i].name); |
1198 | 1207 |
1199 if ((gm->getFlags() & GM::kSkipPipe_Flag) || | 1208 if ((gm->getFlags() & GM::kSkipPipe_Flag) || |
1200 (gm->getFlags() & GM::kSkipTiled_Flag)) { | 1209 (gm->getFlags() & GM::kSkipTiled_Flag)) { |
1201 RecordTestResults(kIntentionallySkipped_ErrorType, shortNamePlus Config, | 1210 RecordSkippedTest(shortNamePlusConfig, |
1202 renderModeDescriptor.c_str()); | 1211 renderModeDescriptor.c_str()); |
1203 errors.add(kIntentionallySkipped_ErrorType); | 1212 errors.add(kIntentionallySkipped_ErrorType); |
1204 } else { | 1213 } else { |
1205 SkBitmap bitmap; | 1214 SkBitmap bitmap; |
1206 SkISize size = gm->getISize(); | 1215 SkISize size = gm->getISize(); |
1207 setup_bitmap(gRec, size, &bitmap); | 1216 setup_bitmap(gRec, size, &bitmap); |
1208 SkCanvas canvas(bitmap); | 1217 SkCanvas canvas(bitmap); |
1209 installFilter(&canvas); | 1218 installFilter(&canvas); |
1210 TiledPipeController pipeController(bitmap, &SkImageDecoder::Deco deMemory); | 1219 TiledPipeController pipeController(bitmap, &SkImageDecoder::Deco deMemory); |
1211 SkGPipeWriter writer; | 1220 SkGPipeWriter writer; |
(...skipping 296 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1508 } | 1517 } |
1509 | 1518 |
1510 template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) { | 1519 template <typename T> void appendUnique(SkTDArray<T>* array, const T& value) { |
1511 int index = array->find(value); | 1520 int index = array->find(value); |
1512 if (index < 0) { | 1521 if (index < 0) { |
1513 *array->append() = value; | 1522 *array->append() = value; |
1514 } | 1523 } |
1515 } | 1524 } |
1516 | 1525 |
1517 /** | 1526 /** |
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, | 1527 * Run this test in a number of different drawing modes (pipe, |
1640 * deferred, tiled, etc.), confirming that the resulting bitmaps all | 1528 * deferred, tiled, etc.), confirming that the resulting bitmaps all |
1641 * *exactly* match comparisonBitmap. | 1529 * *exactly* match comparisonBitmap. |
1642 * | 1530 * |
1643 * Returns all errors encountered while doing so. | 1531 * Returns all errors encountered while doing so. |
1644 */ | 1532 */ |
1645 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, | 1533 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
1646 const SkBitmap &comparisonBitmap, | 1534 const SkBitmap &comparisonBitmap, |
1647 const SkTDArray<SkScalar> &tileGridReplaySca les); | 1535 const SkTDArray<SkScalar> &tileGridReplaySca les); |
1648 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, | 1536 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, |
1649 const SkBitmap &comparisonBitmap, | 1537 const SkBitmap &comparisonBitmap, |
1650 const SkTDArray<SkScalar> &tileGridReplaySca les) { | 1538 const SkTDArray<SkScalar> &tileGridReplaySca les) { |
1651 ErrorCombination errorsForAllModes; | 1539 ErrorCombination errorsForAllModes; |
1652 uint32_t gmFlags = gm->getFlags(); | 1540 uint32_t gmFlags = gm->getFlags(); |
1653 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->s hortName(), | 1541 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->s hortName(), |
1654 compa reConfig.fName); | 1542 compa reConfig.fName); |
1655 | 1543 |
1656 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); | 1544 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); |
1657 SkAutoUnref aur(pict); | 1545 SkAutoUnref aur(pict); |
1658 if (FLAGS_replay) { | 1546 if (FLAGS_replay) { |
1659 const char renderModeDescriptor[] = "-replay"; | 1547 const char renderModeDescriptor[] = "-replay"; |
1660 if (gmFlags & GM::kSkipPicture_Flag) { | 1548 if (gmFlags & GM::kSkipPicture_Flag) { |
1661 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, | 1549 gmmain.RecordSkippedTest(shortNamePlusConfig, |
1662 renderModeDescriptor); | 1550 renderModeDescriptor); |
1663 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1551 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
1664 } else { | 1552 } else { |
1665 SkBitmap bitmap; | 1553 SkBitmap bitmap; |
1666 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | 1554 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; |
1667 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | 1555 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
1668 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap, | 1556 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap, |
1669 &comparisonBitmap)); | 1557 &comparisonBitmap)); |
1670 } | 1558 } |
1671 } | 1559 } |
1672 | 1560 |
1673 if (FLAGS_serialize) { | 1561 if (FLAGS_serialize) { |
1674 const char renderModeDescriptor[] = "-serialize"; | 1562 const char renderModeDescriptor[] = "-serialize"; |
1675 if (gmFlags & GM::kSkipPicture_Flag) { | 1563 if (gmFlags & GM::kSkipPicture_Flag) { |
1676 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, | 1564 gmmain.RecordSkippedTest(shortNamePlusConfig, |
1677 renderModeDescriptor); | 1565 renderModeDescriptor); |
1678 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1566 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
1679 } else { | 1567 } else { |
1680 SkPicture* repict = gmmain.stream_to_new_picture(*pict); | 1568 SkPicture* repict = gmmain.stream_to_new_picture(*pict); |
1681 SkAutoUnref aurr(repict); | 1569 SkAutoUnref aurr(repict); |
1682 SkBitmap bitmap; | 1570 SkBitmap bitmap; |
1683 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); | 1571 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); |
1684 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | 1572 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
1685 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap, | 1573 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap, |
1686 &comparisonBitmap)); | 1574 &comparisonBitmap)); |
(...skipping 12 matching lines...) Expand all Loading... | |
1699 // break anybody. | 1587 // break anybody. |
1700 SkString path = gmmain.make_filename(FLAGS_writePicturePath[0], gm->shor tName(), | 1588 SkString path = gmmain.make_filename(FLAGS_writePicturePath[0], gm->shor tName(), |
1701 compareConfig.fName, "", pictureSuf fix); | 1589 compareConfig.fName, "", pictureSuf fix); |
1702 SkFILEWStream stream(path.c_str()); | 1590 SkFILEWStream stream(path.c_str()); |
1703 pict->serialize(&stream); | 1591 pict->serialize(&stream); |
1704 } | 1592 } |
1705 | 1593 |
1706 if (FLAGS_rtree) { | 1594 if (FLAGS_rtree) { |
1707 const char renderModeDescriptor[] = "-rtree"; | 1595 const char renderModeDescriptor[] = "-rtree"; |
1708 if (gmFlags & GM::kSkipPicture_Flag) { | 1596 if (gmFlags & GM::kSkipPicture_Flag) { |
1709 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, | 1597 gmmain.RecordSkippedTest(shortNamePlusConfig, |
1710 renderModeDescriptor); | 1598 renderModeDescriptor); |
1711 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1599 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
1712 } else { | 1600 } else { |
1713 SkPicture* pict = gmmain.generate_new_picture( | 1601 SkPicture* pict = gmmain.generate_new_picture( |
1714 gm, kRTree_BbhType, SkPicture::kOptimizeForClippedPlayback_Recor dingFlag); | 1602 gm, kRTree_BbhType, SkPicture::kOptimizeForClippedPlayback_Recor dingFlag); |
1715 SkAutoUnref aur(pict); | 1603 SkAutoUnref aur(pict); |
1716 SkBitmap bitmap; | 1604 SkBitmap bitmap; |
1717 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; | 1605 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; |
1718 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( | 1606 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( |
1719 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap, | 1607 gm->shortName(), compareConfig.fName, renderModeDescriptor, bitm ap, |
1720 &comparisonBitmap)); | 1608 &comparisonBitmap)); |
1721 } | 1609 } |
1722 } | 1610 } |
1723 | 1611 |
1724 if (FLAGS_tileGrid) { | 1612 if (FLAGS_tileGrid) { |
1725 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { | 1613 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { |
1726 SkScalar replayScale = tileGridReplayScales[scaleIndex]; | 1614 SkScalar replayScale = tileGridReplayScales[scaleIndex]; |
1727 SkString renderModeDescriptor("-tilegrid"); | 1615 SkString renderModeDescriptor("-tilegrid"); |
1728 if (SK_Scalar1 != replayScale) { | 1616 if (SK_Scalar1 != replayScale) { |
1729 renderModeDescriptor += "-scale-"; | 1617 renderModeDescriptor += "-scale-"; |
1730 renderModeDescriptor.appendScalar(replayScale); | 1618 renderModeDescriptor.appendScalar(replayScale); |
1731 } | 1619 } |
1732 | 1620 |
1733 if ((gmFlags & GM::kSkipPicture_Flag) || | 1621 if ((gmFlags & GM::kSkipPicture_Flag) || |
1734 ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) { | 1622 ((gmFlags & GM::kSkipScaledReplay_Flag) && replayScale != 1)) { |
1735 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortN amePlusConfig, | 1623 gmmain.RecordSkippedTest(shortNamePlusConfig, |
1736 renderModeDescriptor.c_str()); | 1624 renderModeDescriptor.c_str()); |
1737 errorsForAllModes.add(kIntentionallySkipped_ErrorType); | 1625 errorsForAllModes.add(kIntentionallySkipped_ErrorType); |
1738 } else { | 1626 } else { |
1739 // We record with the reciprocal scale to obtain a replay | 1627 // We record with the reciprocal scale to obtain a replay |
1740 // result that can be validated against comparisonBitmap. | 1628 // result that can be validated against comparisonBitmap. |
1741 SkScalar recordScale = SkScalarInvert(replayScale); | 1629 SkScalar recordScale = SkScalarInvert(replayScale); |
1742 SkPicture* pict = gmmain.generate_new_picture( | 1630 SkPicture* pict = gmmain.generate_new_picture( |
1743 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag, | 1631 gm, kTileGrid_BbhType, SkPicture::kUsePathBoundsForClip_Reco rdingFlag, |
1744 recordScale); | 1632 recordScale); |
1745 SkAutoUnref aur(pict); | 1633 SkAutoUnref aur(pict); |
(...skipping 15 matching lines...) Expand all Loading... | |
1761 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa risonBitmap, | 1649 errorsForAllModes.add(gmmain.test_pipe_playback(gm, compareConfig, compa risonBitmap, |
1762 FLAGS_simulatePipePlayba ckFailure)); | 1650 FLAGS_simulatePipePlayba ckFailure)); |
1763 if (FLAGS_tiledPipe) { | 1651 if (FLAGS_tiledPipe) { |
1764 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, | 1652 errorsForAllModes.add(gmmain.test_tiled_pipe_playback(gm, compareCon fig, |
1765 comparisonBitm ap)); | 1653 comparisonBitm ap)); |
1766 } | 1654 } |
1767 } | 1655 } |
1768 return errorsForAllModes; | 1656 return errorsForAllModes; |
1769 } | 1657 } |
1770 | 1658 |
1659 | |
1660 /** | |
1661 * Run this test in a number of different configs (8888, 565, PDF, | |
1662 * etc.), confirming that the resulting bitmaps match expectations | |
1663 * (which may be different for each config). | |
1664 * | |
1665 * Returns all errors encountered while doing so. | |
1666 */ | |
1667 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, | |
1668 const SkTDArray<size_t> &configs, | |
1669 const SkTDArray<const PDFRasterizerData*> &pdfRasterizers, | |
1670 const SkTDArray<SkScalar> &tileGridReplayS cales, | |
1671 GrContextFactory *grFactory); | |
1672 ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, | |
1673 const SkTDArray<size_t> &configs, | |
1674 const SkTDArray<const PDFRasterizerData*> &pdfRasterizers, | |
1675 const SkTDArray<SkScalar> &tileGridReplayS cales, | |
1676 GrContextFactory *grFactory) { | |
1677 const char renderModeDescriptor[] = ""; | |
1678 ErrorCombination errorsForAllConfigs; | |
1679 uint32_t gmFlags = gm->getFlags(); | |
1680 | |
1681 for (int i = 0; i < configs.count(); i++) { | |
1682 ConfigData config = gRec[configs[i]]; | |
1683 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(g m->shortName(), | |
1684 c onfig.fName); | |
1685 | |
1686 // Skip any tests that we don't even need to try. | |
1687 // If any of these were skipped on a per-GM basis, record them as | |
1688 // kIntentionallySkipped. | |
1689 if (kPDF_Backend == config.fBackend) { | |
1690 if (gmFlags & GM::kSkipPDF_Flag) { | |
1691 gmmain.RecordSkippedTest(shortNamePlusConfig, | |
1692 renderModeDescriptor); | |
1693 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1694 continue; | |
1695 } | |
1696 } | |
1697 if ((gmFlags & GM::kSkip565_Flag) && | |
1698 (kRaster_Backend == config.fBackend) && | |
1699 (SkBitmap::kRGB_565_Config == config.fConfig)) { | |
1700 gmmain.RecordSkippedTest(shortNamePlusConfig, | |
1701 renderModeDescriptor); | |
1702 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1703 continue; | |
1704 } | |
1705 if (((gmFlags & GM::kSkipGPU_Flag) && kGPU_Backend == config.fBackend) | | | |
1706 ((gmFlags & GM::kGPUOnly_Flag) && kGPU_Backend != config.fBackend)) { | |
1707 gmmain.RecordSkippedTest(shortNamePlusConfig, | |
1708 renderModeDescriptor); | |
1709 errorsForAllConfigs.add(kIntentionallySkipped_ErrorType); | |
1710 continue; | |
1711 } | |
1712 | |
1713 // Now we know that we want to run this test and record its | |
1714 // success or failure. | |
1715 ErrorCombination errorsForThisConfig; | |
1716 GrSurface* gpuTarget = NULL; | |
1717 #if SK_SUPPORT_GPU | |
1718 SkAutoTUnref<GrSurface> auGpuTarget; | |
1719 if ((errorsForThisConfig.isEmpty()) && (kGPU_Backend == config.fBackend) ) { | |
1720 if (FLAGS_resetGpuContext) { | |
1721 grFactory->destroyContexts(); | |
1722 } | |
1723 GrContext* gr = grFactory->get(config.fGLContextType); | |
1724 bool grSuccess = false; | |
1725 if (gr) { | |
1726 // create a render target to back the device | |
1727 GrTextureDesc desc; | |
1728 desc.fConfig = kSkia8888_GrPixelConfig; | |
1729 desc.fFlags = kRenderTarget_GrTextureFlagBit; | |
1730 desc.fWidth = gm->getISize().width(); | |
1731 desc.fHeight = gm->getISize().height(); | |
1732 desc.fSampleCnt = config.fSampleCnt; | |
1733 auGpuTarget.reset(gr->createUncachedTexture(desc, NULL, 0)); | |
1734 if (NULL != auGpuTarget) { | |
1735 gpuTarget = auGpuTarget; | |
1736 grSuccess = true; | |
1737 // Set the user specified cache limits if non-default. | |
1738 size_t bytes; | |
1739 int count; | |
1740 gr->getTextureCacheLimits(&count, &bytes); | |
1741 if (DEFAULT_CACHE_VALUE != gGpuCacheSizeBytes) { | |
1742 bytes = static_cast<size_t>(gGpuCacheSizeBytes); | |
1743 } | |
1744 if (DEFAULT_CACHE_VALUE != gGpuCacheSizeCount) { | |
1745 count = gGpuCacheSizeCount; | |
1746 } | |
1747 gr->setTextureCacheLimits(count, bytes); | |
1748 } | |
1749 } | |
1750 if (!grSuccess) { | |
1751 errorsForThisConfig.add(kNoGpuContext_ErrorType); | |
1752 } | |
1753 } | |
1754 #endif | |
1755 | |
1756 SkBitmap comparisonBitmap; | |
1757 | |
1758 const char* writePath; | |
1759 if (FLAGS_writePath.count() == 1) { | |
1760 writePath = FLAGS_writePath[0]; | |
1761 } else { | |
1762 writePath = NULL; | |
1763 } | |
1764 | |
1765 if (errorsForThisConfig.isEmpty()) { | |
1766 errorsForThisConfig.add(gmmain.test_drawing(gm, config, pdfRasterize rs, | |
1767 writePath, gpuTarget, | |
1768 &comparisonBitmap)); | |
1769 gmmain.RecordTestResults(errorsForThisConfig, shortNamePlusConfig, " "); | |
1770 } | |
1771 | |
1772 // TODO: run only if gmmain.test_drawing succeeded. | |
1773 if (kRaster_Backend == config.fBackend) { | |
1774 run_multiple_modes(gmmain, gm, config, comparisonBitmap, tileGridRep layScales); | |
1775 } | |
1776 | |
1777 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && | |
1778 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) { | |
1779 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap, | |
1780 gpuTarget)); | |
1781 } | |
1782 | |
1783 errorsForAllConfigs.add(errorsForThisConfig); | |
1784 } | |
1785 return errorsForAllConfigs; | |
1786 } | |
1787 | |
1788 | |
1771 /** | 1789 /** |
1772 * Read individual lines from a file, pushing them into the given array. | 1790 * Read individual lines from a file, pushing them into the given array. |
1773 * | 1791 * |
1774 * @param filename path to the file to read | 1792 * @param filename path to the file to read |
1775 * @param lines array of strings to add the lines to | 1793 * @param lines array of strings to add the lines to |
1776 * @returns true if able to read lines from the file | 1794 * @returns true if able to read lines from the file |
1777 */ | 1795 */ |
1778 static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines ) { | 1796 static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines ) { |
1779 SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); | 1797 SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); |
1780 SkStream *stream = streamWrapper.get(); | 1798 SkStream *stream = streamWrapper.get(); |
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2278 | 2296 |
2279 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { | 2297 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { |
2280 continue; | 2298 continue; |
2281 } | 2299 } |
2282 | 2300 |
2283 gmsRun++; | 2301 gmsRun++; |
2284 SkISize size = gm->getISize(); | 2302 SkISize size = gm->getISize(); |
2285 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, | 2303 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short Name, |
2286 size.width(), size.height()); | 2304 size.width(), size.height()); |
2287 | 2305 |
2288 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, grFactory); | 2306 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 } | 2307 } |
2299 | 2308 |
2300 SkTArray<SkString> modes; | 2309 SkTArray<SkString> modes; |
2301 gmmain.GetRenderModesEncountered(modes); | 2310 gmmain.GetRenderModesEncountered(modes); |
2302 bool reportError = false; | 2311 bool reportError = false; |
2303 if (gmmain.NumSignificantErrors() > 0) { | 2312 if (gmmain.NumSignificantErrors() > 0) { |
2304 reportError = true; | 2313 reportError = true; |
2305 } | 2314 } |
2306 int expectedNumberOfTests = gmsRun * (configs.count() + modes.count()); | 2315 |
2316 // We test every GM against every config, and for every raster config also t est every mode. | |
2317 int rasterConfigs = 0; | |
2318 for (int i = 0; i < configs.count(); i++) { | |
2319 if (gRec[configs[i]].fBackend == kRaster_Backend) { | |
2320 rasterConfigs++; | |
2321 } | |
2322 } | |
2323 const int expectedNumberOfTests = gmsRun * configs.count() | |
2324 + gmsRun * rasterConfigs * modes.count(); | |
2307 | 2325 |
2308 // Output summary to stdout. | 2326 // Output summary to stdout. |
2309 if (FLAGS_verbose) { | 2327 if (FLAGS_verbose) { |
2310 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); | 2328 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); |
2311 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), | 2329 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), |
2312 list_all_config_names(configs).c_str()); | 2330 list_all_config_names(configs).c_str()); |
2313 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_al l(modes).c_str()); | 2331 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_al l(modes).c_str()); |
2314 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe ctedNumberOfTests); | 2332 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe ctedNumberOfTests); |
2315 } | 2333 } |
2316 gmmain.ListErrors(FLAGS_verbose); | 2334 gmmain.ListErrors(FLAGS_verbose); |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2362 if (FLAGS_forceBWtext) { | 2380 if (FLAGS_forceBWtext) { |
2363 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2381 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
2364 } | 2382 } |
2365 } | 2383 } |
2366 | 2384 |
2367 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2385 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
2368 int main(int argc, char * const argv[]) { | 2386 int main(int argc, char * const argv[]) { |
2369 return tool_main(argc, (char**) argv); | 2387 return tool_main(argc, (char**) argv); |
2370 } | 2388 } |
2371 #endif | 2389 #endif |
OLD | NEW |