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

Side by Side Diff: gm/gmmain.cpp

Issue 14054012: SkBitmapHasher: use 64-bit-truncated MD5 instead of 64-bit CityHash (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: add_algorithm_type_to_timing_report Created 7 years, 8 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | src/utils/SkBitmapHasher.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 20 matching lines...) Expand all
31 #include "SkImageEncoder.h" 31 #include "SkImageEncoder.h"
32 #include "SkOSFile.h" 32 #include "SkOSFile.h"
33 #include "SkPicture.h" 33 #include "SkPicture.h"
34 #include "SkRefCnt.h" 34 #include "SkRefCnt.h"
35 #include "SkStream.h" 35 #include "SkStream.h"
36 #include "SkTArray.h" 36 #include "SkTArray.h"
37 #include "SkTDict.h" 37 #include "SkTDict.h"
38 #include "SkTileGridPicture.h" 38 #include "SkTileGridPicture.h"
39 #include "SamplePipeControllers.h" 39 #include "SamplePipeControllers.h"
40 40
41 #define EPOGER_TEST
42 #ifdef EPOGER_TEST
43 #include "SkTime.h"
44 #endif
45
41 #ifdef SK_BUILD_FOR_WIN 46 #ifdef SK_BUILD_FOR_WIN
42 // json includes xlocale which generates warning 4530 because we're compilin g without 47 // json includes xlocale which generates warning 4530 because we're compilin g without
43 // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067 48 // exceptions; see https://code.google.com/p/skia/issues/detail?id=1067
44 #pragma warning(push) 49 #pragma warning(push)
45 #pragma warning(disable : 4530) 50 #pragma warning(disable : 4530)
46 #endif 51 #endif
47 #include "json/value.h" 52 #include "json/value.h"
48 #ifdef SK_BUILD_FOR_WIN 53 #ifdef SK_BUILD_FOR_WIN
49 #pragma warning(pop) 54 #pragma warning(pop)
50 #endif 55 #endif
(...skipping 1389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1440 } 1445 }
1441 if (!grSuccess) { 1446 if (!grSuccess) {
1442 errorsForThisConfig.add(kNoGpuContext_ErrorType); 1447 errorsForThisConfig.add(kNoGpuContext_ErrorType);
1443 } 1448 }
1444 } 1449 }
1445 #endif 1450 #endif
1446 1451
1447 SkBitmap comparisonBitmap; 1452 SkBitmap comparisonBitmap;
1448 1453
1449 const char* writePath; 1454 const char* writePath;
1455 #ifdef EPOGER_TEST
1456 writePath = NULL;
1457 #else
1450 if (FLAGS_writePath.count() == 1) { 1458 if (FLAGS_writePath.count() == 1) {
1451 writePath = FLAGS_writePath[0]; 1459 writePath = FLAGS_writePath[0];
1452 } else { 1460 } else {
1453 writePath = NULL; 1461 writePath = NULL;
1454 } 1462 }
1463 #endif
1455 if (errorsForThisConfig.isEmpty()) { 1464 if (errorsForThisConfig.isEmpty()) {
1456 errorsForThisConfig.add(gmmain.test_drawing(gm,config, writePath, gp uTarget, 1465 errorsForThisConfig.add(gmmain.test_drawing(gm,config, writePath, gp uTarget,
1457 &comparisonBitmap)); 1466 &comparisonBitmap));
1458 } 1467 }
1459 1468
1460 if (FLAGS_deferred && errorsForThisConfig.isEmpty() && 1469 if (FLAGS_deferred && errorsForThisConfig.isEmpty() &&
1461 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) { 1470 (kGPU_Backend == config.fBackend || kRaster_Backend == config.fBacke nd)) {
1462 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap, 1471 errorsForThisConfig.add(gmmain.test_deferred_drawing(gm, config, com parisonBitmap,
1463 gpuTarget)); 1472 gpuTarget));
1464 } 1473 }
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
1508 } else { 1517 } else {
1509 SkPicture* repict = gmmain.stream_to_new_picture(*pict); 1518 SkPicture* repict = gmmain.stream_to_new_picture(*pict);
1510 SkAutoUnref aurr(repict); 1519 SkAutoUnref aurr(repict);
1511 SkBitmap bitmap; 1520 SkBitmap bitmap;
1512 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p); 1521 gmmain.generate_image_from_picture(gm, compareConfig, repict, &bitma p);
1513 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p( 1522 errorsForAllModes.add(gmmain.compare_test_results_to_reference_bitma p(
1514 name, renderModeDescriptor, bitmap, &comparisonBitmap)); 1523 name, renderModeDescriptor, bitmap, &comparisonBitmap));
1515 } 1524 }
1516 } 1525 }
1517 1526
1527 #ifdef EPOGER_TEST
1528 #else
1518 if ((1 == FLAGS_writePicturePath.count()) && 1529 if ((1 == FLAGS_writePicturePath.count()) &&
1519 !(gmFlags & GM::kSkipPicture_Flag)) { 1530 !(gmFlags & GM::kSkipPicture_Flag)) {
1520 const char* pictureSuffix = "skp"; 1531 const char* pictureSuffix = "skp";
1521 SkString path = make_filename(FLAGS_writePicturePath[0], "", 1532 SkString path = make_filename(FLAGS_writePicturePath[0], "",
1522 gm->shortName(), pictureSuffix); 1533 gm->shortName(), pictureSuffix);
1523 SkFILEWStream stream(path.c_str()); 1534 SkFILEWStream stream(path.c_str());
1524 pict->serialize(&stream); 1535 pict->serialize(&stream);
1525 } 1536 }
1537 #endif
1526 1538
1527 if (FLAGS_rtree) { 1539 if (FLAGS_rtree) {
1528 const char renderModeDescriptor[] = "-rtree"; 1540 const char renderModeDescriptor[] = "-rtree";
1529 if (gmFlags & GM::kSkipPicture_Flag) { 1541 if (gmFlags & GM::kSkipPicture_Flag) {
1530 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor); 1542 gmmain.RecordTestResults(kIntentionallySkipped_ErrorType, name, rend erModeDescriptor);
1531 errorsForAllModes.add(kIntentionallySkipped_ErrorType); 1543 errorsForAllModes.add(kIntentionallySkipped_ErrorType);
1532 } else { 1544 } else {
1533 SkPicture* pict = gmmain.generate_new_picture( 1545 SkPicture* pict = gmmain.generate_new_picture(
1534 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag); 1546 gm, kRTree_BbhType, SkPicture::kUsePathBoundsForClip_RecordingFl ag);
1535 SkAutoUnref aur(pict); 1547 SkAutoUnref aur(pict);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1625 return total; 1637 return total;
1626 } 1638 }
1627 1639
1628 int tool_main(int argc, char** argv); 1640 int tool_main(int argc, char** argv);
1629 int tool_main(int argc, char** argv) { 1641 int tool_main(int argc, char** argv) {
1630 1642
1631 #if SK_ENABLE_INST_COUNT 1643 #if SK_ENABLE_INST_COUNT
1632 gPrintInstCount = true; 1644 gPrintInstCount = true;
1633 #endif 1645 #endif
1634 1646
1647 #ifdef EPOGER_TEST
1648 SkMSec timeStart = SkTime::GetMSecs();
1649 #endif
1650
1635 SkGraphics::Init(); 1651 SkGraphics::Init();
1636 // we don't need to see this during a run 1652 // we don't need to see this during a run
1637 gSkSuppressFontCachePurgeSpew = true; 1653 gSkSuppressFontCachePurgeSpew = true;
1638 1654
1639 setSystemPreferences(); 1655 setSystemPreferences();
1640 GMMain gmmain; 1656 GMMain gmmain;
1641 1657
1642 SkTDArray<size_t> configs; 1658 SkTDArray<size_t> configs;
1643 SkTDArray<size_t> excludeConfigs; 1659 SkTDArray<size_t> excludeConfigs;
1644 bool userConfig = false; 1660 bool userConfig = false;
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
1792 } else { 1808 } else {
1793 if (FLAGS_verbose) { 1809 if (FLAGS_verbose) {
1794 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath); 1810 gm_fprintf(stdout, "reading expectations from JSON summary file %s\n", readPath);
1795 } 1811 }
1796 gmmain.fExpectationsSource.reset(SkNEW_ARGS( 1812 gmmain.fExpectationsSource.reset(SkNEW_ARGS(
1797 JsonExpectationsSource, (readPath))); 1813 JsonExpectationsSource, (readPath)));
1798 } 1814 }
1799 } 1815 }
1800 if (FLAGS_verbose) { 1816 if (FLAGS_verbose) {
1801 if (FLAGS_writePath.count() == 1) { 1817 if (FLAGS_writePath.count() == 1) {
1818 #ifdef EPOGER_TEST
1819 gm_fprintf(stdout, "EPOGER_TEST: NOT writing to %s\n", FLAGS_writePa th[0]);
1820 #else
1802 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); 1821 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]);
1822 #endif
1803 } 1823 }
1804 if (FLAGS_writePicturePath.count() == 1) { 1824 if (FLAGS_writePicturePath.count() == 1) {
1825 #ifdef EPOGER_TEST
1826 gm_fprintf(stdout, "EPOGER_TEST: NOT writing pictures to %s\n", FLAG S_writePicturePath[0]);
1827 #else
1805 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat h[0]); 1828 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat h[0]);
1829 #endif
1806 } 1830 }
1807 if (FLAGS_resourcePath.count() == 1) { 1831 if (FLAGS_resourcePath.count() == 1) {
1808 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath [0]); 1832 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath [0]);
1809 } 1833 }
1810 } 1834 }
1811 1835
1812 if (moduloDivisor <= 0) { 1836 if (moduloDivisor <= 0) {
1813 moduloRemainder = -1; 1837 moduloRemainder = -1;
1814 } 1838 }
1815 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) { 1839 if (moduloRemainder < 0 || moduloRemainder >= moduloDivisor) {
1816 moduloRemainder = -1; 1840 moduloRemainder = -1;
1817 } 1841 }
1818 1842
1819 int gmsRun = 0; 1843 int gmsRun = 0;
1820 int gmIndex = -1; 1844 int gmIndex = -1;
1821 SkString moduloStr; 1845 SkString moduloStr;
1822 1846
1847 #ifdef EPOGER_TEST
1848 #else
1823 // If we will be writing out files, prepare subdirectories. 1849 // If we will be writing out files, prepare subdirectories.
1824 if (FLAGS_writePath.count() == 1) { 1850 if (FLAGS_writePath.count() == 1) {
1825 if (!sk_mkdir(FLAGS_writePath[0])) { 1851 if (!sk_mkdir(FLAGS_writePath[0])) {
1826 return -1; 1852 return -1;
1827 } 1853 }
1828 if (gmmain.fUseFileHierarchy) { 1854 if (gmmain.fUseFileHierarchy) {
1829 for (int i = 0; i < configs.count(); i++) { 1855 for (int i = 0; i < configs.count(); i++) {
1830 ConfigData config = gRec[configs[i]]; 1856 ConfigData config = gRec[configs[i]];
1831 SkString subdir; 1857 SkString subdir;
1832 subdir.appendf("%s%c%s", FLAGS_writePath[0], SkPATH_SEPARATOR, 1858 subdir.appendf("%s%c%s", FLAGS_writePath[0], SkPATH_SEPARATOR,
1833 config.fName); 1859 config.fName);
1834 if (!sk_mkdir(subdir.c_str())) { 1860 if (!sk_mkdir(subdir.c_str())) {
1835 return -1; 1861 return -1;
1836 } 1862 }
1837 } 1863 }
1838 } 1864 }
1839 } 1865 }
1866 #endif
1840 1867
1841 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { 1868 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) {
1842 gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range. "); 1869 gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range. ");
1843 } 1870 }
1844 1871
1845 Iter iter; 1872 Iter iter;
1846 GM* gm; 1873 GM* gm;
1847 while ((gm = iter.next()) != NULL) { 1874 while ((gm = iter.next()) != NULL) {
1848 SkAutoTDelete<GM> adgm(gm); 1875 SkAutoTDelete<GM> adgm(gm);
1849 ++gmIndex; 1876 ++gmIndex;
(...skipping 27 matching lines...) Expand all
1877 } 1904 }
1878 1905
1879 SkTArray<SkString> modes; 1906 SkTArray<SkString> modes;
1880 gmmain.GetRenderModesEncountered(modes); 1907 gmmain.GetRenderModesEncountered(modes);
1881 bool reportError = false; 1908 bool reportError = false;
1882 if (gmmain.NumSignificantErrors() > 0) { 1909 if (gmmain.NumSignificantErrors() > 0) {
1883 reportError = true; 1910 reportError = true;
1884 } 1911 }
1885 int expectedNumberOfTests = gmsRun * (configs.count() + modes.count()); 1912 int expectedNumberOfTests = gmsRun * (configs.count() + modes.count());
1886 1913
1914 #ifdef EPOGER_TEST
1915 SkMSec timeBeforeSummaryOutput = SkTime::GetMSecs();
1916 #endif
1917
1887 // Output summary to stdout. 1918 // Output summary to stdout.
1888 if (FLAGS_verbose) { 1919 if (FLAGS_verbose) {
1889 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); 1920 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun);
1890 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), 1921 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(),
1891 list_all_config_names(configs).c_str()); 1922 list_all_config_names(configs).c_str());
1892 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_al l(modes).c_str()); 1923 gm_fprintf(stdout, "... and %2d modes [%s]\n", modes.count(), list_al l(modes).c_str());
1893 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe ctedNumberOfTests); 1924 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe ctedNumberOfTests);
1894 } 1925 }
1895 gmmain.ListErrors(FLAGS_verbose); 1926 gmmain.ListErrors(FLAGS_verbose);
1896 1927
1897 // TODO(epoger): Enable this check for Android, too, once we resolve 1928 // TODO(epoger): Enable this check for Android, too, once we resolve
1898 // https://code.google.com/p/skia/issues/detail?id=1222 1929 // https://code.google.com/p/skia/issues/detail?id=1222
1899 // ('GM is unexpectedly skipping tests on Android') 1930 // ('GM is unexpectedly skipping tests on Android')
1900 #ifndef SK_BUILD_FOR_ANDROID 1931 #ifndef SK_BUILD_FOR_ANDROID
1901 if (expectedNumberOfTests != gmmain.fTestsRun) { 1932 if (expectedNumberOfTests != gmmain.fTestsRun) {
1902 gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", 1933 gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n",
1903 expectedNumberOfTests, gmmain.fTestsRun); 1934 expectedNumberOfTests, gmmain.fTestsRun);
1904 reportError = true; 1935 reportError = true;
1905 } 1936 }
1906 #endif 1937 #endif
1907 1938
1939 #ifdef EPOGER_TEST
1940 Json::Value actualResults;
1941 actualResults[kJsonKey_ActualResults_Failed] =
1942 gmmain.fJsonActualResults_Failed;
1943 actualResults[kJsonKey_ActualResults_FailureIgnored] =
1944 gmmain.fJsonActualResults_FailureIgnored;
1945 actualResults[kJsonKey_ActualResults_NoComparison] =
1946 gmmain.fJsonActualResults_NoComparison;
1947 actualResults[kJsonKey_ActualResults_Succeeded] =
1948 gmmain.fJsonActualResults_Succeeded;
1949 Json::Value root;
1950 root[kJsonKey_ActualResults] = actualResults;
1951 root[kJsonKey_ExpectedResults] = gmmain.fJsonExpectedResults;
1952 std::string jsonStdString = root.toStyledString();
1953 printf("%s\n", jsonStdString.c_str());
1954 #endif
1955
1908 if (FLAGS_writeJsonSummaryPath.count() == 1) { 1956 if (FLAGS_writeJsonSummaryPath.count() == 1) {
1909 Json::Value actualResults; 1957 Json::Value actualResults;
1910 actualResults[kJsonKey_ActualResults_Failed] = 1958 actualResults[kJsonKey_ActualResults_Failed] =
1911 gmmain.fJsonActualResults_Failed; 1959 gmmain.fJsonActualResults_Failed;
1912 actualResults[kJsonKey_ActualResults_FailureIgnored] = 1960 actualResults[kJsonKey_ActualResults_FailureIgnored] =
1913 gmmain.fJsonActualResults_FailureIgnored; 1961 gmmain.fJsonActualResults_FailureIgnored;
1914 actualResults[kJsonKey_ActualResults_NoComparison] = 1962 actualResults[kJsonKey_ActualResults_NoComparison] =
1915 gmmain.fJsonActualResults_NoComparison; 1963 gmmain.fJsonActualResults_NoComparison;
1916 actualResults[kJsonKey_ActualResults_Succeeded] = 1964 actualResults[kJsonKey_ActualResults_Succeeded] =
1917 gmmain.fJsonActualResults_Succeeded; 1965 gmmain.fJsonActualResults_Succeeded;
(...skipping 17 matching lines...) Expand all
1935 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); 1983 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr);
1936 gr->printCacheStats(); 1984 gr->printCacheStats();
1937 } 1985 }
1938 } 1986 }
1939 #endif 1987 #endif
1940 1988
1941 delete grFactory; 1989 delete grFactory;
1942 #endif 1990 #endif
1943 SkGraphics::Term(); 1991 SkGraphics::Term();
1944 1992
1993 #ifdef EPOGER_TEST
1994 SkMSec timeEnd = SkTime::GetMSecs();
1995 printf("EPOGER_TEST timings with %s algorithm: %d msecs before summary outpu t, %d msecs total\n",
epoger 2013/04/24 17:36:58 patchset 3 only adds a report of which hashing alg
1996 #ifdef BITMAPHASHER_USES_TRUNCATED_MD5
1997 "MD5",
1998 #else
1999 "CityHash",
2000 #endif
2001 (timeBeforeSummaryOutput - timeStart), (timeEnd - timeStart));
2002 #endif
2003
1945 return (reportError) ? -1 : 0; 2004 return (reportError) ? -1 : 0;
1946 } 2005 }
1947 2006
1948 void GMMain::installFilter(SkCanvas* canvas) { 2007 void GMMain::installFilter(SkCanvas* canvas) {
1949 if (FLAGS_forceBWtext) { 2008 if (FLAGS_forceBWtext) {
1950 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); 2009 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref();
1951 } 2010 }
1952 } 2011 }
1953 2012
1954 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) 2013 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL)
1955 int main(int argc, char * const argv[]) { 2014 int main(int argc, char * const argv[]) {
1956 return tool_main(argc, (char**) argv); 2015 return tool_main(argc, (char**) argv);
1957 } 2016 }
1958 #endif 2017 #endif
OLDNEW
« no previous file with comments | « no previous file | src/utils/SkBitmapHasher.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698