Index: gm/gmmain.cpp |
=================================================================== |
--- gm/gmmain.cpp (revision 9647) |
+++ gm/gmmain.cpp (working copy) |
@@ -634,7 +634,7 @@ |
ErrorCombination write_reference_image(const ConfigData& gRec, const char writePath [], |
const char renderModeDescriptor [], |
- const char *shortName, SkBitmap& bitmap, |
+ const char *shortName, const SkBitmap* bitmap, |
SkDynamicMemoryWStream* document) { |
SkString path; |
bool success = false; |
@@ -644,7 +644,7 @@ |
path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor, |
kPNG_FileExtension); |
- success = write_bitmap(path, bitmap); |
+ success = write_bitmap(path, *bitmap); |
} |
if (kPDF_Backend == gRec.fBackend) { |
path = make_filename(writePath, shortName, gRec.fName, renderModeDescriptor, |
@@ -864,12 +864,13 @@ |
* @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 actualBitmap 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 SkBitmap* actualBitmap, SkDynamicMemoryWStream* document) { |
SkString shortNamePlusConfig = make_shortname_plus_config(gm->shortName(), gRec.fName); |
SkString nameWithExtension(shortNamePlusConfig); |
@@ -877,33 +878,42 @@ |
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, actualBitmap, |
- gm->shortName(), gRec.fName, "", true)); |
+ |
+ if (NULL == actualBitmap) { |
+ // 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), |
epoger
2013/06/18 05:20:10
Patchset 3 gives us better behavior... when render
|
+ shortNamePlusConfig, ""); |
} else { |
- // If we are running without expectations, we still want to |
- // record the actual results. |
- GmResultDigest actualResultDigest(actualBitmap); |
- add_actual_results_to_json_summary(nameWithExtension.c_str(), actualResultDigest, |
- ErrorCombination(kMissingExpectations_ErrorType), |
- false); |
- RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), |
- shortNamePlusConfig, ""); |
+ ExpectationsSource *expectationsSource = this->fExpectationsSource.get(); |
+ if (expectationsSource && (gRec.fFlags & kRead_ConfigFlag)) { |
epoger
2013/06/18 05:20:10
This section is just moved down and tab-indented.
|
+ /* |
+ * 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, *actualBitmap, |
+ gm->shortName(), gRec.fName, "", true)); |
+ } else { |
+ // If we are running without expectations, we still want to |
+ // record the actual results. |
+ GmResultDigest actualResultDigest(*actualBitmap); |
+ add_actual_results_to_json_summary(nameWithExtension.c_str(), actualResultDigest, |
+ ErrorCombination(kMissingExpectations_ErrorType), |
+ false); |
+ RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), |
+ shortNamePlusConfig, ""); |
+ } |
} |
// TODO: Consider moving this into compare_to_expectations(), |
@@ -912,7 +922,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(), |
- actualBitmap, pdf)); |
+ actualBitmap, document)); |
} |
return errors; |
@@ -1014,12 +1024,15 @@ |
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); |
+ gm, gRec, writePath, bitmap, &document); |
} |
ErrorCombination test_deferred_drawing(GM* gm, |