| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright 2013 Google Inc. | 2 * Copyright 2013 Google Inc. |
| 3 * | 3 * |
| 4 * Use of this source code is governed by a BSD-style license that can be | 4 * Use of this source code is governed by a BSD-style license that can be |
| 5 * found in the LICENSE file. | 5 * found in the LICENSE file. |
| 6 */ | 6 */ |
| 7 | 7 |
| 8 // TODO(djsollen): Rename this whole package (perhaps to "SkMultiDiffer"). |
| 9 // It's not just for "pdiff" (perceptual diffs)--it's a harness that allows |
| 10 // the execution of an arbitrary set of difference algorithms. |
| 11 // See http://skbug.com/2711 ('rename skpdiff') |
| 12 |
| 8 #if SK_SUPPORT_OPENCL | 13 #if SK_SUPPORT_OPENCL |
| 9 | 14 |
| 10 #define __NO_STD_VECTOR // Uses cl::vectpr instead of std::vectpr | 15 #define __NO_STD_VECTOR // Uses cl::vectpr instead of std::vectpr |
| 11 #define __NO_STD_STRING // Uses cl::STRING_CLASS instead of std::string | 16 #define __NO_STD_STRING // Uses cl::STRING_CLASS instead of std::string |
| 12 #if SK_BUILD_FOR_MAC | 17 #if SK_BUILD_FOR_MAC |
| 13 // Note that some macs don't have this header and it can be downloaded from the
Khronos registry | 18 // Note that some macs don't have this header and it can be downloaded from the
Khronos registry |
| 14 # include <OpenCL/cl.hpp> | 19 # include <OpenCL/cl.hpp> |
| 15 #else | 20 #else |
| 16 # include <CL/cl.hpp> | 21 # include <CL/cl.hpp> |
| 17 #endif | 22 #endif |
| (...skipping 12 matching lines...) Expand all Loading... |
| 30 #include "skpdiff_util.h" | 35 #include "skpdiff_util.h" |
| 31 | 36 |
| 32 #include "SkForceLinking.h" | 37 #include "SkForceLinking.h" |
| 33 __SK_FORCE_IMAGE_DECODER_LINKING; | 38 __SK_FORCE_IMAGE_DECODER_LINKING; |
| 34 | 39 |
| 35 // Command line argument definitions go here | 40 // Command line argument definitions go here |
| 36 DEFINE_bool2(list, l, false, "List out available differs"); | 41 DEFINE_bool2(list, l, false, "List out available differs"); |
| 37 DEFINE_string2(differs, d, "", "The names of the differs to use or all of them b
y default"); | 42 DEFINE_string2(differs, d, "", "The names of the differs to use or all of them b
y default"); |
| 38 DEFINE_string2(folders, f, "", "Compare two folders with identical subfile names
: <baseline folder> <test folder>"); | 43 DEFINE_string2(folders, f, "", "Compare two folders with identical subfile names
: <baseline folder> <test folder>"); |
| 39 DEFINE_string2(patterns, p, "", "Use two patterns to compare images: <baseline>
<test>"); | 44 DEFINE_string2(patterns, p, "", "Use two patterns to compare images: <baseline>
<test>"); |
| 40 DEFINE_string2(output, o, "", "Writes the output of these diffs to output: <outp
ut>"); | 45 DEFINE_string2(output, o, "", "Writes a JSON summary of these diffs to file: <fi
lepath>"); |
| 41 DEFINE_string(alphaDir, "", "Writes the alpha mask of these diffs to output: <ou
tput>"); | 46 DEFINE_string(alphaDir, "", "If the differ can generate an alpha mask, write it
into directory: <dirpath>"); |
| 47 DEFINE_string(rgbDiffDir, "", "If the differ can generate an image showing the R
GB diff at each pixel, write it into directory: <dirpath>"); |
| 48 DEFINE_string(whiteDiffDir, "", "If the differ can generate an image showing eve
ry changed pixel in white, write it into directory: <dirpath>"); |
| 42 DEFINE_bool(jsonp, true, "Output JSON with padding"); | 49 DEFINE_bool(jsonp, true, "Output JSON with padding"); |
| 43 DEFINE_string(csv, "", "Writes the output of these diffs to a csv file"); | 50 DEFINE_string(csv, "", "Writes the output of these diffs to a csv file: <filepat
h>"); |
| 44 DEFINE_int32(threads, -1, "run N threads in parallel [default is derived from CP
Us available]"); | 51 DEFINE_int32(threads, -1, "run N threads in parallel [default is derived from CP
Us available]"); |
| 45 | 52 |
| 46 #if SK_SUPPORT_OPENCL | 53 #if SK_SUPPORT_OPENCL |
| 47 /// A callback for any OpenCL errors | 54 /// A callback for any OpenCL errors |
| 48 static void CL_CALLBACK error_notify(const char* errorInfo, const void* privateI
nfoSize, ::size_t cb, void* userData) { | 55 static void CL_CALLBACK error_notify(const char* errorInfo, const void* privateI
nfoSize, ::size_t cb, void* userData) { |
| 49 SkDebugf("OpenCL error notify: %s\n", errorInfo); | 56 SkDebugf("OpenCL error notify: %s\n", errorInfo); |
| 50 exit(1); | 57 exit(1); |
| 51 } | 58 } |
| 52 | 59 |
| 53 /// Creates a device and context with OpenCL | 60 /// Creates a device and context with OpenCL |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 return 1; | 193 return 1; |
| 187 } | 194 } |
| 188 } | 195 } |
| 189 | 196 |
| 190 if (!FLAGS_alphaDir.isEmpty()) { | 197 if (!FLAGS_alphaDir.isEmpty()) { |
| 191 if (1 != FLAGS_alphaDir.count()) { | 198 if (1 != FLAGS_alphaDir.count()) { |
| 192 SkDebugf("alphaDir flag expects one argument: <directory>\n"); | 199 SkDebugf("alphaDir flag expects one argument: <directory>\n"); |
| 193 return 1; | 200 return 1; |
| 194 } | 201 } |
| 195 } | 202 } |
| 203 if (!FLAGS_rgbDiffDir.isEmpty()) { |
| 204 if (1 != FLAGS_rgbDiffDir.count()) { |
| 205 SkDebugf("rgbDiffDir flag expects one argument: <directory>\n"); |
| 206 return 1; |
| 207 } |
| 208 } |
| 209 if (!FLAGS_whiteDiffDir.isEmpty()) { |
| 210 if (1 != FLAGS_whiteDiffDir.count()) { |
| 211 SkDebugf("whiteDiffDir flag expects one argument: <directory>\n"); |
| 212 return 1; |
| 213 } |
| 214 } |
| 196 | 215 |
| 197 SkDiffContext ctx; | 216 SkDiffContext ctx; |
| 198 ctx.setDiffers(chosenDiffers); | 217 ctx.setDiffers(chosenDiffers); |
| 199 | 218 |
| 200 if (!FLAGS_alphaDir.isEmpty()) { | 219 if (!FLAGS_alphaDir.isEmpty()) { |
| 201 ctx.setDifferenceDir(SkString(FLAGS_alphaDir[0])); | 220 ctx.setAlphaMaskDir(SkString(FLAGS_alphaDir[0])); |
| 221 } |
| 222 if (!FLAGS_rgbDiffDir.isEmpty()) { |
| 223 ctx.setRgbDiffDir(SkString(FLAGS_rgbDiffDir[0])); |
| 224 } |
| 225 if (!FLAGS_whiteDiffDir.isEmpty()) { |
| 226 ctx.setWhiteDiffDir(SkString(FLAGS_whiteDiffDir[0])); |
| 202 } | 227 } |
| 203 | 228 |
| 204 if (FLAGS_threads >= 0) { | 229 if (FLAGS_threads >= 0) { |
| 205 ctx.setThreadCount(FLAGS_threads); | 230 ctx.setThreadCount(FLAGS_threads); |
| 206 } | 231 } |
| 207 | 232 |
| 208 // Perform a folder diff if one is requested | 233 // Perform a folder diff if one is requested |
| 209 if (!FLAGS_folders.isEmpty()) { | 234 if (!FLAGS_folders.isEmpty()) { |
| 210 ctx.diffDirectories(FLAGS_folders[0], FLAGS_folders[1]); | 235 ctx.diffDirectories(FLAGS_folders[0], FLAGS_folders[1]); |
| 211 } | 236 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 227 } | 252 } |
| 228 | 253 |
| 229 return 0; | 254 return 0; |
| 230 } | 255 } |
| 231 | 256 |
| 232 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) | 257 #if !defined(SK_BUILD_FOR_IOS) && !defined(SK_BUILD_FOR_NACL) |
| 233 int main(int argc, char * argv[]) { | 258 int main(int argc, char * argv[]) { |
| 234 return tool_main(argc, (char**) argv); | 259 return tool_main(argc, (char**) argv); |
| 235 } | 260 } |
| 236 #endif | 261 #endif |
| OLD | NEW |