Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(128)

Side by Side Diff: gm/gmmain.cpp

Issue 803183003: Fix layer hoisting image filter corner cases (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Fix unit test Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « no previous file | src/core/SkLayerInfo.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 637 matching lines...) Expand 10 before | Expand all | Expand 10 after
648 if (useMPD) { 648 if (useMPD) {
649 SkMultiPictureDraw mpd; 649 SkMultiPictureDraw mpd;
650 mpd.add(surf->getCanvas(), pict, &matrix, NULL); 650 mpd.add(surf->getCanvas(), pict, &matrix, NULL);
651 mpd.draw(); 651 mpd.draw();
652 } else { 652 } else {
653 surf->getCanvas()->drawPicture(pict, &matrix, NULL); 653 surf->getCanvas()->drawPicture(pict, &matrix, NULL);
654 } 654 }
655 } 655 }
656 } 656 }
657 657
658 static void generate_image_from_picture(GM* gm, const ConfigData& gRec, 658 static void generate_image_from_picture(GM* gm, const ConfigData& config,
659 GrSurface* gpuTarget,
659 SkPicture* pict, SkBitmap* bitmap, 660 SkPicture* pict, SkBitmap* bitmap,
660 SkScalar scale = SK_Scalar1, 661 SkScalar scale = SK_Scalar1,
661 bool tile = false) { 662 bool tile = false) {
662 SkISize size = gm->getISize(); 663 const SkISize size = gm->getISize();
663 setup_bitmap(gRec, size, bitmap);
664 664
665 SkAutoTUnref<SkSurface> surf(SkSurface::NewRasterDirect(bitmap->info(), 665 SkAutoTUnref<SkSurface> surf(CreateSurface(config, size, gpuTarget));
666 bitmap->getPixel s(),
667 bitmap->rowBytes ()));
668 666
669 DrawPictureToSurface(surf, pict, scale, tile, false); 667 DrawPictureToSurface(surf, pict, scale, tile, false);
668
669 setup_bitmap(config, size, bitmap);
670
671 surf->readPixels(bitmap->info(), bitmap->getPixels(), bitmap->rowBytes() , 0, 0);
672
670 complete_bitmap(bitmap); 673 complete_bitmap(bitmap);
671 } 674 }
672 675
673 static bool generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) { 676 static bool generate_pdf(GM* gm, SkDynamicMemoryWStream& pdf) {
674 #ifdef SK_SUPPORT_PDF 677 #ifdef SK_SUPPORT_PDF
675 SkMatrix initialTransform = gm->getInitialTransform(); 678 SkMatrix initialTransform = gm->getInitialTransform();
676 if (FLAGS_useDocumentInsteadOfDevice) { 679 if (FLAGS_useDocumentInsteadOfDevice) {
677 SkISize pageISize = gm->getISize(); 680 SkISize pageISize = gm->getISize();
678 SkAutoTUnref<SkDocument> pdfDoc( 681 SkAutoTUnref<SkDocument> pdfDoc(
679 SkDocument::CreatePDF(&pdf, NULL, 682 SkDocument::CreatePDF(&pdf, NULL,
(...skipping 943 matching lines...) Expand 10 before | Expand all | Expand 10 after
1623 } 1626 }
1624 } 1627 }
1625 1628
1626 /** 1629 /**
1627 * Run this test in a number of different drawing modes (pipe, 1630 * Run this test in a number of different drawing modes (pipe,
1628 * deferred, tiled, etc.), confirming that the resulting bitmaps all 1631 * deferred, tiled, etc.), confirming that the resulting bitmaps all
1629 * *exactly* match comparisonBitmap. 1632 * *exactly* match comparisonBitmap.
1630 * 1633 *
1631 * Returns all errors encountered while doing so. 1634 * Returns all errors encountered while doing so.
1632 */ 1635 */
1633 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, 1636 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm,
1637 const ConfigData &compareConfig, GrSurface* gpuTarget,
1634 const SkBitmap &comparisonBitmap, 1638 const SkBitmap &comparisonBitmap,
1635 const SkTDArray<SkScalar> &tileGridReplaySca les); 1639 const SkTDArray<SkScalar> &tileGridReplaySca les);
1636 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm, const ConfigData &co mpareConfig, 1640 ErrorCombination run_multiple_modes(GMMain &gmmain, GM *gm,
1641 const ConfigData &compareConfig, GrSurface* gpuTarget,
1637 const SkBitmap &comparisonBitmap, 1642 const SkBitmap &comparisonBitmap,
1638 const SkTDArray<SkScalar> &tileGridReplaySca les) { 1643 const SkTDArray<SkScalar> &tileGridReplaySca les) {
1639 ErrorCombination errorsForAllModes; 1644 ErrorCombination errorsForAllModes;
1640 uint32_t gmFlags = gm->getFlags(); 1645 uint32_t gmFlags = gm->getFlags();
1641 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->g etName(), 1646 const SkString shortNamePlusConfig = gmmain.make_shortname_plus_config(gm->g etName(),
1642 compa reConfig.fName); 1647 compa reConfig.fName);
1643 1648
1644 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0); 1649 SkPicture* pict = gmmain.generate_new_picture(gm, kNone_BbhType, 0);
1645 SkAutoTUnref<SkPicture> aur(pict); 1650 SkAutoTUnref<SkPicture> aur(pict);
1646 if (FLAGS_replay) { 1651 if (FLAGS_replay) {
1647 const char renderModeDescriptor[] = "-replay"; 1652 const char renderModeDescriptor[] = "-replay";
1648 if (gmFlags & GM::kSkipPicture_Flag) { 1653 if (gmFlags & GM::kSkipPicture_Flag) {
1649 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, 1654 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1650 renderModeDescriptor); 1655 renderModeDescriptor);
1651 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1656 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1652 } else { 1657 } else {
1653 SkBitmap bitmap; 1658 SkBitmap bitmap;
1654 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; 1659 gmmain.generate_image_from_picture(gm, compareConfig, gpuTarget, pic t, &bitmap);
1660
1655 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1661 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1656 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap , 1662 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap ,
1657 &comparisonBitmap)); 1663 &comparisonBitmap));
1658 } 1664 }
1659 } 1665 }
1660 1666
1661 if (FLAGS_serialize) { 1667 if (FLAGS_serialize) {
1662 const char renderModeDescriptor[] = "-serialize"; 1668 const char renderModeDescriptor[] = "-serialize";
1663 if (gmFlags & GM::kSkipPicture_Flag) { 1669 if (gmFlags & GM::kSkipPicture_Flag) {
1664 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, 1670 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1665 renderModeDescriptor); 1671 renderModeDescriptor);
1666 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1672 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1667 } else { 1673 } else {
1668 SkPicture* repict = gmmain.stream_to_new_picture(*pict); 1674 SkPicture* repict = gmmain.stream_to_new_picture(*pict);
1669 SkAutoTUnref<SkPicture> aurr(repict); 1675 SkAutoTUnref<SkPicture> aurr(repict);
1670 SkBitmap bitmap; 1676 SkBitmap bitmap;
1671 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); 1677 gmmain.generate_image_from_picture(gm, compareConfig, gpuTarget, rep ict, &bitmap);
1672 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1678 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1673 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap , 1679 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap ,
1674 &comparisonBitmap)); 1680 &comparisonBitmap));
1675 } 1681 }
1676 } 1682 }
1677 1683
1678 if ((1 == FLAGS_writePicturePath.count()) && 1684 if ((1 == FLAGS_writePicturePath.count()) &&
1679 !(gmFlags & GM::kSkipPicture_Flag)) { 1685 !(gmFlags & GM::kSkipPicture_Flag)) {
1680 const char* pictureSuffix = "skp"; 1686 const char* pictureSuffix = "skp";
1681 // TODO(epoger): Make sure this still works even though the 1687 // TODO(epoger): Make sure this still works even though the
(...skipping 12 matching lines...) Expand all
1694 if (FLAGS_rtree) { 1700 if (FLAGS_rtree) {
1695 const char renderModeDescriptor[] = "-rtree"; 1701 const char renderModeDescriptor[] = "-rtree";
1696 if ((gmFlags & GM::kSkipPicture_Flag) || (gmFlags & GM::kSkipTiled_Flag) ) { 1702 if ((gmFlags & GM::kSkipPicture_Flag) || (gmFlags & GM::kSkipTiled_Flag) ) {
1697 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig, 1703 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, shortNameP lusConfig,
1698 renderModeDescriptor); 1704 renderModeDescriptor);
1699 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1705 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1700 } else { 1706 } else {
1701 SkPicture* pict = gmmain.generate_new_picture(gm, kRTree_BbhType, 0) ; 1707 SkPicture* pict = gmmain.generate_new_picture(gm, kRTree_BbhType, 0) ;
1702 SkAutoTUnref<SkPicture> aur(pict); 1708 SkAutoTUnref<SkPicture> aur(pict);
1703 SkBitmap bitmap; 1709 SkBitmap bitmap;
1704 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bitmap) ; 1710 gmmain.generate_image_from_picture(gm, compareConfig, gpuTarget, pic t, &bitmap);
1705 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1711 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1706 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap , 1712 gm->getName(), compareConfig.fName, renderModeDescriptor, bitmap ,
1707 &comparisonBitmap)); 1713 &comparisonBitmap));
1708 } 1714 }
1709 } 1715 }
1710 1716
1711 if (FLAGS_tileGrid) { 1717 if (FLAGS_tileGrid) {
1712 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) { 1718 for(int scaleIndex = 0; scaleIndex < tileGridReplayScales.count(); ++sca leIndex) {
1713 SkScalar replayScale = tileGridReplayScales[scaleIndex]; 1719 SkScalar replayScale = tileGridReplayScales[scaleIndex];
1714 SkString renderModeDescriptor("-tilegrid"); 1720 SkString renderModeDescriptor("-tilegrid");
(...skipping 12 matching lines...) Expand all
1727 // We record with the reciprocal scale to obtain a replay 1733 // We record with the reciprocal scale to obtain a replay
1728 // result that can be validated against comparisonBitmap. 1734 // result that can be validated against comparisonBitmap.
1729 SkScalar recordScale = SkScalarInvert(replayScale); 1735 SkScalar recordScale = SkScalarInvert(replayScale);
1730 SkPicture* pict = gmmain.generate_new_picture( 1736 SkPicture* pict = gmmain.generate_new_picture(
1731 gm, kTileGrid_BbhType, 0, recordScale); 1737 gm, kTileGrid_BbhType, 0, recordScale);
1732 SkAutoTUnref<SkPicture> aur(pict); 1738 SkAutoTUnref<SkPicture> aur(pict);
1733 SkBitmap bitmap; 1739 SkBitmap bitmap;
1734 // We cannot yet pass 'true' to generate_image_from_picture to 1740 // We cannot yet pass 'true' to generate_image_from_picture to
1735 // perform actual tiled rendering (see Issue 1198 - 1741 // perform actual tiled rendering (see Issue 1198 -
1736 // https://code.google.com/p/skia/issues/detail?id=1198) 1742 // https://code.google.com/p/skia/issues/detail?id=1198)
1737 gmmain.generate_image_from_picture(gm, compareConfig, pict, &bit map, 1743 gmmain.generate_image_from_picture(gm, compareConfig, gpuTarget, pict, &bitmap,
1738 replayScale /*, true */); 1744 replayScale /*, true */);
1739 errorsForAllModes.add(gmmain.compare_test_results_to_reference_b itmap( 1745 errorsForAllModes.add(gmmain.compare_test_results_to_reference_b itmap(
1740 gm->getName(), compareConfig.fName, renderModeDescriptor.c_s tr(), bitmap, 1746 gm->getName(), compareConfig.fName, renderModeDescriptor.c_s tr(), bitmap,
1741 &comparisonBitmap)); 1747 &comparisonBitmap));
1742 } 1748 }
1743 } 1749 }
1744 } 1750 }
1745 1751
1746 // run the pipe centric GM steps 1752 // run the pipe centric GM steps
1747 if (FLAGS_pipe) { 1753 if (FLAGS_pipe) {
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 1874
1869 if (errorsForThisConfig.isEmpty()) { 1875 if (errorsForThisConfig.isEmpty()) {
1870 errorsForThisConfig.add(gmmain.test_drawing(gm, config, pdfRasterize rs, 1876 errorsForThisConfig.add(gmmain.test_drawing(gm, config, pdfRasterize rs,
1871 writePath, gpuTarget, 1877 writePath, gpuTarget,
1872 &comparisonBitmap)); 1878 &comparisonBitmap));
1873 gmmain.RecordTestResults(errorsForThisConfig, shortNamePlusConfig, " "); 1879 gmmain.RecordTestResults(errorsForThisConfig, shortNamePlusConfig, " ");
1874 } 1880 }
1875 1881
1876 // TODO: run only if gmmain.test_drawing succeeded. 1882 // TODO: run only if gmmain.test_drawing succeeded.
1877 if (kRaster_Backend == config.fBackend) { 1883 if (kRaster_Backend == config.fBackend) {
1878 run_multiple_modes(gmmain, gm, config, comparisonBitmap, tileGridRep layScales); 1884 run_multiple_modes(gmmain, gm, config, gpuTarget, comparisonBitmap, tileGridReplayScales);
1879 } 1885 }
1880 1886
1881 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && 1887 if (FLAGS_deferred && errorsForThisConfig.isEmpty() &&
1882 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) { 1888 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) {
1883 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap, 1889 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap,
1884 gpuTarget)); 1890 gpuTarget));
1885 } 1891 }
1886 1892
1887 if (FLAGS_mpd && (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBackend)) { 1893 if (FLAGS_mpd && (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBackend)) {
1888 1894
(...skipping 675 matching lines...) Expand 10 before | Expand all | Expand 10 after
2564 if (FLAGS_forceBWtext) { 2570 if (FLAGS_forceBWtext) {
2565 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2571 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
2566 } 2572 }
2567 } 2573 }
2568 2574
2569 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2575 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
2570 int main(int argc, char * const argv[]) { 2576 int main(int argc, char * const argv[]) {
2571 return tool_main(argc, (char**) argv); 2577 return tool_main(argc, (char**) argv);
2572 } 2578 }
2573 #endif 2579 #endif
OLDNEW
« no previous file with comments | « no previous file | src/core/SkLayerInfo.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698