aboutsummaryrefslogtreecommitdiffhomepage
path: root/tools/skpdiff/SkDiffContext.cpp
diff options
context:
space:
mode:
authorGravatar stephana <stephana@google.com>2014-08-13 10:36:06 -0700
committerGravatar Commit bot <commit-bot@chromium.org>2014-08-13 10:36:06 -0700
commit21b342d19c71fa5abe7e4aa5cfb518fd04cb9d67 (patch)
tree1c9b42a2ae539b4bcd17ab11c42b2dfca0e77411 /tools/skpdiff/SkDiffContext.cpp
parent97a0d437718706b918f710fe9dfc2e7c0ba618a7 (diff)
This eliminates the need to copy the generated images from a temporary directory to the directory that is served by the rebaseline_server.
BUG=skia:2815, skia:2818 R=epoger@google.com Author: stephana@google.com Review URL: https://codereview.chromium.org/457203003
Diffstat (limited to 'tools/skpdiff/SkDiffContext.cpp')
-rw-r--r--tools/skpdiff/SkDiffContext.cpp25
1 files changed, 24 insertions, 1 deletions
diff --git a/tools/skpdiff/SkDiffContext.cpp b/tools/skpdiff/SkDiffContext.cpp
index ea44c90da1..42d20de19d 100644
--- a/tools/skpdiff/SkDiffContext.cpp
+++ b/tools/skpdiff/SkDiffContext.cpp
@@ -14,6 +14,9 @@
#include "SkTDict.h"
#include "SkThreadPool.h"
+// from the tools directory for replace_char(...)
+#include "picture_utils.h"
+
#include "SkDiffContext.h"
#include "SkImageDiffer.h"
#include "skpdiff_util.h"
@@ -48,6 +51,10 @@ void SkDiffContext::setWhiteDiffDir(const SkString& path) {
}
}
+void SkDiffContext::setLongNames(const bool useLongNames) {
+ longNames = useLongNames;
+}
+
void SkDiffContext::setDiffers(const SkTDArray<SkImageDiffer*>& differs) {
// Delete whatever the last array of differs was
if (NULL != fDiffers) {
@@ -79,6 +86,16 @@ static SkString get_common_prefix(const SkString& a, const SkString& b) {
}
}
+static SkString get_combined_name(const SkString& a, const SkString& b) {
+ // Note (stephana): We must keep this function in sync with
+ // getImageDiffRelativeUrl() in static/loader.js (under rebaseline_server).
+ SkString result = a;
+ result.append("-vs-");
+ result.append(b);
+ sk_tools::replace_char(&result, '.', '_');
+ return result;
+}
+
void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
// Load the images at the paths
SkBitmap baselineBitmap;
@@ -100,7 +117,13 @@ void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) {
// compute the common name
SkString baseName = SkOSPath::Basename(baselinePath);
SkString testName = SkOSPath::Basename(testPath);
- newRecord->fCommonName = get_common_prefix(baseName, testName);
+
+ if (longNames) {
+ newRecord->fCommonName = get_combined_name(baseName, testName);
+ } else {
+ newRecord->fCommonName = get_common_prefix(baseName, testName);
+ }
+ newRecord->fCommonName.append(".png");
newRecord->fBaselinePath = baselinePath;
newRecord->fTestPath = testPath;