GM: include filename extension (.png) of each output file in JSON summary

Doing this so that, once we *do* start writing PDF checksums into the JSON
summary, we'll be able to distinguish those from the PNG checksums.
Otherwise, we could have naming collisions.

R=scroggo@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@9119 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/gm/gmmain.cpp b/gm/gmmain.cpp
index 179ec84..cd9b84f 100644
--- a/gm/gmmain.cpp
+++ b/gm/gmmain.cpp
@@ -121,6 +121,11 @@
     const GMRegistry* fReg;
 };
 
+// TODO(epoger): Right now, various places in this code assume that all the
+// image files read/written by GM use this file extension.
+// Search for references to this constant to find these assumptions.
+const static char kPNG_FileExtension[] = "png";
+
 enum Backend {
     kRaster_Backend,
     kGPU_Backend,
@@ -607,7 +612,7 @@
             (gRec.fBackend == kPDF_Backend && CAN_IMAGE_PDF)) {
 
             path = make_filename(writePath, renderModeDescriptor, name.c_str(),
-                                 "png");
+                                 kPNG_FileExtension);
             success = write_bitmap(path, bitmap);
         }
         if (kPDF_Backend == gRec.fBackend) {
@@ -727,6 +732,8 @@
         }
         SkString completeNameString = baseNameString;
         completeNameString.append(renderModeDescriptor);
+        completeNameString.append(".");
+        completeNameString.append(kPNG_FileExtension);
         const char* completeName = completeNameString.c_str();
 
         if (expectations.empty()) {
@@ -746,7 +753,7 @@
             if (fMismatchPath) {
                 SkString path =
                     make_filename(fMismatchPath, renderModeDescriptor,
-                                  baseNameString.c_str(), "png");
+                                  baseNameString.c_str(), kPNG_FileExtension);
                 write_bitmap(path, actualBitmap);
             }
 
@@ -853,7 +860,10 @@
              * force_all_opaque().
              * See comments above complete_bitmap() for more detail.
              */
-            Expectations expectations = expectationsSource->get(name.c_str());
+            SkString nameWithExtension(name);
+            nameWithExtension.append(".");
+            nameWithExtension.append(kPNG_FileExtension);
+            Expectations expectations = expectationsSource->get(nameWithExtension.c_str());
             errors.add(compare_to_expectations(expectations, actualBitmap,
                                                name, "", true));
         } else {
@@ -865,7 +875,10 @@
             if (!SkBitmapHasher::ComputeDigest(actualBitmap, &actualBitmapHash)) {
                 actualBitmapHash = 0;
             }
-            add_actual_results_to_json_summary(name.c_str(), actualBitmapHash,
+            SkString nameWithExtension(name);
+            nameWithExtension.append(".");
+            nameWithExtension.append(kPNG_FileExtension);
+            add_actual_results_to_json_summary(nameWithExtension.c_str(), actualBitmapHash,
                                                ErrorCombination(kMissingExpectations_ErrorType),
                                                false);
             RecordTestResults(ErrorCombination(kMissingExpectations_ErrorType), name, "");