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");
diff --git a/tools/skpdiff/viewer.html b/tools/skpdiff/viewer.html
index f4b8fd7..1d3793b 100644
--- a/tools/skpdiff/viewer.html
+++ b/tools/skpdiff/viewer.html
@@ -33,6 +33,7 @@
           <thead>
             <tr>
               <td ng-show="isDynamic">Rebaseline?</td>
+              <td>Name</td>
               <td>Expected Image</td>
               <td>Actual Image</td>
               <td>Results</td>
@@ -51,6 +52,7 @@
                        ng-click="selectedRebaseline($index, $event)"
                        ng-class="{lastselected: lastSelectedIndex == $index}" />
               </td>
+              <td class="common-name">{{ record.commonName }}</td>
               <td>
                 <swap-img left-src="{{ record.baselinePath }}"
                           right-src="{{ record.testPath }}"
diff --git a/tools/skpdiff/viewer_style.css b/tools/skpdiff/viewer_style.css
index e172667..1e4420f 100644
--- a/tools/skpdiff/viewer_style.css
+++ b/tools/skpdiff/viewer_style.css
@@ -5,7 +5,7 @@
 }
 
 table {
-    width:100%;
+    width: auto;
     border-collapse: collapse;
     border-spacing: 0;
     padding: 8px;
@@ -13,7 +13,7 @@
 
 td {
     border-top: 1px solid #DDD;
-    padding: 8px;
+    padding: 16px;
 }
 thead > tr > td {
     border: none;
@@ -73,6 +73,11 @@
     background: -webkit-linear-gradient(top, #96c56f 0%,#a9db80 100%);
 }
 
+.common-name {
+    vertical-align: top;
+}
+
+
 .gm-image {
     border: 1px dotted black;
 }