Index: gm/gmmain.cpp |
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp |
index 9b2f9a13c2003710bcf3351e30b4f8457f05888e..ece8ff32d4888f0d26cb2768df7c4ed5d7b118e6 100644 |
--- a/gm/gmmain.cpp |
+++ b/gm/gmmain.cpp |
@@ -247,11 +247,11 @@ public: |
/** |
* Assemble filename suitable for writing out an SkBitmap. |
*/ |
- SkString make_bitmap_filename(const char *path, |
- const char *shortName, |
- const char *configName, |
- const char *renderModeDescriptor, |
- const GmResultDigest &bitmapDigest) { |
+ SkString makeBitmapFilename(const char *path, |
+ const char *shortName, |
+ const char *configName, |
+ const char *renderModeDescriptor, |
+ const GmResultDigest &bitmapDigest) { |
if (fWriteChecksumBasedFilenames) { |
SkString filename; |
filename.append(bitmapDigest.getHashType()); |
@@ -296,7 +296,7 @@ public: |
} |
} |
- static ErrorCombination write_bitmap(const SkString& path, const SkBitmap& bitmap) { |
+ static ErrorCombination WriteBitmap(const SkString& path, const SkBitmap& bitmap) { |
// TODO(epoger): Now that we have removed force_all_opaque() |
// from this method, we should be able to get rid of the |
// transformation to 8888 format also. |
@@ -335,7 +335,7 @@ public: |
/** |
* Returns true if failures on this test should be ignored. |
*/ |
- bool ShouldIgnoreTest(const char *name) const { |
+ bool shouldIgnoreTest(const char *name) const { |
for (int i = 0; i < fIgnorableTestNames.count(); i++) { |
if (fIgnorableTestNames[i].equals(name)) { |
return true; |
@@ -843,10 +843,10 @@ public: |
// Write out the "actuals" for any tests without expectations, if we have |
// been directed to do so. |
if (fMissingExpectationsPath) { |
- SkString path = make_bitmap_filename(fMissingExpectationsPath, shortName, |
- configName, renderModeDescriptor, |
- actualBitmapAndDigest.fDigest); |
- write_bitmap(path, actualBitmapAndDigest.fBitmap); |
+ SkString path = this->makeBitmapFilename(fMissingExpectationsPath, shortName, |
+ configName, renderModeDescriptor, |
+ actualBitmapAndDigest.fDigest); |
+ WriteBitmap(path, actualBitmapAndDigest.fBitmap); |
} |
} else if (!expectations.match(actualBitmapAndDigest.fDigest)) { |
@@ -862,10 +862,10 @@ public: |
// Write out the "actuals" for any mismatches, if we have |
// been directed to do so. |
if (fMismatchPath) { |
- SkString path = make_bitmap_filename(fMismatchPath, shortName, configName, |
- renderModeDescriptor, |
- actualBitmapAndDigest.fDigest); |
- write_bitmap(path, actualBitmapAndDigest.fBitmap); |
+ SkString path = this->makeBitmapFilename(fMismatchPath, shortName, configName, |
+ renderModeDescriptor, |
+ actualBitmapAndDigest.fDigest); |
+ WriteBitmap(path, actualBitmapAndDigest.fBitmap); |
} |
// If we have access to a single expected bitmap, log more |
@@ -944,7 +944,7 @@ public: |
* @param actualBitmapAndDigest ptr to bitmap generated by this run, or NULL |
* if we don't have a usable bitmap representation |
*/ |
- ErrorCombination compare_test_results_to_stored_expectations( |
+ ErrorCombination compareTestResultsToStoredExpectations( |
GM* gm, const ConfigData& gRec, const char* configName, |
const BitmapAndDigest* actualBitmapAndDigest) { |
ErrorCombination errors; |
@@ -982,7 +982,7 @@ public: |
* See comments above complete_bitmap() for more detail. |
*/ |
Expectations expectations = expectationsSource->get(nameWithExtension.c_str()); |
- if (this->ShouldIgnoreTest(gm->getName())) { |
+ if (this->shouldIgnoreTest(gm->getName())) { |
expectations.setIgnoreFailure(true); |
} |
errors.add(compare_to_expectations(expectations, *actualBitmapAndDigest, |
@@ -1072,7 +1072,6 @@ public: |
SkBitmap* bitmap) { |
ErrorCombination errors; |
SkDynamicMemoryWStream document; |
- SkString path; |
if (gRec.fBackend == kRaster_Backend || |
gRec.fBackend == kGPU_Backend) { |
@@ -1084,22 +1083,15 @@ public: |
// trying to generate the image. |
return errors; |
} |
- BitmapAndDigest bitmapAndDigest(*bitmap); |
- errors.add(compare_test_results_to_stored_expectations( |
- gm, gRec, gRec.fName, &bitmapAndDigest)); |
- if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
- path = make_bitmap_filename(writePath, gm->getName(), gRec.fName, |
- "", bitmapAndDigest.fDigest); |
- errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); |
- } |
+ errors.add(this->writeBitmap(gm, gRec, gRec.fName, writePath, *bitmap)); |
} else if (gRec.fBackend == kPDF_Backend) { |
if (!generate_pdf(gm, document)) { |
errors.add(kGeneratePdfFailed_ErrorType); |
} else { |
SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream()); |
if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
- path = make_filename(writePath, gm->getName(), gRec.fName, "", "pdf"); |
+ SkString path = make_filename(writePath, gm->getName(), gRec.fName, "", "pdf"); |
errors.add(write_document(path, documentStream)); |
} |
@@ -1120,16 +1112,8 @@ public: |
configName.append("-"); |
configName.append(pdfRasterizers[i]->fName); |
- BitmapAndDigest bitmapAndDigest(pdfBitmap); |
- errors.add(compare_test_results_to_stored_expectations( |
- gm, gRec, configName.c_str(), &bitmapAndDigest)); |
- |
- if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
- path = make_bitmap_filename(writePath, gm->getName(), |
- configName.c_str(), |
- "", bitmapAndDigest.fDigest); |
- errors.add(write_bitmap(path, bitmapAndDigest.fBitmap)); |
- } |
+ errors.add(this->writeBitmap(gm, gRec, configName.c_str(), |
+ writePath, pdfBitmap)); |
} |
} else { |
errors.add(kIntentionallySkipped_ErrorType); |
@@ -1139,11 +1123,11 @@ public: |
generate_xps(gm, document); |
SkAutoTUnref<SkStreamAsset> documentStream(document.detachAsStream()); |
- errors.add(compare_test_results_to_stored_expectations( |
+ errors.add(this->compareTestResultsToStoredExpectations( |
gm, gRec, gRec.fName, NULL)); |
if (writePath && (gRec.fFlags & kWrite_ConfigFlag)) { |
- path = make_filename(writePath, gm->getName(), gRec.fName, "", "xps"); |
+ SkString path = make_filename(writePath, gm->getName(), gRec.fName, "", "xps"); |
errors.add(write_document(path, documentStream)); |
} |
} else { |
@@ -1206,8 +1190,31 @@ public: |
return NULL; |
} |
+ ErrorCombination writeBitmap(GM* gm, |
+ const ConfigData& config, |
+ const char* configName, |
+ const char* writePath, |
+ const SkBitmap& bitmap) { |
+ ErrorCombination errors; |
+ |
+ BitmapAndDigest bitmapAndDigest(bitmap); |
+ errors.add(this->compareTestResultsToStoredExpectations(gm, config, |
+ configName, &bitmapAndDigest)); |
+ |
+ if (writePath && (config.fFlags & kWrite_ConfigFlag)) { |
+ SkString path; |
+ |
+ path = this->makeBitmapFilename(writePath, gm->getName(), configName, |
+ "", bitmapAndDigest.fDigest); |
+ errors.add(WriteBitmap(path, bitmapAndDigest.fBitmap)); |
+ } |
+ |
+ return errors; |
+ } |
+ |
ErrorCombination testMPDDrawing(GM* gm, |
const ConfigData& config, |
+ const char* writePath, |
GrSurface* gpuTarget, |
const SkBitmap& referenceBitmap) { |
SkASSERT(kRaster_Backend == config.fBackend || kGPU_Backend == config.fBackend); |
@@ -1227,8 +1234,10 @@ public: |
surf->readPixels(bitmap.info(), bitmap.getPixels(), bitmap.rowBytes(), 0, 0); |
complete_bitmap(&bitmap); |
- return compare_test_results_to_reference_bitmap( |
- gm->getName(), config.fName, "-mpd", bitmap, &referenceBitmap); |
+ SkString configName(config.fName); |
+ configName.append("-mpd"); |
+ |
+ return this->writeBitmap(gm, config, configName.c_str(), writePath, bitmap); |
} |
ErrorCombination test_pipe_playback(GM* gm, const ConfigData& gRec, |
@@ -1898,7 +1907,8 @@ ErrorCombination run_multiple_configs(GMMain &gmmain, GM *gm, |
config.fBackend); |
errorsForThisConfig.add(kIntentionallySkipped_ErrorType); |
} else if (!(gmFlags & GM::kGPUOnly_Flag)) { |
- errorsForThisConfig.add(gmmain.testMPDDrawing(gm, config, gpuTarget, |
+ errorsForThisConfig.add(gmmain.testMPDDrawing(gm, config, |
+ writePath, gpuTarget, |
comparisonBitmap)); |
} |
} |