diff options
author | stephana <stephana@google.com> | 2014-08-13 10:36:06 -0700 |
---|---|---|
committer | Commit bot <commit-bot@chromium.org> | 2014-08-13 10:36:06 -0700 |
commit | 21b342d19c71fa5abe7e4aa5cfb518fd04cb9d67 (patch) | |
tree | 1c9b42a2ae539b4bcd17ab11c42b2dfca0e77411 /tools | |
parent | 97a0d437718706b918f710fe9dfc2e7c0ba618a7 (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')
-rw-r--r-- | tools/skpdiff/SkDiffContext.cpp | 25 | ||||
-rw-r--r-- | tools/skpdiff/SkDiffContext.h | 25 | ||||
-rw-r--r-- | tools/skpdiff/skpdiff_main.cpp | 3 |
3 files changed, 50 insertions, 3 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; diff --git a/tools/skpdiff/SkDiffContext.h b/tools/skpdiff/SkDiffContext.h index 996737f2ee..8f4789fea6 100644 --- a/tools/skpdiff/SkDiffContext.h +++ b/tools/skpdiff/SkDiffContext.h @@ -52,6 +52,25 @@ public: void setWhiteDiffDir(const SkString& directory); /** + * Modify the pattern used to generate commonName (= the + * basename of rgb/white diff files). + * + * - true: basename is a combination of the input file names. + * - false: basename is the common prefix of the input file names. + * + * For example, for: + * baselinePath=/tmp/dir/image-before.png + * testPath=/tmp/dir/image-after.png + * + * If setLongNames(true), commonName would be: + * image-before-png-vs-image-after-png.png + * + * If setLongNames(false), commonName would be: + * image-.png + */ + void setLongNames(const bool useLongNames); + + /** * Sets the differs to be used in each diff. Already started diffs will not retroactively use * these. * @param differs An array of differs to use. The array is copied, but not the differs @@ -85,8 +104,9 @@ public: * * The format of the JSON document is one top level array named "records". * Each record in the array is an object with the following values: - * "commonName" : string containing the common prefix of the baselinePath - * and testPath filenames + * "commonName" : string containing the output filename (basename) + * depending on the value of 'longNames'. + * (see 'setLongNames' for an explanation and example). * "baselinePath" : string containing the path to the baseline image * "testPath" : string containing the path to the test image * "differencePath" : (optional) string containing the path to an alpha @@ -177,6 +197,7 @@ private: SkString fAlphaMaskDir; SkString fRgbDiffDir; SkString fWhiteDiffDir; + bool longNames; }; #endif diff --git a/tools/skpdiff/skpdiff_main.cpp b/tools/skpdiff/skpdiff_main.cpp index 3d1bcda0f4..6c40552d33 100644 --- a/tools/skpdiff/skpdiff_main.cpp +++ b/tools/skpdiff/skpdiff_main.cpp @@ -49,6 +49,7 @@ DEFINE_string(whiteDiffDir, "", "If the differ can generate an image showing eve DEFINE_bool(jsonp, true, "Output JSON with padding"); DEFINE_string(csv, "", "Writes the output of these diffs to a csv file: <filepath>"); DEFINE_int32(threads, -1, "run N threads in parallel [default is derived from CPUs available]"); +DEFINE_bool(longnames, false, "Output image names are a combination of baseline and test names"); #if SK_SUPPORT_OPENCL /// A callback for any OpenCL errors @@ -206,6 +207,7 @@ int tool_main(int argc, char * argv[]) { return 1; } } + if (!FLAGS_whiteDiffDir.isEmpty()) { if (1 != FLAGS_whiteDiffDir.count()) { SkDebugf("whiteDiffDir flag expects one argument: <directory>\n"); @@ -215,6 +217,7 @@ int tool_main(int argc, char * argv[]) { SkDiffContext ctx; ctx.setDiffers(chosenDiffers); + ctx.setLongNames(FLAGS_longnames); if (!FLAGS_alphaDir.isEmpty()) { ctx.setAlphaMaskDir(SkString(FLAGS_alphaDir[0])); |