Make gm tool able to read and write image files in the same run
BUG=http://code.google.com/p/skia/issues/detail?id=571
Review URL: https://codereview.appspot.com/6052050
git-svn-id: http://skia.googlecode.com/svn/trunk@3717 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 31e8074..7d47bbe 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -462,23 +462,25 @@
SkDynamicMemoryWStream* pdf,
const SkBitmap* comparisonBitmap) {
SkString name = make_name(gm->shortName(), gRec.fName);
+ ErrorBitfield retval = ERROR_NONE;
- if (writePath) {
- return write_reference_image(gRec, writePath, renderModeDescriptor,
- name, bitmap, pdf);
- } else if (readPath && (
+ if (readPath && (
gRec.fBackend == kRaster_Backend ||
gRec.fBackend == kGPU_Backend ||
(gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF))) {
- return compare_to_reference_image(readPath, name, bitmap,
- diffPath, renderModeDescriptor);
- } else if (comparisonBitmap) {
- return compare_to_reference_image(name, bitmap,
- *comparisonBitmap, diffPath,
- renderModeDescriptor);
- } else {
- return ERROR_NONE;
+ retval |= compare_to_reference_image(readPath, name, bitmap,
+ diffPath, renderModeDescriptor);
}
+ if (writePath) {
+ retval |= write_reference_image(gRec, writePath, renderModeDescriptor,
+ name, bitmap, pdf);
+ }
+ if (comparisonBitmap) {
+ retval |= compare_to_reference_image(name, bitmap,
+ *comparisonBitmap, diffPath,
+ renderModeDescriptor);
+ }
+ return retval;
}
static SkPicture* generate_new_picture(GM* gm) {
@@ -816,7 +818,8 @@
if (readPath) {
fprintf(stderr, "reading from %s\n", readPath);
- } else if (writePath) {
+ }
+ if (writePath) {
fprintf(stderr, "writing to %s\n", writePath);
}