Chromium Code Reviews| Index: tools/skpdiff/SkDiffContext.cpp |
| diff --git a/tools/skpdiff/SkDiffContext.cpp b/tools/skpdiff/SkDiffContext.cpp |
| index ea44c90da1e2efe22077bbc42c6b1d73a1353d34..8e193419a05c1c614bfab24c5d69db5bd46cf5f2 100644 |
| --- a/tools/skpdiff/SkDiffContext.cpp |
| +++ b/tools/skpdiff/SkDiffContext.cpp |
| @@ -18,6 +18,9 @@ |
| #include "SkImageDiffer.h" |
| #include "skpdiff_util.h" |
| +#include <string> |
| +#include <algorithm> |
| + |
| SkDiffContext::SkDiffContext() { |
| fDiffers = NULL; |
| fDifferCount = 0; |
| @@ -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,20 @@ static SkString get_common_prefix(const SkString& a, const SkString& b) { |
| } |
| } |
| +static SkString sanitize_name(const SkString& str) { |
| + std::string result = std::string(str.c_str()); |
| + std::replace(result.begin(), result.end(), '.', '_'); |
| + |
| + return SkString(result.c_str()); |
| +} |
| + |
| +static SkString get_combined_name(const SkString& a, const SkString& b) { |
| + SkString result = a; |
| + result.append("-vs-"); |
|
epoger
2014/08/11 19:33:28
Looking at _get_difference_locator() in imagediffd
stephana
2014/08/11 20:03:57
Yes, I just realized that it breaks the front-end
|
| + result.append(b); |
| + return sanitize_name(result); |
| +} |
|
stephana
2014/08/11 14:58:31
This uses the <string> and <algorithm> headers inc
epoger
2014/08/11 19:33:28
A fine question... in my experience, within the Sk
stephana
2014/08/11 20:03:57
Make sense, I'll consult with Mike about this.
O
|
| + |
| void SkDiffContext::addDiff(const char* baselinePath, const char* testPath) { |
| // Load the images at the paths |
| SkBitmap baselineBitmap; |
| @@ -100,7 +121,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; |