| 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 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 267 static void force_all_opaque(const SkBitmap& bitmap) { | 267 static void force_all_opaque(const SkBitmap& bitmap) { |
| 268 SkColorType colorType = bitmap.colorType(); | 268 SkColorType colorType = bitmap.colorType(); |
| 269 switch (colorType) { | 269 switch (colorType) { |
| 270 case kPMColor_SkColorType: | 270 case kPMColor_SkColorType: |
| 271 force_all_opaque_8888(bitmap); | 271 force_all_opaque_8888(bitmap); |
| 272 break; | 272 break; |
| 273 case kRGB_565_SkColorType: | 273 case kRGB_565_SkColorType: |
| 274 // nothing to do here; 565 bitmaps are inherently opaque | 274 // nothing to do here; 565 bitmaps are inherently opaque |
| 275 break; | 275 break; |
| 276 default: | 276 default: |
| 277 gm_fprintf(stderr, "unsupported bitmap colorType %d\n", colorType); | 277 SkDebugf("unsupported bitmap colorType %d\n", colorType); |
| 278 DEBUGFAIL_SEE_STDERR; | 278 DEBUGFAIL_SEE_STDERR; |
| 279 } | 279 } |
| 280 } | 280 } |
| 281 | 281 |
| 282 static void force_all_opaque_8888(const SkBitmap& bitmap) { | 282 static void force_all_opaque_8888(const SkBitmap& bitmap) { |
| 283 SkAutoLockPixels lock(bitmap); | 283 SkAutoLockPixels lock(bitmap); |
| 284 for (int y = 0; y < bitmap.height(); y++) { | 284 for (int y = 0; y < bitmap.height(); y++) { |
| 285 for (int x = 0; x < bitmap.width(); x++) { | 285 for (int x = 0; x < bitmap.width(); x++) { |
| 286 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); | 286 *bitmap.getAddr32(x, y) |= (SK_A32_MASK << SK_A32_SHIFT); |
| 287 } | 287 } |
| 288 } | 288 } |
| 289 } | 289 } |
| 290 | 290 |
| 291 static ErrorCombination write_bitmap(const SkString& path, const SkBitmap& b
itmap) { | 291 static ErrorCombination write_bitmap(const SkString& path, const SkBitmap& b
itmap) { |
| 292 // TODO(epoger): Now that we have removed force_all_opaque() | 292 // TODO(epoger): Now that we have removed force_all_opaque() |
| 293 // from this method, we should be able to get rid of the | 293 // from this method, we should be able to get rid of the |
| 294 // transformation to 8888 format also. | 294 // transformation to 8888 format also. |
| 295 SkBitmap copy; | 295 SkBitmap copy; |
| 296 bitmap.copyTo(©, kPMColor_SkColorType); | 296 bitmap.copyTo(©, kPMColor_SkColorType); |
| 297 if (!SkImageEncoder::EncodeFile(path.c_str(), copy, | 297 if (!SkImageEncoder::EncodeFile(path.c_str(), copy, |
| 298 SkImageEncoder::kPNG_Type, | 298 SkImageEncoder::kPNG_Type, |
| 299 100)) { | 299 100)) { |
| 300 gm_fprintf(stderr, "FAILED to write bitmap: %s\n", path.c_str()); | 300 SkDebugf("FAILED to write bitmap: %s\n", path.c_str()); |
| 301 return ErrorCombination(kWritingReferenceImage_ErrorType); | 301 return ErrorCombination(kWritingReferenceImage_ErrorType); |
| 302 } | 302 } |
| 303 return kEmpty_ErrorCombination; | 303 return kEmpty_ErrorCombination; |
| 304 } | 304 } |
| 305 | 305 |
| 306 /** | 306 /** |
| 307 * Add all render modes encountered thus far to the "modes" array. | 307 * Add all render modes encountered thus far to the "modes" array. |
| 308 */ | 308 */ |
| 309 void GetRenderModesEncountered(SkTArray<SkString> &modes) { | 309 void GetRenderModesEncountered(SkTArray<SkString> &modes) { |
| 310 SkTDict<int>::Iter iter(this->fRenderModesEncountered); | 310 SkTDict<int>::Iter iter(this->fRenderModesEncountered); |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 422 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; | 422 SkTArray<SkString> *failedTestsOfThisType = &fFailedTests[type]; |
| 423 int count = failedTestsOfThisType->count(); | 423 int count = failedTestsOfThisType->count(); |
| 424 line.appendf("%d %s", count, getErrorTypeName(type)); | 424 line.appendf("%d %s", count, getErrorTypeName(type)); |
| 425 if (!isIgnorableType || verbose) { | 425 if (!isIgnorableType || verbose) { |
| 426 line.append(":"); | 426 line.append(":"); |
| 427 for (int i = 0; i < count; ++i) { | 427 for (int i = 0; i < count; ++i) { |
| 428 line.append(" "); | 428 line.append(" "); |
| 429 line.append((*failedTestsOfThisType)[i]); | 429 line.append((*failedTestsOfThisType)[i]); |
| 430 } | 430 } |
| 431 } | 431 } |
| 432 gm_fprintf(stdout, "%s\n", line.c_str()); | 432 SkDebugf("%s\n", line.c_str()); |
| 433 } | 433 } |
| 434 | 434 |
| 435 /** | 435 /** |
| 436 * List contents of fFailedTests to stdout. | 436 * List contents of fFailedTests to stdout. |
| 437 * | 437 * |
| 438 * @param verbose whether to be all verbose about it | 438 * @param verbose whether to be all verbose about it |
| 439 */ | 439 */ |
| 440 void ListErrors(bool verbose) { | 440 void ListErrors(bool verbose) { |
| 441 // First, print a single summary line. | 441 // First, print a single summary line. |
| 442 SkString summary; | 442 SkString summary; |
| 443 summary.appendf("Ran %d tests:", fTestsRun); | 443 summary.appendf("Ran %d tests:", fTestsRun); |
| 444 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 444 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 445 ErrorType type = static_cast<ErrorType>(typeInt); | 445 ErrorType type = static_cast<ErrorType>(typeInt); |
| 446 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type]
.count()); | 446 summary.appendf(" %s=%d", getErrorTypeName(type), fFailedTests[type]
.count()); |
| 447 } | 447 } |
| 448 gm_fprintf(stdout, "%s\n", summary.c_str()); | 448 SkDebugf("%s\n", summary.c_str()); |
| 449 | 449 |
| 450 // Now, for each failure type, list the tests that failed that way. | 450 // Now, for each failure type, list the tests that failed that way. |
| 451 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { | 451 for (int typeInt = 0; typeInt <= kLast_ErrorType; typeInt++) { |
| 452 this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verb
ose); | 452 this->DisplayResultTypeSummary(static_cast<ErrorType>(typeInt), verb
ose); |
| 453 } | 453 } |
| 454 gm_fprintf(stdout, "(results marked with [*] will cause nonzero return v
alue)\n"); | 454 SkDebugf("(results marked with [*] will cause nonzero return value)\n"); |
| 455 } | 455 } |
| 456 | 456 |
| 457 static ErrorCombination write_document(const SkString& path, SkStreamAsset*
asset) { | 457 static ErrorCombination write_document(const SkString& path, SkStreamAsset*
asset) { |
| 458 SkFILEWStream stream(path.c_str()); | 458 SkFILEWStream stream(path.c_str()); |
| 459 if (!stream.writeStream(asset, asset->getLength())) { | 459 if (!stream.writeStream(asset, asset->getLength())) { |
| 460 gm_fprintf(stderr, "FAILED to write document: %s\n", path.c_str()); | 460 SkDebugf("FAILED to write document: %s\n", path.c_str()); |
| 461 return ErrorCombination(kWritingReferenceImage_ErrorType); | 461 return ErrorCombination(kWritingReferenceImage_ErrorType); |
| 462 } | 462 } |
| 463 return kEmpty_ErrorCombination; | 463 return kEmpty_ErrorCombination; |
| 464 } | 464 } |
| 465 | 465 |
| 466 /** | 466 /** |
| 467 * Prepare an SkBitmap to render a GM into. | 467 * Prepare an SkBitmap to render a GM into. |
| 468 * | 468 * |
| 469 * After you've rendered the GM into the SkBitmap, you must call | 469 * After you've rendered the GM into the SkBitmap, you must call |
| 470 * complete_bitmap()! | 470 * complete_bitmap()! |
| (...skipping 256 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 727 * Log more detail about the mistmatch between expectedBitmap and | 727 * Log more detail about the mistmatch between expectedBitmap and |
| 728 * actualBitmap. | 728 * actualBitmap. |
| 729 */ | 729 */ |
| 730 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act
ualBitmap, | 730 void report_bitmap_diffs(const SkBitmap& expectedBitmap, const SkBitmap& act
ualBitmap, |
| 731 const char *testName) { | 731 const char *testName) { |
| 732 const int expectedWidth = expectedBitmap.width(); | 732 const int expectedWidth = expectedBitmap.width(); |
| 733 const int expectedHeight = expectedBitmap.height(); | 733 const int expectedHeight = expectedBitmap.height(); |
| 734 const int width = actualBitmap.width(); | 734 const int width = actualBitmap.width(); |
| 735 const int height = actualBitmap.height(); | 735 const int height = actualBitmap.height(); |
| 736 if ((expectedWidth != width) || (expectedHeight != height)) { | 736 if ((expectedWidth != width) || (expectedHeight != height)) { |
| 737 gm_fprintf(stderr, "---- %s: dimension mismatch --" | 737 SkDebugf("---- %s: dimension mismatch -- expected [%d %d], actual [%
d %d]\n", |
| 738 " expected [%d %d], actual [%d %d]\n", | 738 testName, expectedWidth, expectedHeight, width, height); |
| 739 testName, expectedWidth, expectedHeight, width, height); | |
| 740 return; | 739 return; |
| 741 } | 740 } |
| 742 | 741 |
| 743 if ((kPMColor_SkColorType != expectedBitmap.colorType()) || | 742 if ((kPMColor_SkColorType != expectedBitmap.colorType()) || |
| 744 (kPMColor_SkColorType != actualBitmap.colorType())) { | 743 (kPMColor_SkColorType != actualBitmap.colorType())) { |
| 745 gm_fprintf(stderr, "---- %s: not computing max per-channel" | 744 SkDebugf("---- %s: not computing max per-channel pixel mismatch beca
use non-8888\n", |
| 746 " pixel mismatch because non-8888\n", testName); | 745 testName); |
| 747 return; | 746 return; |
| 748 } | 747 } |
| 749 | 748 |
| 750 SkAutoLockPixels alp0(expectedBitmap); | 749 SkAutoLockPixels alp0(expectedBitmap); |
| 751 SkAutoLockPixels alp1(actualBitmap); | 750 SkAutoLockPixels alp1(actualBitmap); |
| 752 int errR = 0; | 751 int errR = 0; |
| 753 int errG = 0; | 752 int errG = 0; |
| 754 int errB = 0; | 753 int errB = 0; |
| 755 int errA = 0; | 754 int errA = 0; |
| 756 int differingPixels = 0; | 755 int differingPixels = 0; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 767 (int)SkGetPackedR32(actualPixel
))); | 766 (int)SkGetPackedR32(actualPixel
))); |
| 768 errG = SkMax32(errG, SkAbs32((int)SkGetPackedG32(expectedPix
el) - | 767 errG = SkMax32(errG, SkAbs32((int)SkGetPackedG32(expectedPix
el) - |
| 769 (int)SkGetPackedG32(actualPixel
))); | 768 (int)SkGetPackedG32(actualPixel
))); |
| 770 errB = SkMax32(errB, SkAbs32((int)SkGetPackedB32(expectedPix
el) - | 769 errB = SkMax32(errB, SkAbs32((int)SkGetPackedB32(expectedPix
el) - |
| 771 (int)SkGetPackedB32(actualPixel
))); | 770 (int)SkGetPackedB32(actualPixel
))); |
| 772 errA = SkMax32(errA, SkAbs32((int)SkGetPackedA32(expectedPix
el) - | 771 errA = SkMax32(errA, SkAbs32((int)SkGetPackedA32(expectedPix
el) - |
| 773 (int)SkGetPackedA32(actualPixel
))); | 772 (int)SkGetPackedA32(actualPixel
))); |
| 774 } | 773 } |
| 775 } | 774 } |
| 776 } | 775 } |
| 777 gm_fprintf(stderr, "---- %s: %d (of %d) differing pixels," | 776 SkDebugf("---- %s: %d (of %d) differing pixels, " |
| 778 " max per-channel mismatch R=%d G=%d B=%d A=%d\n", | 777 "max per-channel mismatch R=%d G=%d B=%d A=%d\n", |
| 779 testName, differingPixels, width*height, errR, errG, errB, er
rA); | 778 testName, differingPixels, width*height, errR, errG, errB, errA
); |
| 780 } | 779 } |
| 781 | 780 |
| 782 /** | 781 /** |
| 783 * Compares actual hash digest to expectations, returning the set of errors | 782 * Compares actual hash digest to expectations, returning the set of errors |
| 784 * (if any) that we saw along the way. | 783 * (if any) that we saw along the way. |
| 785 * | 784 * |
| 786 * If fMismatchPath has been set, and there are pixel diffs, then the | 785 * If fMismatchPath has been set, and there are pixel diffs, then the |
| 787 * actual bitmap will be written out to a file within fMismatchPath. | 786 * actual bitmap will be written out to a file within fMismatchPath. |
| 788 * And similarly for fMissingExpectationsPath... | 787 * And similarly for fMissingExpectationsPath... |
| 789 * | 788 * |
| (...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1083 errors.add(write_document(path, documentStream)); | 1082 errors.add(write_document(path, documentStream)); |
| 1084 } | 1083 } |
| 1085 | 1084 |
| 1086 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) { | 1085 if (!(gm->getFlags() & GM::kSkipPDFRasterization_Flag)) { |
| 1087 for (int i = 0; i < pdfRasterizers.count(); i++) { | 1086 for (int i = 0; i < pdfRasterizers.count(); i++) { |
| 1088 SkBitmap pdfBitmap; | 1087 SkBitmap pdfBitmap; |
| 1089 documentStream->rewind(); | 1088 documentStream->rewind(); |
| 1090 bool success = (*pdfRasterizers[i]->fRasterizerFunction)
( | 1089 bool success = (*pdfRasterizers[i]->fRasterizerFunction)
( |
| 1091 documentStream.get(), &pdfBitmap); | 1090 documentStream.get(), &pdfBitmap); |
| 1092 if (!success) { | 1091 if (!success) { |
| 1093 gm_fprintf(stderr, "FAILED to render PDF for %s usin
g renderer %s\n", | 1092 SkDebugf("FAILED to render PDF for %s using renderer
%s\n", |
| 1094 gm->getName(), | 1093 gm->getName(), |
| 1095 pdfRasterizers[i]->fName); | 1094 pdfRasterizers[i]->fName); |
| 1096 continue; | 1095 continue; |
| 1097 } | 1096 } |
| 1098 | 1097 |
| 1099 SkString configName(gRec.fName); | 1098 SkString configName(gRec.fName); |
| 1100 configName.append("-"); | 1099 configName.append("-"); |
| 1101 configName.append(pdfRasterizers[i]->fName); | 1100 configName.append(pdfRasterizers[i]->fName); |
| 1102 | 1101 |
| 1103 BitmapAndDigest bitmapAndDigest(pdfBitmap); | 1102 BitmapAndDigest bitmapAndDigest(pdfBitmap); |
| 1104 errors.add(compare_test_results_to_stored_expectations( | 1103 errors.add(compare_test_results_to_stored_expectations( |
| 1105 gm, gRec, configName.c_str(), &bitmapAndDiges
t)); | 1104 gm, gRec, configName.c_str(), &bitmapAndDiges
t)); |
| (...skipping 706 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1812 * Read individual lines from a file, pushing them into the given array. | 1811 * Read individual lines from a file, pushing them into the given array. |
| 1813 * | 1812 * |
| 1814 * @param filename path to the file to read | 1813 * @param filename path to the file to read |
| 1815 * @param lines array of strings to add the lines to | 1814 * @param lines array of strings to add the lines to |
| 1816 * @returns true if able to read lines from the file | 1815 * @returns true if able to read lines from the file |
| 1817 */ | 1816 */ |
| 1818 static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines
) { | 1817 static bool read_lines_from_file(const char* filename, SkTArray<SkString> &lines
) { |
| 1819 SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); | 1818 SkAutoTUnref<SkStream> streamWrapper(SkStream::NewFromFile(filename)); |
| 1820 SkStream *stream = streamWrapper.get(); | 1819 SkStream *stream = streamWrapper.get(); |
| 1821 if (!stream) { | 1820 if (!stream) { |
| 1822 gm_fprintf(stderr, "unable to read file '%s'\n", filename); | 1821 SkDebugf("unable to read file '%s'\n", filename); |
| 1823 return false; | 1822 return false; |
| 1824 } | 1823 } |
| 1825 | 1824 |
| 1826 char c; | 1825 char c; |
| 1827 SkString line; | 1826 SkString line; |
| 1828 while (1 == stream->read(&c, 1)) { | 1827 while (1 == stream->read(&c, 1)) { |
| 1829 // If we hit either CR or LF, we've completed a line. | 1828 // If we hit either CR or LF, we've completed a line. |
| 1830 // | 1829 // |
| 1831 // TODO: If the file uses both CR and LF, this will return an extra blan
k | 1830 // TODO: If the file uses both CR and LF, this will return an extra blan
k |
| 1832 // line for each line of the file. Which is OK for current purposes... | 1831 // line for each line of the file. Which is OK for current purposes... |
| (...skipping 92 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1925 } | 1924 } |
| 1926 int index = findConfig(config); | 1925 int index = findConfig(config); |
| 1927 if (index >= 0) { | 1926 if (index >= 0) { |
| 1928 if (exclude) { | 1927 if (exclude) { |
| 1929 *excludeConfigs.append() = index; | 1928 *excludeConfigs.append() = index; |
| 1930 } else { | 1929 } else { |
| 1931 appendUnique<size_t>(outConfigs, index); | 1930 appendUnique<size_t>(outConfigs, index); |
| 1932 } | 1931 } |
| 1933 } else if (0 == strcmp(kDefaultsConfigStr, config)) { | 1932 } else if (0 == strcmp(kDefaultsConfigStr, config)) { |
| 1934 if (exclude) { | 1933 if (exclude) { |
| 1935 gm_fprintf(stderr, "%c%s is not allowed.\n", | 1934 SkDebugf("%c%s is not allowed.\n", |
| 1936 kExcludeConfigChar, kDefaultsConfigStr); | 1935 kExcludeConfigChar, kDefaultsConfigStr); |
| 1937 return false; | 1936 return false; |
| 1938 } | 1937 } |
| 1939 for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) { | 1938 for (size_t c = 0; c < SK_ARRAY_COUNT(gRec); ++c) { |
| 1940 if (gRec[c].fRunByDefault) { | 1939 if (gRec[c].fRunByDefault) { |
| 1941 appendUnique<size_t>(outConfigs, c); | 1940 appendUnique<size_t>(outConfigs, c); |
| 1942 } | 1941 } |
| 1943 } | 1942 } |
| 1944 } else { | 1943 } else { |
| 1945 gm_fprintf(stderr, "unrecognized config %s\n", config); | 1944 SkDebugf("unrecognized config %s\n", config); |
| 1946 return false; | 1945 return false; |
| 1947 } | 1946 } |
| 1948 } | 1947 } |
| 1949 | 1948 |
| 1950 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { | 1949 for (int i = 0; i < FLAGS_excludeConfig.count(); i++) { |
| 1951 int index = findConfig(FLAGS_excludeConfig[i]); | 1950 int index = findConfig(FLAGS_excludeConfig[i]); |
| 1952 if (index >= 0) { | 1951 if (index >= 0) { |
| 1953 *excludeConfigs.append() = index; | 1952 *excludeConfigs.append() = index; |
| 1954 } else { | 1953 } else { |
| 1955 gm_fprintf(stderr, "unrecognized excludeConfig %s\n", FLAGS_excludeC
onfig[i]); | 1954 SkDebugf("unrecognized excludeConfig %s\n", FLAGS_excludeConfig[i]); |
| 1956 return false; | 1955 return false; |
| 1957 } | 1956 } |
| 1958 } | 1957 } |
| 1959 | 1958 |
| 1960 if (outConfigs->count() == 0) { | 1959 if (outConfigs->count() == 0) { |
| 1961 // if no config is specified by user, add the defaults | 1960 // if no config is specified by user, add the defaults |
| 1962 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { | 1961 for (size_t i = 0; i < SK_ARRAY_COUNT(gRec); ++i) { |
| 1963 if (gRec[i].fRunByDefault) { | 1962 if (gRec[i].fRunByDefault) { |
| 1964 *outConfigs->append() = i; | 1963 *outConfigs->append() = i; |
| 1965 } | 1964 } |
| 1966 } | 1965 } |
| 1967 } | 1966 } |
| 1968 // now remove any explicitly excluded configs | 1967 // now remove any explicitly excluded configs |
| 1969 for (int i = 0; i < excludeConfigs.count(); ++i) { | 1968 for (int i = 0; i < excludeConfigs.count(); ++i) { |
| 1970 int index = outConfigs->find(excludeConfigs[i]); | 1969 int index = outConfigs->find(excludeConfigs[i]); |
| 1971 if (index >= 0) { | 1970 if (index >= 0) { |
| 1972 outConfigs->remove(index); | 1971 outConfigs->remove(index); |
| 1973 // now assert that there was only one copy in configs[] | 1972 // now assert that there was only one copy in configs[] |
| 1974 SkASSERT(outConfigs->find(excludeConfigs[i]) < 0); | 1973 SkASSERT(outConfigs->find(excludeConfigs[i]) < 0); |
| 1975 } | 1974 } |
| 1976 } | 1975 } |
| 1977 | 1976 |
| 1978 #if SK_SUPPORT_GPU | 1977 #if SK_SUPPORT_GPU |
| 1979 SkASSERT(grFactory != NULL); | 1978 SkASSERT(grFactory != NULL); |
| 1980 for (int i = 0; i < outConfigs->count(); ++i) { | 1979 for (int i = 0; i < outConfigs->count(); ++i) { |
| 1981 size_t index = (*outConfigs)[i]; | 1980 size_t index = (*outConfigs)[i]; |
| 1982 if (kGPU_Backend == gRec[index].fBackend) { | 1981 if (kGPU_Backend == gRec[index].fBackend) { |
| 1983 GrContext* ctx = grFactory->get(gRec[index].fGLContextType); | 1982 GrContext* ctx = grFactory->get(gRec[index].fGLContextType); |
| 1984 if (NULL == ctx) { | 1983 if (NULL == ctx) { |
| 1985 gm_fprintf(stderr, "GrContext could not be created for config %s
." | 1984 SkDebugf("GrContext could not be created for config %s. Config w
ill be skipped.\n", |
| 1986 " Config will be skipped.\n", gRec[index].fName); | 1985 gRec[index].fName); |
| 1987 outConfigs->remove(i); | 1986 outConfigs->remove(i); |
| 1988 --i; | 1987 --i; |
| 1989 continue; | 1988 continue; |
| 1990 } | 1989 } |
| 1991 if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { | 1990 if (gRec[index].fSampleCnt > ctx->getMaxSampleCount()) { |
| 1992 gm_fprintf(stderr, "Sample count (%d) of config %s is not suppor
ted." | 1991 SkDebugf("Sample count (%d) of config %s is not supported." |
| 1993 " Config will be skipped.\n", | 1992 " Config will be skipped.\n", |
| 1994 gRec[index].fSampleCnt, gRec[index].fName); | 1993 gRec[index].fSampleCnt, gRec[index].fName); |
| 1995 outConfigs->remove(i); | 1994 outConfigs->remove(i); |
| 1996 --i; | 1995 --i; |
| 1997 } | 1996 } |
| 1998 } | 1997 } |
| 1999 } | 1998 } |
| 2000 #endif | 1999 #endif |
| 2001 | 2000 |
| 2002 if (outConfigs->isEmpty()) { | 2001 if (outConfigs->isEmpty()) { |
| 2003 gm_fprintf(stderr, "No configs to run."); | 2002 SkDebugf("No configs to run."); |
| 2004 return false; | 2003 return false; |
| 2005 } | 2004 } |
| 2006 | 2005 |
| 2007 // now show the user the set of configs that will be run. | 2006 // now show the user the set of configs that will be run. |
| 2008 SkString configStr("These configs will be run:"); | 2007 SkString configStr("These configs will be run:"); |
| 2009 // show the user the config that will run. | 2008 // show the user the config that will run. |
| 2010 for (int i = 0; i < outConfigs->count(); ++i) { | 2009 for (int i = 0; i < outConfigs->count(); ++i) { |
| 2011 configStr.appendf(" %s", gRec[(*outConfigs)[i]].fName); | 2010 configStr.appendf(" %s", gRec[(*outConfigs)[i]].fName); |
| 2012 } | 2011 } |
| 2013 gm_fprintf(stdout, "%s\n", configStr.c_str()); | 2012 SkDebugf("%s\n", configStr.c_str()); |
| 2014 | 2013 |
| 2015 return true; | 2014 return true; |
| 2016 } | 2015 } |
| 2017 | 2016 |
| 2018 static bool parse_flags_pdf_rasterizers(const SkTDArray<size_t>& configs, | 2017 static bool parse_flags_pdf_rasterizers(const SkTDArray<size_t>& configs, |
| 2019 SkTDArray<const PDFRasterizerData*>* out
Rasterizers) { | 2018 SkTDArray<const PDFRasterizerData*>* out
Rasterizers) { |
| 2020 // No need to run this check (and display the PDF rasterizers message) | 2019 // No need to run this check (and display the PDF rasterizers message) |
| 2021 // if no PDF backends are in the configs. | 2020 // if no PDF backends are in the configs. |
| 2022 bool configHasPDF = false; | 2021 bool configHasPDF = false; |
| 2023 for (int i = 0; i < configs.count(); i++) { | 2022 for (int i = 0; i < configs.count(); i++) { |
| (...skipping 12 matching lines...) Expand all Loading... |
| 2036 if (kPDFRasterizers[i].fRunByDefault) { | 2035 if (kPDFRasterizers[i].fRunByDefault) { |
| 2037 *outRasterizers->append() = &kPDFRasterizers[i]; | 2036 *outRasterizers->append() = &kPDFRasterizers[i]; |
| 2038 } | 2037 } |
| 2039 } | 2038 } |
| 2040 } else { | 2039 } else { |
| 2041 for (int i = 0; i < FLAGS_pdfRasterizers.count(); i++) { | 2040 for (int i = 0; i < FLAGS_pdfRasterizers.count(); i++) { |
| 2042 const char* rasterizer = FLAGS_pdfRasterizers[i]; | 2041 const char* rasterizer = FLAGS_pdfRasterizers[i]; |
| 2043 const PDFRasterizerData* rasterizerPtr = | 2042 const PDFRasterizerData* rasterizerPtr = |
| 2044 findPDFRasterizer(rasterizer); | 2043 findPDFRasterizer(rasterizer); |
| 2045 if (rasterizerPtr == NULL) { | 2044 if (rasterizerPtr == NULL) { |
| 2046 gm_fprintf(stderr, "unrecognized rasterizer %s\n", rasterizer); | 2045 SkDebugf("unrecognized rasterizer %s\n", rasterizer); |
| 2047 return false; | 2046 return false; |
| 2048 } | 2047 } |
| 2049 appendUnique<const PDFRasterizerData*>(outRasterizers, | 2048 appendUnique<const PDFRasterizerData*>(outRasterizers, |
| 2050 rasterizerPtr); | 2049 rasterizerPtr); |
| 2051 } | 2050 } |
| 2052 } | 2051 } |
| 2053 | 2052 |
| 2054 // now show the user the set of configs that will be run. | 2053 // now show the user the set of configs that will be run. |
| 2055 SkString configStr("These PDF rasterizers will be run:"); | 2054 SkString configStr("These PDF rasterizers will be run:"); |
| 2056 // show the user the config that will run. | 2055 // show the user the config that will run. |
| 2057 for (int i = 0; i < outRasterizers->count(); ++i) { | 2056 for (int i = 0; i < outRasterizers->count(); ++i) { |
| 2058 configStr.appendf(" %s", (*outRasterizers)[i]->fName); | 2057 configStr.appendf(" %s", (*outRasterizers)[i]->fName); |
| 2059 } | 2058 } |
| 2060 gm_fprintf(stdout, "%s\n", configStr.c_str()); | 2059 SkDebugf("%s\n", configStr.c_str()); |
| 2061 | 2060 |
| 2062 return true; | 2061 return true; |
| 2063 } | 2062 } |
| 2064 | 2063 |
| 2065 static bool parse_flags_ignore_error_types(ErrorCombination* outErrorTypes) { | 2064 static bool parse_flags_ignore_error_types(ErrorCombination* outErrorTypes) { |
| 2066 if (FLAGS_ignoreErrorTypes.count() > 0) { | 2065 if (FLAGS_ignoreErrorTypes.count() > 0) { |
| 2067 *outErrorTypes = ErrorCombination(); | 2066 *outErrorTypes = ErrorCombination(); |
| 2068 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { | 2067 for (int i = 0; i < FLAGS_ignoreErrorTypes.count(); i++) { |
| 2069 ErrorType type; | 2068 ErrorType type; |
| 2070 const char *name = FLAGS_ignoreErrorTypes[i]; | 2069 const char *name = FLAGS_ignoreErrorTypes[i]; |
| 2071 if (!getErrorTypeByName(name, &type)) { | 2070 if (!getErrorTypeByName(name, &type)) { |
| 2072 gm_fprintf(stderr, "cannot find ErrorType with name '%s'\n", nam
e); | 2071 SkDebugf("cannot find ErrorType with name '%s'\n", name); |
| 2073 return false; | 2072 return false; |
| 2074 } else { | 2073 } else { |
| 2075 outErrorTypes->add(type); | 2074 outErrorTypes->add(type); |
| 2076 } | 2075 } |
| 2077 } | 2076 } |
| 2078 } | 2077 } |
| 2079 return true; | 2078 return true; |
| 2080 } | 2079 } |
| 2081 | 2080 |
| 2082 /** | 2081 /** |
| (...skipping 22 matching lines...) Expand all Loading... |
| 2105 | 2104 |
| 2106 return true; | 2105 return true; |
| 2107 } | 2106 } |
| 2108 | 2107 |
| 2109 static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { | 2108 static bool parse_flags_modulo(int* moduloRemainder, int* moduloDivisor) { |
| 2110 if (FLAGS_modulo.count() == 2) { | 2109 if (FLAGS_modulo.count() == 2) { |
| 2111 *moduloRemainder = atoi(FLAGS_modulo[0]); | 2110 *moduloRemainder = atoi(FLAGS_modulo[0]); |
| 2112 *moduloDivisor = atoi(FLAGS_modulo[1]); | 2111 *moduloDivisor = atoi(FLAGS_modulo[1]); |
| 2113 if (*moduloRemainder < 0 || *moduloDivisor <= 0 || | 2112 if (*moduloRemainder < 0 || *moduloDivisor <= 0 || |
| 2114 *moduloRemainder >= *moduloDivisor) { | 2113 *moduloRemainder >= *moduloDivisor) { |
| 2115 gm_fprintf(stderr, "invalid modulo values."); | 2114 SkDebugf("invalid modulo values."); |
| 2116 return false; | 2115 return false; |
| 2117 } | 2116 } |
| 2118 } | 2117 } |
| 2119 return true; | 2118 return true; |
| 2120 } | 2119 } |
| 2121 | 2120 |
| 2122 #if SK_SUPPORT_GPU | 2121 #if SK_SUPPORT_GPU |
| 2123 static bool parse_flags_gpu_cache(int* sizeBytes, int* sizeCount) { | 2122 static bool parse_flags_gpu_cache(int* sizeBytes, int* sizeCount) { |
| 2124 if (FLAGS_gpuCacheSize.count() > 0) { | 2123 if (FLAGS_gpuCacheSize.count() > 0) { |
| 2125 if (FLAGS_gpuCacheSize.count() != 2) { | 2124 if (FLAGS_gpuCacheSize.count() != 2) { |
| 2126 gm_fprintf(stderr, "--gpuCacheSize requires two arguments\n"); | 2125 SkDebugf("--gpuCacheSize requires two arguments\n"); |
| 2127 return false; | 2126 return false; |
| 2128 } | 2127 } |
| 2129 *sizeBytes = atoi(FLAGS_gpuCacheSize[0]); | 2128 *sizeBytes = atoi(FLAGS_gpuCacheSize[0]); |
| 2130 *sizeCount = atoi(FLAGS_gpuCacheSize[1]); | 2129 *sizeCount = atoi(FLAGS_gpuCacheSize[1]); |
| 2131 } else { | 2130 } else { |
| 2132 *sizeBytes = DEFAULT_CACHE_VALUE; | 2131 *sizeBytes = DEFAULT_CACHE_VALUE; |
| 2133 *sizeCount = DEFAULT_CACHE_VALUE; | 2132 *sizeCount = DEFAULT_CACHE_VALUE; |
| 2134 } | 2133 } |
| 2135 return true; | 2134 return true; |
| 2136 } | 2135 } |
| 2137 #endif | 2136 #endif |
| 2138 | 2137 |
| 2139 static bool parse_flags_tile_grid_replay_scales(SkTDArray<SkScalar>* outScales)
{ | 2138 static bool parse_flags_tile_grid_replay_scales(SkTDArray<SkScalar>* outScales)
{ |
| 2140 *outScales->append() = SK_Scalar1; // By default only test at scale 1.0 | 2139 *outScales->append() = SK_Scalar1; // By default only test at scale 1.0 |
| 2141 if (FLAGS_tileGridReplayScales.count() > 0) { | 2140 if (FLAGS_tileGridReplayScales.count() > 0) { |
| 2142 outScales->reset(); | 2141 outScales->reset(); |
| 2143 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { | 2142 for (int i = 0; i < FLAGS_tileGridReplayScales.count(); i++) { |
| 2144 double val = atof(FLAGS_tileGridReplayScales[i]); | 2143 double val = atof(FLAGS_tileGridReplayScales[i]); |
| 2145 if (0 < val) { | 2144 if (0 < val) { |
| 2146 *outScales->append() = SkDoubleToScalar(val); | 2145 *outScales->append() = SkDoubleToScalar(val); |
| 2147 } | 2146 } |
| 2148 } | 2147 } |
| 2149 if (0 == outScales->count()) { | 2148 if (0 == outScales->count()) { |
| 2150 // Should have at least one scale | 2149 // Should have at least one scale |
| 2151 gm_fprintf(stderr, "--tileGridReplayScales requires at least one sca
le.\n"); | 2150 SkDebugf("--tileGridReplayScales requires at least one scale.\n"); |
| 2152 return false; | 2151 return false; |
| 2153 } | 2152 } |
| 2154 } | 2153 } |
| 2155 return true; | 2154 return true; |
| 2156 } | 2155 } |
| 2157 | 2156 |
| 2158 static bool parse_flags_gmmain_paths(GMMain* gmmain) { | 2157 static bool parse_flags_gmmain_paths(GMMain* gmmain) { |
| 2159 gmmain->fUseFileHierarchy = FLAGS_hierarchy; | 2158 gmmain->fUseFileHierarchy = FLAGS_hierarchy; |
| 2160 gmmain->fWriteChecksumBasedFilenames = FLAGS_writeChecksumBasedFilenames; | 2159 gmmain->fWriteChecksumBasedFilenames = FLAGS_writeChecksumBasedFilenames; |
| 2161 | 2160 |
| 2162 if (FLAGS_mismatchPath.count() == 1) { | 2161 if (FLAGS_mismatchPath.count() == 1) { |
| 2163 gmmain->fMismatchPath = FLAGS_mismatchPath[0]; | 2162 gmmain->fMismatchPath = FLAGS_mismatchPath[0]; |
| 2164 } | 2163 } |
| 2165 | 2164 |
| 2166 if (FLAGS_missingExpectationsPath.count() == 1) { | 2165 if (FLAGS_missingExpectationsPath.count() == 1) { |
| 2167 gmmain->fMissingExpectationsPath = FLAGS_missingExpectationsPath[0]; | 2166 gmmain->fMissingExpectationsPath = FLAGS_missingExpectationsPath[0]; |
| 2168 } | 2167 } |
| 2169 | 2168 |
| 2170 if (FLAGS_readPath.count() == 1) { | 2169 if (FLAGS_readPath.count() == 1) { |
| 2171 const char* readPath = FLAGS_readPath[0]; | 2170 const char* readPath = FLAGS_readPath[0]; |
| 2172 if (!sk_exists(readPath)) { | 2171 if (!sk_exists(readPath)) { |
| 2173 gm_fprintf(stderr, "readPath %s does not exist!\n", readPath); | 2172 SkDebugf("readPath %s does not exist!\n", readPath); |
| 2174 return false; | 2173 return false; |
| 2175 } | 2174 } |
| 2176 if (sk_isdir(readPath)) { | 2175 if (sk_isdir(readPath)) { |
| 2177 if (FLAGS_verbose) { | 2176 if (FLAGS_verbose) { |
| 2178 gm_fprintf(stdout, "reading from %s\n", readPath); | 2177 SkDebugf("reading from %s\n", readPath); |
| 2179 } | 2178 } |
| 2180 gmmain->fExpectationsSource.reset(SkNEW_ARGS( | 2179 gmmain->fExpectationsSource.reset(SkNEW_ARGS( |
| 2181 IndividualImageExpectationsSource, (readPath))); | 2180 IndividualImageExpectationsSource, (readPath))); |
| 2182 } else { | 2181 } else { |
| 2183 if (FLAGS_verbose) { | 2182 if (FLAGS_verbose) { |
| 2184 gm_fprintf(stdout, "reading expectations from JSON summary file
%s\n", readPath); | 2183 SkDebugf("reading expectations from JSON summary file %s\n", rea
dPath); |
| 2185 } | 2184 } |
| 2186 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource,
(readPath))); | 2185 gmmain->fExpectationsSource.reset(SkNEW_ARGS(JsonExpectationsSource,
(readPath))); |
| 2187 } | 2186 } |
| 2188 } | 2187 } |
| 2189 return true; | 2188 return true; |
| 2190 } | 2189 } |
| 2191 | 2190 |
| 2192 static bool parse_flags_resource_path() { | 2191 static bool parse_flags_resource_path() { |
| 2193 if (FLAGS_resourcePath.count() == 1) { | 2192 if (FLAGS_resourcePath.count() == 1) { |
| 2194 GM::SetResourcePath(FLAGS_resourcePath[0]); | 2193 GM::SetResourcePath(FLAGS_resourcePath[0]); |
| 2195 } | 2194 } |
| 2196 return true; | 2195 return true; |
| 2197 } | 2196 } |
| 2198 | 2197 |
| 2199 static bool parse_flags_jpeg_quality() { | 2198 static bool parse_flags_jpeg_quality() { |
| 2200 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { | 2199 if (FLAGS_pdfJpegQuality < -1 || FLAGS_pdfJpegQuality > 100) { |
| 2201 gm_fprintf(stderr, "%s\n", "pdfJpegQuality must be in [-1 .. 100] range.
"); | 2200 SkDebugf("%s\n", "pdfJpegQuality must be in [-1 .. 100] range."); |
| 2202 return false; | 2201 return false; |
| 2203 } | 2202 } |
| 2204 return true; | 2203 return true; |
| 2205 } | 2204 } |
| 2206 | 2205 |
| 2207 int tool_main(int argc, char** argv); | 2206 int tool_main(int argc, char** argv); |
| 2208 int tool_main(int argc, char** argv) { | 2207 int tool_main(int argc, char** argv) { |
| 2209 | 2208 |
| 2210 SkString usage; | 2209 SkString usage; |
| 2211 usage.printf("Run the golden master tests.\n"); | 2210 usage.printf("Run the golden master tests.\n"); |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2247 !parse_flags_resource_path() || | 2246 !parse_flags_resource_path() || |
| 2248 !parse_flags_jpeg_quality() || | 2247 !parse_flags_jpeg_quality() || |
| 2249 !parse_flags_configs(&configs, grFactory) || | 2248 !parse_flags_configs(&configs, grFactory) || |
| 2250 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) || | 2249 !parse_flags_pdf_rasterizers(configs, &pdfRasterizers) || |
| 2251 !parse_flags_gmmain_paths(&gmmain)) { | 2250 !parse_flags_gmmain_paths(&gmmain)) { |
| 2252 return -1; | 2251 return -1; |
| 2253 } | 2252 } |
| 2254 | 2253 |
| 2255 if (FLAGS_verbose) { | 2254 if (FLAGS_verbose) { |
| 2256 if (FLAGS_writePath.count() == 1) { | 2255 if (FLAGS_writePath.count() == 1) { |
| 2257 gm_fprintf(stdout, "writing to %s\n", FLAGS_writePath[0]); | 2256 SkDebugf("writing to %s\n", FLAGS_writePath[0]); |
| 2258 } | 2257 } |
| 2259 if (NULL != gmmain.fMismatchPath) { | 2258 if (NULL != gmmain.fMismatchPath) { |
| 2260 gm_fprintf(stdout, "writing mismatches to %s\n", gmmain.fMismatchPat
h); | 2259 SkDebugf("writing mismatches to %s\n", gmmain.fMismatchPath); |
| 2261 } | 2260 } |
| 2262 if (NULL != gmmain.fMissingExpectationsPath) { | 2261 if (NULL != gmmain.fMissingExpectationsPath) { |
| 2263 gm_fprintf(stdout, "writing images without expectations to %s\n", | 2262 SkDebugf("writing images without expectations to %s\n", |
| 2264 gmmain.fMissingExpectationsPath); | 2263 gmmain.fMissingExpectationsPath); |
| 2265 } | 2264 } |
| 2266 if (FLAGS_writePicturePath.count() == 1) { | 2265 if (FLAGS_writePicturePath.count() == 1) { |
| 2267 gm_fprintf(stdout, "writing pictures to %s\n", FLAGS_writePicturePat
h[0]); | 2266 SkDebugf("writing pictures to %s\n", FLAGS_writePicturePath[0]); |
| 2268 } | 2267 } |
| 2269 if (FLAGS_resourcePath.count() == 1) { | 2268 if (FLAGS_resourcePath.count() == 1) { |
| 2270 gm_fprintf(stdout, "reading resources from %s\n", FLAGS_resourcePath
[0]); | 2269 SkDebugf("reading resources from %s\n", FLAGS_resourcePath[0]); |
| 2271 } | 2270 } |
| 2272 } | 2271 } |
| 2273 | 2272 |
| 2274 int gmsRun = 0; | 2273 int gmsRun = 0; |
| 2275 int gmIndex = -1; | 2274 int gmIndex = -1; |
| 2276 SkString moduloStr; | 2275 SkString moduloStr; |
| 2277 | 2276 |
| 2278 // If we will be writing out files, prepare subdirectories. | 2277 // If we will be writing out files, prepare subdirectories. |
| 2279 if (FLAGS_writePath.count() == 1) { | 2278 if (FLAGS_writePath.count() == 1) { |
| 2280 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy
, | 2279 if (!prepare_subdirectories(FLAGS_writePath[0], gmmain.fUseFileHierarchy
, |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2317 } | 2316 } |
| 2318 | 2317 |
| 2319 const char* shortName = gm->getName(); | 2318 const char* shortName = gm->getName(); |
| 2320 | 2319 |
| 2321 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { | 2320 if (SkCommandLineFlags::ShouldSkip(FLAGS_match, shortName)) { |
| 2322 continue; | 2321 continue; |
| 2323 } | 2322 } |
| 2324 | 2323 |
| 2325 gmsRun++; | 2324 gmsRun++; |
| 2326 SkISize size = gm->getISize(); | 2325 SkISize size = gm->getISize(); |
| 2327 gm_fprintf(stdout, "%sdrawing... %s [%d %d]\n", moduloStr.c_str(), short
Name, | 2326 SkDebugf("%sdrawing... %s [%d %d]\n", moduloStr.c_str(), shortName, |
| 2328 size.width(), size.height()); | 2327 size.width(), size.height()); |
| 2329 | 2328 |
| 2330 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplay
Scales, grFactory); | 2329 run_multiple_configs(gmmain, gm, configs, pdfRasterizers, tileGridReplay
Scales, grFactory); |
| 2331 } | 2330 } |
| 2332 | 2331 |
| 2333 SkTArray<SkString> modes; | 2332 SkTArray<SkString> modes; |
| 2334 gmmain.GetRenderModesEncountered(modes); | 2333 gmmain.GetRenderModesEncountered(modes); |
| 2335 int modeCount = modes.count(); | 2334 int modeCount = modes.count(); |
| 2336 | 2335 |
| 2337 // Now that we have run all the tests and thus know the full set of renderMo
des that we | 2336 // Now that we have run all the tests and thus know the full set of renderMo
des that we |
| 2338 // tried to run, we can call RecordTestResults() to record the cases in whic
h we skipped | 2337 // tried to run, we can call RecordTestResults() to record the cases in whic
h we skipped |
| (...skipping 19 matching lines...) Expand all Loading... |
| 2358 if (gRec[configs[i]].fBackend == kRaster_Backend) { | 2357 if (gRec[configs[i]].fBackend == kRaster_Backend) { |
| 2359 rasterConfigs++; | 2358 rasterConfigs++; |
| 2360 } | 2359 } |
| 2361 } | 2360 } |
| 2362 // For raster configs, we run all renderModes; for non-raster configs, just
default renderMode | 2361 // For raster configs, we run all renderModes; for non-raster configs, just
default renderMode |
| 2363 const int expectedNumberOfTests = rasterConfigs * gmsRun * modeCount | 2362 const int expectedNumberOfTests = rasterConfigs * gmsRun * modeCount |
| 2364 + (configs.count() - rasterConfigs) * gmsRun
; | 2363 + (configs.count() - rasterConfigs) * gmsRun
; |
| 2365 | 2364 |
| 2366 // Output summary to stdout. | 2365 // Output summary to stdout. |
| 2367 if (FLAGS_verbose) { | 2366 if (FLAGS_verbose) { |
| 2368 gm_fprintf(stdout, "Ran %d GMs\n", gmsRun); | 2367 SkDebugf("Ran %d GMs\n", gmsRun); |
| 2369 gm_fprintf(stdout, "... over %2d configs [%s]\n", configs.count(), | 2368 SkDebugf("... over %2d configs [%s]\n", configs.count(), |
| 2370 list_all_config_names(configs).c_str()); | 2369 list_all_config_names(configs).c_str()); |
| 2371 gm_fprintf(stdout, "... and %2d modes [%s]\n", modeCount, list_all(mo
des).c_str()); | 2370 SkDebugf("... and %2d modes [%s]\n", modeCount, list_all(modes).c_str
()); |
| 2372 gm_fprintf(stdout, "... so there should be a total of %d tests.\n", expe
ctedNumberOfTests); | 2371 SkDebugf("... so there should be a total of %d tests.\n", expectedNumber
OfTests); |
| 2373 } | 2372 } |
| 2374 gmmain.ListErrors(FLAGS_verbose); | 2373 gmmain.ListErrors(FLAGS_verbose); |
| 2375 | 2374 |
| 2376 // TODO(epoger): Enable this check for Android, too, once we resolve | 2375 // TODO(epoger): Enable this check for Android, too, once we resolve |
| 2377 // https://code.google.com/p/skia/issues/detail?id=1222 | 2376 // https://code.google.com/p/skia/issues/detail?id=1222 |
| 2378 // ('GM is unexpectedly skipping tests on Android') | 2377 // ('GM is unexpectedly skipping tests on Android') |
| 2379 #ifndef SK_BUILD_FOR_ANDROID | 2378 #ifndef SK_BUILD_FOR_ANDROID |
| 2380 if (expectedNumberOfTests != gmmain.fTestsRun) { | 2379 if (expectedNumberOfTests != gmmain.fTestsRun) { |
| 2381 gm_fprintf(stderr, "expected %d tests, but ran or skipped %d tests\n", | 2380 SkDebugf("expected %d tests, but ran or skipped %d tests\n", |
| 2382 expectedNumberOfTests, gmmain.fTestsRun); | 2381 expectedNumberOfTests, gmmain.fTestsRun); |
| 2383 reportError = true; | 2382 reportError = true; |
| 2384 } | 2383 } |
| 2385 #endif | 2384 #endif |
| 2386 | 2385 |
| 2387 if (FLAGS_writeJsonSummaryPath.count() == 1) { | 2386 if (FLAGS_writeJsonSummaryPath.count() == 1) { |
| 2388 Json::Value root = CreateJsonTree( | 2387 Json::Value root = CreateJsonTree( |
| 2389 gmmain.fJsonExpectedResults, | 2388 gmmain.fJsonExpectedResults, |
| 2390 gmmain.fJsonActualResults_Failed, gmmain.fJsonActualResults_FailureI
gnored, | 2389 gmmain.fJsonActualResults_Failed, gmmain.fJsonActualResults_FailureI
gnored, |
| 2391 gmmain.fJsonActualResults_NoComparison, gmmain.fJsonActualResults_Su
cceeded); | 2390 gmmain.fJsonActualResults_NoComparison, gmmain.fJsonActualResults_Su
cceeded); |
| 2392 std::string jsonStdString = root.toStyledString(); | 2391 std::string jsonStdString = root.toStyledString(); |
| 2393 SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); | 2392 SkFILEWStream stream(FLAGS_writeJsonSummaryPath[0]); |
| 2394 stream.write(jsonStdString.c_str(), jsonStdString.length()); | 2393 stream.write(jsonStdString.c_str(), jsonStdString.length()); |
| 2395 } | 2394 } |
| 2396 | 2395 |
| 2397 #if SK_SUPPORT_GPU | 2396 #if SK_SUPPORT_GPU |
| 2398 | 2397 |
| 2399 #if GR_CACHE_STATS | 2398 #if GR_CACHE_STATS |
| 2400 for (int i = 0; i < configs.count(); i++) { | 2399 for (int i = 0; i < configs.count(); i++) { |
| 2401 ConfigData config = gRec[configs[i]]; | 2400 ConfigData config = gRec[configs[i]]; |
| 2402 | 2401 |
| 2403 if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) { | 2402 if (FLAGS_verbose && (kGPU_Backend == config.fBackend)) { |
| 2404 GrContext* gr = grFactory->get(config.fGLContextType); | 2403 GrContext* gr = grFactory->get(config.fGLContextType); |
| 2405 | 2404 |
| 2406 gm_fprintf(stdout, "config: %s %x\n", config.fName, gr); | 2405 SkDebugf("config: %s %x\n", config.fName, gr); |
| 2407 gr->printCacheStats(); | 2406 gr->printCacheStats(); |
| 2408 } | 2407 } |
| 2409 } | 2408 } |
| 2410 #endif | 2409 #endif |
| 2411 | 2410 |
| 2412 delete grFactory; | 2411 delete grFactory; |
| 2413 #endif | 2412 #endif |
| 2414 SkGraphics::Term(); | 2413 SkGraphics::Term(); |
| 2415 | 2414 |
| 2416 return (reportError) ? -1 : 0; | 2415 return (reportError) ? -1 : 0; |
| 2417 } | 2416 } |
| 2418 | 2417 |
| 2419 void GMMain::installFilter(SkCanvas* canvas) { | 2418 void GMMain::installFilter(SkCanvas* canvas) { |
| 2420 if (FLAGS_forceBWtext) { | 2419 if (FLAGS_forceBWtext) { |
| 2421 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); | 2420 canvas->setDrawFilter(SkNEW(BWTextDrawFilter))->unref(); |
| 2422 } | 2421 } |
| 2423 } | 2422 } |
| 2424 | 2423 |
| 2425 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 2424 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 2426 int main(int argc, char * const argv[]) { | 2425 int main(int argc, char * const argv[]) { |
| 2427 return tool_main(argc, (char**) argv); | 2426 return tool_main(argc, (char**) argv); |
| 2428 } | 2427 } |
| 2429 #endif | 2428 #endif |
| OLD | NEW |