Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(93)

Side by Side Diff: tools/skpdiff/skpdiff_main.cpp

Issue 19671002: migrate skpdiff to tools (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: i shake my fist at Visual Studio's default use of tabs Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « tools/skpdiff/generate_pmetric_tables.py ('k') | tools/skpdiff/skpdiff_util.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 #if SK_SUPPORT_OPENCL 8 #if SK_SUPPORT_OPENCL
9
9 #define __NO_STD_VECTOR // Uses cl::vectpr instead of std::vectpr 10 #define __NO_STD_VECTOR // Uses cl::vectpr instead of std::vectpr
10 #define __NO_STD_STRING // Uses cl::STRING_CLASS instead of std::string 11 #define __NO_STD_STRING // Uses cl::STRING_CLASS instead of std::string
11 #include <CL/cl.hpp> 12 #if SK_BUILD_FOR_MAC
13 // Note that some macs don't have this header and it can be downloaded from the Khronos registry
14 # include <OpenCL/cl.hpp>
15 #else
16 # include <CL/cl.hpp>
17 #endif
18
12 #endif 19 #endif
13 20
14 #include "SkCommandLineFlags.h" 21 #include "SkCommandLineFlags.h"
15 #include "SkGraphics.h" 22 #include "SkGraphics.h"
16 #include "SkStream.h" 23 #include "SkStream.h"
17 #include "SkTDArray.h" 24 #include "SkTDArray.h"
18 25
19 #include "SkDifferentPixelsMetric.h" 26 #include "SkDifferentPixelsMetric.h"
20 #include "SkDiffContext.h" 27 #include "SkDiffContext.h"
21 #include "SkImageDiffer.h" 28 #include "SkImageDiffer.h"
22 #include "SkPMetric.h" 29 #include "SkPMetric.h"
23 #include "skpdiff_util.h" 30 #include "skpdiff_util.h"
24 31
25 #include "SkForceLinking.h" 32 #include "SkForceLinking.h"
26 __SK_FORCE_IMAGE_DECODER_LINKING; 33 __SK_FORCE_IMAGE_DECODER_LINKING;
27 34
28 // Command line argument definitions go here 35 // Command line argument definitions go here
29 DEFINE_bool2(list, l, false, "List out available differs"); 36 DEFINE_bool2(list, l, false, "List out available differs");
30 DEFINE_string2(differs, d, "", "The names of the differs to use or all of them b y default"); 37 DEFINE_string2(differs, d, "", "The names of the differs to use or all of them b y default");
31 DEFINE_string2(folders, f, "", "Compare two folders with identical subfile names : <baseline folder> <test folder>"); 38 DEFINE_string2(folders, f, "", "Compare two folders with identical subfile names : <baseline folder> <test folder>");
32 DEFINE_string2(patterns, p, "", "Use two patterns to compare images: <baseline> <test>"); 39 DEFINE_string2(patterns, p, "", "Use two patterns to compare images: <baseline> <test>");
33 DEFINE_string2(output, o, "skpdiff_output.json", "Writes the output of these dif fs to output: <output>"); 40 DEFINE_string2(output, o, "skpdiff_output.json", "Writes the output of these dif fs to output: <output>");
34 DEFINE_bool(jsonp, true, "Output JSON with padding"); 41 DEFINE_bool(jsonp, true, "Output JSON with padding");
35 42
36 #if SK_SUPPORT_OPENCL 43 #if SK_SUPPORT_OPENCL
37 /// A callback for any OpenCL errors 44 /// A callback for any OpenCL errors
38 CL_CALLBACK void error_notify(const char* errorInfo, const void* privateInfoSize , ::size_t cb, void* userData) { 45 static void CL_CALLBACK error_notify(const char* errorInfo, const void* privateI nfoSize, ::size_t cb, void* userData) {
39 SkDebugf("OpenCL error notify: %s\n", errorInfo); 46 SkDebugf("OpenCL error notify: %s\n", errorInfo);
40 exit(1); 47 exit(1);
41 } 48 }
42 49
43 /// Creates a device and context with OpenCL 50 /// Creates a device and context with OpenCL
44 static bool init_device_and_context(cl::Device* device, cl::Context* context) { 51 static bool init_device_and_context(cl::Device* device, cl::Context* context) {
45 // Query for a platform 52 // Query for a platform
46 cl::vector<cl::Platform> platformList; 53 cl::vector<cl::Platform> platformList;
47 cl::Platform::get(&platformList); 54 cl::Platform::get(&platformList);
48 SkDebugf("The number of platforms is %u\n", platformList.size()); 55 SkDebugf("The number of platforms is %u\n", platformList.size());
49 56
50 // Print some information about the platform for debugging 57 // Print some information about the platform for debugging
51 cl::Platform& platform = platformList[0]; 58 cl::Platform& platform = platformList[0];
52 cl::STRING_CLASS platformName; 59 cl::STRING_CLASS platformName;
53 platform.getInfo(CL_PLATFORM_NAME, &platformName); 60 platform.getInfo(CL_PLATFORM_NAME, &platformName);
54 SkDebugf("Platform index 0 is named %s\n", platformName.c_str()); 61 SkDebugf("Platform index 0 is named %s\n", platformName.c_str());
55 62
56 // Query for a device 63 // Query for a device
57 cl::vector<cl::Device> deviceList; 64 cl::vector<cl::Device> deviceList;
58 platform.getDevices(CL_DEVICE_TYPE_GPU, &deviceList); 65 platform.getDevices(CL_DEVICE_TYPE_ALL, &deviceList);
59 SkDebugf("The number of GPU devices is %u\n", deviceList.size()); 66 SkDebugf("The number of devices is %u\n", deviceList.size());
60 67
61 // Print some information about the device for debugging 68 // Print some information about the device for debugging
62 *device = deviceList[0]; 69 *device = deviceList[0];
63 cl::STRING_CLASS deviceName; 70 cl::STRING_CLASS deviceName;
64 device->getInfo(CL_DEVICE_NAME, &deviceName); 71 device->getInfo(CL_DEVICE_NAME, &deviceName);
65 SkDebugf("Device index 0 is named %s\n", deviceName.c_str()); 72 SkDebugf("Device index 0 is named %s\n", deviceName.c_str());
66 73
67 // Create a CL context and check for all errors 74 // Create a CL context and check for all errors
68 cl_int contextErr = CL_SUCCESS; 75 cl_int contextErr = CL_SUCCESS;
69 *context = cl::Context(deviceList, NULL, error_notify, NULL, &contextErr); 76 *context = cl::Context(deviceList, NULL, error_notify, NULL, &contextErr);
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 } 190 }
184 191
185 // Output to the file specified 192 // Output to the file specified
186 if (!FLAGS_output.isEmpty()) { 193 if (!FLAGS_output.isEmpty()) {
187 SkFILEWStream outputStream(FLAGS_output[0]); 194 SkFILEWStream outputStream(FLAGS_output[0]);
188 ctx.outputRecords(outputStream, FLAGS_jsonp); 195 ctx.outputRecords(outputStream, FLAGS_jsonp);
189 } 196 }
190 197
191 return 0; 198 return 0;
192 } 199 }
OLDNEW
« no previous file with comments | « tools/skpdiff/generate_pmetric_tables.py ('k') | tools/skpdiff/skpdiff_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698