GM: stop recording all *_pdf.png results as "INVALID" on non-Mac platforms

BUG=https://code.google.com/p/skia/issues/detail?id=1352
R=edisonn@google.com

Review URL: https://codereview.chromium.org/17366003

git-svn-id: http://skia.googlecode.com/svn/trunk@9912 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 8c015e7..ab8053e 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -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));
-        } 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),
+
+        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 {
+            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,