| Index: gm/gmmain.cpp
|
| ===================================================================
|
| --- gm/gmmain.cpp (revision 9911)
|
| +++ gm/gmmain.cpp (working copy)
|
| @@ -664,7 +664,7 @@
|
| ErrorCombination write_reference_image(const ConfigData& gRec, const char writePath [],
|
| const char renderModeDescriptor [],
|
| const char *shortName,
|
| - const BitmapAndDigest& bitmapAndDigest,
|
| + const BitmapAndDigest* bitmapAndDigest,
|
| SkDynamicMemoryWStream* document) {
|
| SkString path;
|
| bool success = false;
|
| @@ -673,8 +673,8 @@
|
| (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
|
|
|
| path = make_bitmap_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
|
| - bitmapAndDigest.fDigest);
|
| - success = write_bitmap(path, bitmapAndDigest.fBitmap);
|
| + bitmapAndDigest->fDigest);
|
| + success = write_bitmap(path, bitmapAndDigest->fBitmap);
|
| }
|
| if (kPDF_Backend == gRec.fBackend) {
|
| path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor,
|
| @@ -905,47 +905,56 @@
|
| * @param gRec
|
| * @param writePath unless this is NULL, write out actual images into this
|
| * directory
|
| - * @param actualBitmap bitmap generated by this run
|
| - * @param pdf
|
| + * @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL
|
| + * if we don't have a usable bitmap representation
|
| + * @param document pdf or xps representation, if appropriate
|
| */
|
| ErrorCombination compare_test_results_to_stored_expectations(
|
| GM* gm, const ConfigData& gRec, const char writePath[],
|
| - SkBitmap& actualBitmap, SkDynamicMemoryWStream* pdf) {
|
| + const BitmapAndDigest* actualBitmapAndDigest, SkDynamicMemoryWStream* document) {
|
|
|
| - BitmapAndDigest actualBitmapAndDigest(actualBitmap);
|
| SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(), gRec.fName);
|
| SkString nameWithExtension(shortNamePlusConfig);
|
| nameWithExtension.append(".");
|
| nameWithExtension.append(kPNG_FileExtension);
|
|
|
| ErrorCombination errors;
|
| - ExpectationsSource *expectationsSource = this->fExpectationsSource.get();
|
| - if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
|
| - /*
|
| - * Get the expected results for this test, as one or more allowed
|
| - * hash digests. The current implementation of expectationsSource
|
| - * get this by computing the hash digest of a single PNG file on disk.
|
| - *
|
| - * TODO(epoger): This relies on the fact that
|
| - * force_all_opaque() was called on the bitmap before it
|
| - * was written to disk as a PNG in the first place. If
|
| - * not, the hash digest returned here may not match the
|
| - * hash digest of actualBitmap, which *has* been run through
|
| - * force_all_opaque().
|
| - * See comments above complete_bitmap() for more detail.
|
| - */
|
| - Expectations expectations = expectationsSource->get(nameWithExtension.c_str());
|
| - errors.add(compare_to_expectations(expectations, actualBitmapAndDigest,
|
| - gm->shortName(), gRec.fName, "", true));
|
| +
|
| + if (NULL == actualBitmapAndDigest) {
|
| + // Note that we intentionally skipped validating the results for
|
| + // this test, because we don't know how to generate an SkBitmap
|
| + // version of the output.
|
| + RecordTestResults(ErrorCombination(kIntentionallySkipped_ErrorType),
|
| + shortNamePlusConfig, "");
|
| } else {
|
| - // If we are running without expectations, we still want to
|
| - // record the actual results.
|
| - add_actual_results_to_json_summary(nameWithExtension.c_str(),
|
| - actualBitmapAndDigest.fDigest,
|
| - ErrorCombination(kMissingExpectations_ErrorType),
|
| - false);
|
| - RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
|
| - shortNamePlusConfig, "");
|
| + ExpectationsSource *expectationsSource = this->fExpectationsSource.get();
|
| + if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) {
|
| + /*
|
| + * Get the expected results for this test, as one or more allowed
|
| + * hash digests. The current implementation of expectationsSource
|
| + * get this by computing the hash digest of a single PNG file on disk.
|
| + *
|
| + * TODO(epoger): This relies on the fact that
|
| + * force_all_opaque() was called on the bitmap before it
|
| + * was written to disk as a PNG in the first place. If
|
| + * not, the hash digest returned here may not match the
|
| + * hash digest of actualBitmap, which *has* been run through
|
| + * force_all_opaque().
|
| + * See comments above complete_bitmap() for more detail.
|
| + */
|
| + Expectations expectations = expectationsSource->get(nameWithExtension.c_str());
|
| + errors.add(compare_to_expectations(expectations, *actualBitmapAndDigest,
|
| + gm->shortName(), gRec.fName, "", true));
|
| + } else {
|
| + // If we are running without expectations, we still want to
|
| + // record the actual results.
|
| + add_actual_results_to_json_summary(nameWithExtension.c_str(),
|
| + actualBitmapAndDigest->fDigest,
|
| + ErrorCombination(kMissingExpectations_ErrorType),
|
| + false);
|
| + RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType),
|
| + shortNamePlusConfig, "");
|
| + }
|
| }
|
|
|
| // TODO: Consider moving this into compare_to_expectations(),
|
| @@ -954,7 +963,7 @@
|
| // renderModes of all tests! That would be a lot of files.
|
| if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) {
|
| errors.add(write_reference_image(gRec, writePath, "", gm->shortName(),
|
| - actualBitmapAndDigest, pdf));
|
| + actualBitmapAndDigest, document));
|
| }
|
|
|
| return errors;
|
| @@ -1054,12 +1063,22 @@
|
| SkAutoDataUnref data(document.copyToData());
|
| SkMemoryStream stream(data->data(), data->size());
|
| SkPDFDocumentToBitmap(&stream, bitmap);
|
| +#else
|
| + bitmap = NULL; // we don't generate a bitmap rendering of the PDF file
|
| #endif
|
| } else if (gRec.fBackend == kXPS_Backend) {
|
| generate_xps(gm, document);
|
| + bitmap = NULL; // we don't generate a bitmap rendering of the XPS file
|
| }
|
| - return compare_test_results_to_stored_expectations(
|
| - gm, gRec, writePath, *bitmap, &document);
|
| +
|
| + if (NULL == bitmap) {
|
| + return compare_test_results_to_stored_expectations(
|
| + gm, gRec, writePath, NULL, &document);
|
| + } else {
|
| + BitmapAndDigest bitmapAndDigest(*bitmap);
|
| + return compare_test_results_to_stored_expectations(
|
| + gm, gRec, writePath, &bitmapAndDigest, &document);
|
| + }
|
| }
|
|
|
| ErrorCombination test_deferred_drawing(GM* gm,
|
|
|