Update skpdiff to include a name with each file.

R=caryclark@google.com

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

git-svn-id: http://skia.googlecode.com/svn/trunk@11808 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/skpdiff/SkDiffContext.cpp b/tools/skpdiff/SkDiffContext.cpp
index f551ff3..88941ca 100644
--- a/tools/skpdiff/SkDiffContext.cpp
+++ b/tools/skpdiff/SkDiffContext.cpp
@@ -167,6 +167,20 @@
             SkString baselineAbsPath = get_absolute_path(currentRecord->fBaselinePath);
             SkString testAbsPath = get_absolute_path(currentRecord->fTestPath);
 
+            // strip off directory structure and find the common part of the filename
+            SkString baseName = SkOSPath::SkBasename(baselineAbsPath.c_str());
+            SkString testName = SkOSPath::SkBasename(testAbsPath.c_str());
+            for (size_t x = 0; x < baseName.size(); ++x) {
+                if (baseName[x] != testName[x]) {
+                    baseName.insertUnichar(x, '\n');
+                    break;
+                }
+            }
+
+            stream.writeText("            \"commonName\": \"");
+            stream.writeText(baseName.c_str());
+            stream.writeText("\",\n");
+
             stream.writeText("            \"baselinePath\": \"");
             stream.writeText(baselineAbsPath.c_str());
             stream.writeText("\",\n");