blob: 579830d63993b119670d81ea687eba40e5a928eb [file] [log] [blame]
reed@google.com006db0f2012-06-27 19:33:29 +00001/*
2 * Copyright 2012 Google Inc.
3 *
4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file.
6 */
7
8#include "BenchTimer.h"
scroggo@google.com4a26d9d2012-11-07 18:01:46 +00009#include "CopyTilesRenderer.h"
keyar@chromium.org163b5672012-08-01 17:53:29 +000010#include "PictureBenchmark.h"
scroggo@google.com9a412522012-09-07 15:21:18 +000011#include "SkBenchLogger.h"
reed@google.com006db0f2012-06-27 19:33:29 +000012#include "SkCanvas.h"
scroggo@google.com0a36f432012-09-10 20:29:13 +000013#include "SkGraphics.h"
scroggo@google.com5a7c6be2012-10-04 21:46:08 +000014#include "SkImageDecoder.h"
keyar@chromium.orgf4959ab2012-08-23 20:53:25 +000015#include "SkMath.h"
reed@google.com006db0f2012-06-27 19:33:29 +000016#include "SkOSFile.h"
17#include "SkPicture.h"
18#include "SkStream.h"
19#include "SkTArray.h"
20#include "picture_utils.h"
21
borenet@google.com13fd5a12012-09-17 21:10:05 +000022const int DEFAULT_REPEATS = 1;
reed@google.com006db0f2012-06-27 19:33:29 +000023
caryclark@google.coma3622372012-11-06 21:26:13 +000024static char const * const gFilterTypes[] = {
25 "paint",
26 "point",
27 "line",
28 "bitmap",
29 "rect",
jvanverth@google.comd3c208c2013-01-22 13:54:52 +000030 "oval",
caryclark@google.coma3622372012-11-06 21:26:13 +000031 "path",
32 "text",
33 "all",
34};
35
36static const size_t kFilterTypesCount = sizeof(gFilterTypes) / sizeof(gFilterTypes[0]);
37
38static char const * const gFilterFlags[] = {
39 "antiAlias",
40 "filterBitmap",
41 "dither",
42 "underlineText",
43 "strikeThruText",
44 "fakeBoldText",
45 "linearText",
46 "subpixelText",
47 "devKernText",
48 "LCDRenderText",
49 "embeddedBitmapText",
50 "autoHinting",
51 "verticalText",
52 "genA8FromLCD",
53 "blur",
54 "hinting",
55 "slightHinting",
caryclark@google.come3e940c2012-11-07 16:42:17 +000056 "AAClip",
caryclark@google.coma3622372012-11-06 21:26:13 +000057};
58
59static const size_t kFilterFlagsCount = sizeof(gFilterFlags) / sizeof(gFilterFlags[0]);
60
61static SkString filtersName(sk_tools::PictureRenderer::DrawFilterFlags* drawFilters) {
62 int all = drawFilters[0];
63 size_t tIndex;
64 for (tIndex = 1; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
65 all &= drawFilters[tIndex];
66 }
67 SkString result;
68 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
69 SkString types;
70 if (all & (1 << fIndex)) {
71 types = gFilterTypes[SkDrawFilter::kTypeCount];
72 } else {
73 for (tIndex = 0; tIndex < SkDrawFilter::kTypeCount; ++tIndex) {
74 if (drawFilters[tIndex] & (1 << fIndex)) {
75 types += gFilterTypes[tIndex];
76 }
77 }
78 }
79 if (!types.size()) {
80 continue;
81 }
82 result += "_";
83 result += types;
84 result += ".";
85 result += gFilterFlags[fIndex];
86 }
87 return result;
88}
89
90static SkString filterTypesUsage() {
91 SkString result;
92 for (size_t index = 0; index < kFilterTypesCount; ++index) {
93 result += gFilterTypes[index];
94 if (index < kFilterTypesCount - 1) {
95 result += " | ";
96 }
97 }
98 return result;
99}
100
101static SkString filterFlagsUsage() {
102 SkString result;
103 size_t len = 0;
104 for (size_t index = 0; index < kFilterFlagsCount; ++index) {
105 result += gFilterFlags[index];
106 if (result.size() - len >= 72) {
107 result += "\n ";
108 len = result.size();
109 }
110 if (index < kFilterFlagsCount - 1) {
111 result += " | ";
112 }
113 }
114 return result;
115}
116
reed@google.com006db0f2012-06-27 19:33:29 +0000117static void usage(const char* argv0) {
118 SkDebugf("SkPicture benchmarking tool\n");
119 SkDebugf("\n"
120"Usage: \n"
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000121" %s <inputDir>...\n"
scroggo@google.com5239c322012-09-11 19:15:32 +0000122" [--logFile filename][--timers [wcgWC]*][--logPerIter 1|0][--min]\n"
scroggo@google.comcbcef702012-12-13 22:09:28 +0000123" [--repeat][--timeIndividualTiles] \n"
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000124" [--mode pow2tile minWidth height | record | simple\n"
125" | tile width height | playbackCreation]\n"
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000126" [--pipe]\n"
junov@chromium.org9313ca42012-11-02 18:11:49 +0000127" [--bbh bbhType]\n"
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000128" [--multi numThreads]\n"
scroggo@google.com82ec0b02012-12-17 19:25:54 +0000129" [--viewport width height][--scale sf]\n"
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000130" [--device bitmap"
131#if SK_SUPPORT_GPU
132" | gpu"
scroggo@google.com0556ea02013-02-08 19:38:21 +0000133#if SK_ANGLE
134" | angle"
135#endif
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000136#endif
caryclark@google.coma3622372012-11-06 21:26:13 +0000137"]\n"
138" [--filter [%s]:\n [%s]]\n"
139, argv0, filterTypesUsage().c_str(), filterFlagsUsage().c_str());
140 SkDebugf("\n");
reed@google.com006db0f2012-06-27 19:33:29 +0000141 SkDebugf(
keyar@chromium.org795cd472012-08-02 18:57:53 +0000142" inputDir: A list of directories and files to use as input. Files are\n"
scroggo@google.com9a412522012-09-07 15:21:18 +0000143" expected to have the .skp extension.\n\n"
144" --logFile filename : destination for writing log output, in addition to stdout.\n");
scroggo@google.com5239c322012-09-11 19:15:32 +0000145 SkDebugf(" --logPerIter 1|0 : "
146 "Log each repeat timer instead of mean, default is disabled.\n");
147 SkDebugf(" --min : Print the minimum times (instead of average).\n");
148 SkDebugf(" --timers [wcgWC]* : "
149 "Display wall, cpu, gpu, truncated wall or truncated cpu time for each picture.\n");
scroggo@google.comcbcef702012-12-13 22:09:28 +0000150 SkDebugf(" --timeIndividualTiles : Report times for drawing individual tiles, rather than\n"
151" times for drawing the whole page.\n"
152" Requires --mode tile\n");
reed@google.com006db0f2012-06-27 19:33:29 +0000153 SkDebugf(
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000154" --mode pow2tile minWidth height | copyTile width height | record | simple\n"
155" | tile width height | playbackCreation:\n"
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000156" Run in the corresponding mode.\n"
157" Default is simple.\n");
keyar@chromium.orgcf6c44c2012-07-09 19:37:40 +0000158 SkDebugf(
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000159" pow2tile minWidth height, Creates tiles with widths\n"
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000160" that are all a power of two\n"
161" such that they minimize the\n"
162" amount of wasted tile space.\n"
163" minWidth is the minimum width\n"
164" of these tiles and must be a\n"
165" power of two. Simple\n"
166" rendering using these tiles\n"
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000167" is benchmarked.\n");
keyar@chromium.orgf4959ab2012-08-23 20:53:25 +0000168 SkDebugf(
keyar@chromium.org795cd472012-08-02 18:57:53 +0000169" record, Benchmark picture to picture recording.\n");
170 SkDebugf(
171" simple, Benchmark a simple rendering.\n");
172 SkDebugf(
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000173" tile width height, Benchmark simple rendering using\n"
174" tiles with the given dimensions.\n"
175" copyTile width height, Draw the picture, then copy it into tiles.\n"
176" Does not support percentages.\n"
177" If the picture is large enough, breaks it into\n"
178" larger tiles (and draws the picture once per\n"
179" larger tile) to avoid creating a large canvas.\n"
180" Add --tiles x y to specify the number of tiles\n"
181" per larger tile in the x and y direction.\n"
182 );
keyar@chromium.org795cd472012-08-02 18:57:53 +0000183 SkDebugf(
scroggo@google.com9a412522012-09-07 15:21:18 +0000184" playbackCreation, Benchmark creation of the SkPicturePlayback.\n");
keyar@chromium.org795cd472012-08-02 18:57:53 +0000185 SkDebugf("\n");
186 SkDebugf(
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000187" --multi numThreads : Set the number of threads for multi threaded drawing. Must be greater\n"
188" than 1. Only works with tiled rendering.\n"
scroggo@google.comc0d5e542012-12-13 21:40:48 +0000189" --viewport width height : Set the viewport.\n"
scroggo@google.com82ec0b02012-12-17 19:25:54 +0000190" --scale sf : Scale drawing by sf.\n"
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000191" --pipe: Benchmark SkGPipe rendering. Currently incompatible with \"mode\".\n");
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000192 SkDebugf(
junov@chromium.org7b537062012-11-06 18:58:43 +0000193" --bbh bbhType [width height]: Set the bounding box hierarchy type to\n"
194" be used. Accepted values are: none, rtree, grid. Default\n"
195" value is none. Not compatible with --pipe. With value\n"
196" 'grid', width and height must be specified. 'grid' can\n"
197" only be used with modes tile, record, and\n"
198" playbackCreation.");
junov@chromium.org9313ca42012-11-02 18:11:49 +0000199 SkDebugf(
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000200" --device bitmap"
201#if SK_SUPPORT_GPU
202" | gpu"
203#endif
204": Use the corresponding device. Default is bitmap.\n");
205 SkDebugf(
206" bitmap, Render to a bitmap.\n");
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000207#if SK_SUPPORT_GPU
keyar@chromium.orga40c20d2012-08-20 15:04:12 +0000208 SkDebugf(
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000209" gpu, Render to the GPU.\n");
scroggo@google.com0556ea02013-02-08 19:38:21 +0000210#if SK_ANGLE
211 SkDebugf(
212" angle, Render using Angle.\n");
213#endif
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000214#endif
215 SkDebugf("\n");
216 SkDebugf(
keyar@chromium.org795cd472012-08-02 18:57:53 +0000217" --repeat: "
reed@google.com006db0f2012-06-27 19:33:29 +0000218"Set the number of times to repeat each test."
219" Default is %i.\n", DEFAULT_REPEATS);
caryclark@google.coma3622372012-11-06 21:26:13 +0000220 SkDebugf(
caryclark@google.come3e940c2012-11-07 16:42:17 +0000221" --filter type:flag : Enable canvas filtering to disable a paint flag,\n"
222" use no blur or low quality blur, or use no hinting or\n"
223" slight hinting. For all flags except AAClip, specify the\n"
224" type of primitive to effect, or choose all. for AAClip\n"
225" alone, the filter affects all clips independent of type.\n");
reed@google.com006db0f2012-06-27 19:33:29 +0000226}
227
scroggo@google.com9a412522012-09-07 15:21:18 +0000228SkBenchLogger gLogger;
229
borenet@google.com66bcbd12012-09-17 18:26:06 +0000230static bool run_single_benchmark(const SkString& inputPath,
keyar@chromium.org163b5672012-08-01 17:53:29 +0000231 sk_tools::PictureBenchmark& benchmark) {
reed@google.com006db0f2012-06-27 19:33:29 +0000232 SkFILEStream inputStream;
233
reed@google.com006db0f2012-06-27 19:33:29 +0000234 inputStream.setPath(inputPath.c_str());
235 if (!inputStream.isValid()) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000236 SkString err;
237 err.printf("Could not open file %s\n", inputPath.c_str());
238 gLogger.logError(err);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000239 return false;
reed@google.com006db0f2012-06-27 19:33:29 +0000240 }
241
borenet@google.com66bcbd12012-09-17 18:26:06 +0000242 bool success = false;
scroggo@google.com5a7c6be2012-10-04 21:46:08 +0000243 SkPicture picture(&inputStream, &success, &SkImageDecoder::DecodeStream);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000244 if (!success) {
245 SkString err;
246 err.printf("Could not read an SkPicture from %s\n", inputPath.c_str());
247 gLogger.logError(err);
248 return false;
249 }
reed@google.com006db0f2012-06-27 19:33:29 +0000250
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000251 SkString filename;
252 sk_tools::get_basename(&filename, inputPath);
keyar@chromium.orgdb9a5fb2012-08-21 17:57:59 +0000253
254 SkString result;
borenet@google.com2d2b9a02012-09-20 18:54:04 +0000255 result.printf("running bench [%i %i] %s ", picture.width(),
256 picture.height(), filename.c_str());
scroggo@google.com9a412522012-09-07 15:21:18 +0000257 gLogger.logProgress(result);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000258
borenet@google.com2d2b9a02012-09-20 18:54:04 +0000259 benchmark.run(&picture);
borenet@google.com66bcbd12012-09-17 18:26:06 +0000260 return true;
keyar@chromium.org0665f252012-07-10 18:30:18 +0000261}
262
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000263#define PRINT_USAGE_AND_EXIT \
264 do { \
265 usage(argv0); \
266 exit(-1); \
267 } while (0)
268
keyar@chromium.org163b5672012-08-01 17:53:29 +0000269static void parse_commandline(int argc, char* const argv[], SkTArray<SkString>* inputs,
scroggo@google.com5239c322012-09-11 19:15:32 +0000270 sk_tools::PictureBenchmark* benchmark) {
reed@google.com006db0f2012-06-27 19:33:29 +0000271 const char* argv0 = argv[0];
272 char* const* stop = argv + argc;
273
keyar@chromium.org163b5672012-08-01 17:53:29 +0000274 int repeats = DEFAULT_REPEATS;
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000275 sk_tools::PictureRenderer::SkDeviceTypes deviceType =
276 sk_tools::PictureRenderer::kBitmap_DeviceType;
keyar@chromium.org163b5672012-08-01 17:53:29 +0000277
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000278 SkAutoTUnref<sk_tools::PictureRenderer> renderer(NULL);
scroggo@google.com5239c322012-09-11 19:15:32 +0000279
scroggo@google.com9a412522012-09-07 15:21:18 +0000280 // Create a string to show our current settings.
281 // TODO: Make it prettier. Currently it just repeats the command line.
282 SkString commandLine("bench_pictures:");
283 for (int i = 1; i < argc; i++) {
284 commandLine.appendf(" %s", *(argv+i));
285 }
286 commandLine.append("\n");
287
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000288 bool usePipe = false;
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000289 int numThreads = 1;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000290 bool useTiles = false;
291 const char* widthString = NULL;
292 const char* heightString = NULL;
junov@chromium.org7b537062012-11-06 18:58:43 +0000293 int gridWidth = 0;
294 int gridHeight = 0;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000295 bool isPowerOf2Mode = false;
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000296 bool isCopyMode = false;
297 const char* xTilesString = NULL;
298 const char* yTilesString = NULL;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000299 const char* mode = NULL;
junov@chromium.org7b537062012-11-06 18:58:43 +0000300 bool gridSupported = false;
skia.committer@gmail.com1aa90cf2012-11-06 13:18:25 +0000301 sk_tools::PictureRenderer::BBoxHierarchyType bbhType =
junov@chromium.org9313ca42012-11-02 18:11:49 +0000302 sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
caryclark@google.coma3622372012-11-06 21:26:13 +0000303 sk_tools::PictureRenderer::DrawFilterFlags drawFilters[SkDrawFilter::kTypeCount];
304 sk_bzero(drawFilters, sizeof(drawFilters));
scroggo@google.comc0d5e542012-12-13 21:40:48 +0000305 SkISize viewport;
306 viewport.setEmpty();
scroggo@google.com82ec0b02012-12-17 19:25:54 +0000307 SkScalar scaleFactor = SK_Scalar1;
reed@google.com006db0f2012-06-27 19:33:29 +0000308 for (++argv; argv < stop; ++argv) {
309 if (0 == strcmp(*argv, "--repeat")) {
310 ++argv;
311 if (argv < stop) {
keyar@chromium.org163b5672012-08-01 17:53:29 +0000312 repeats = atoi(*argv);
313 if (repeats < 1) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000314 gLogger.logError("--repeat must be given a value > 0\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000315 PRINT_USAGE_AND_EXIT;
reed@google.com006db0f2012-06-27 19:33:29 +0000316 }
317 } else {
scroggo@google.com9a412522012-09-07 15:21:18 +0000318 gLogger.logError("Missing arg for --repeat\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000319 PRINT_USAGE_AND_EXIT;
reed@google.com006db0f2012-06-27 19:33:29 +0000320 }
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000321 } else if (0 == strcmp(*argv, "--pipe")) {
322 usePipe = true;
scroggo@google.com9a412522012-09-07 15:21:18 +0000323 } else if (0 == strcmp(*argv, "--logFile")) {
324 argv++;
325 if (argv < stop) {
326 if (!gLogger.SetLogFile(*argv)) {
327 SkString str;
328 str.printf("Could not open %s for writing.", *argv);
329 gLogger.logError(str);
330 usage(argv0);
borenet@google.coma49bffd2012-09-13 18:54:48 +0000331 // TODO(borenet): We're disabling this for now, due to
332 // write-protected Android devices. The very short-term
333 // solution is to ignore the fact that we have no log file.
334 //exit(-1);
scroggo@google.com9a412522012-09-07 15:21:18 +0000335 }
336 } else {
337 gLogger.logError("Missing arg for --logFile\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000338 PRINT_USAGE_AND_EXIT;
scroggo@google.com9a412522012-09-07 15:21:18 +0000339 }
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000340 } else if (0 == strcmp(*argv, "--multi")) {
341 ++argv;
342 if (argv >= stop) {
343 gLogger.logError("Missing arg for --multi\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000344 PRINT_USAGE_AND_EXIT;
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000345 }
346 numThreads = atoi(*argv);
347 if (numThreads < 2) {
348 gLogger.logError("Number of threads must be at least 2.\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000349 PRINT_USAGE_AND_EXIT;
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000350 }
junov@chromium.org9313ca42012-11-02 18:11:49 +0000351 } else if (0 == strcmp(*argv, "--bbh")) {
352 ++argv;
353 if (argv >= stop) {
354 gLogger.logError("Missing value for --bbh\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000355 PRINT_USAGE_AND_EXIT;
junov@chromium.org9313ca42012-11-02 18:11:49 +0000356 }
357 if (0 == strcmp(*argv, "none")) {
358 bbhType = sk_tools::PictureRenderer::kNone_BBoxHierarchyType;
359 } else if (0 == strcmp(*argv, "rtree")) {
360 bbhType = sk_tools::PictureRenderer::kRTree_BBoxHierarchyType;
junov@chromium.org7b537062012-11-06 18:58:43 +0000361 } else if (0 == strcmp(*argv, "grid")) {
362 bbhType = sk_tools::PictureRenderer::kTileGrid_BBoxHierarchyType;
363 ++argv;
364 if (argv >= stop) {
365 gLogger.logError("Missing width for --bbh grid\n");
366 PRINT_USAGE_AND_EXIT;
367 }
368 gridWidth = atoi(*argv);
369 ++argv;
370 if (argv >= stop) {
371 gLogger.logError("Missing height for --bbh grid\n");
372 PRINT_USAGE_AND_EXIT;
373 }
374 gridHeight = atoi(*argv);
junov@chromium.org9313ca42012-11-02 18:11:49 +0000375 } else {
376 SkString err;
377 err.printf("%s is not a valid value for --bbhType\n", *argv);
378 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000379 PRINT_USAGE_AND_EXIT;
junov@chromium.org9313ca42012-11-02 18:11:49 +0000380 }
381
keyar@chromium.org795cd472012-08-02 18:57:53 +0000382 } else if (0 == strcmp(*argv, "--mode")) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000383 if (renderer.get() != NULL) {
384 SkDebugf("Cannot combine modes.\n");
385 PRINT_USAGE_AND_EXIT;
386 }
keyar@chromium.org795cd472012-08-02 18:57:53 +0000387
reed@google.com006db0f2012-06-27 19:33:29 +0000388 ++argv;
keyar@chromium.org795cd472012-08-02 18:57:53 +0000389 if (argv >= stop) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000390 gLogger.logError("Missing mode for --mode\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000391 PRINT_USAGE_AND_EXIT;
keyar@chromium.org795cd472012-08-02 18:57:53 +0000392 }
393
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000394 if (0 == strcmp(*argv, "record")) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000395 renderer.reset(SkNEW(sk_tools::RecordPictureRenderer));
junov@chromium.org7b537062012-11-06 18:58:43 +0000396 gridSupported = true;
reed@google.com5a34fd32012-12-10 16:05:09 +0000397 } else if (0 == strcmp(*argv, "clone")) {
398 renderer.reset(sk_tools::CreatePictureCloneRenderer());
keyar@chromium.org795cd472012-08-02 18:57:53 +0000399 } else if (0 == strcmp(*argv, "simple")) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000400 renderer.reset(SkNEW(sk_tools::SimplePictureRenderer));
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000401 } else if ((0 == strcmp(*argv, "tile")) || (0 == strcmp(*argv, "pow2tile"))
402 || 0 == strcmp(*argv, "copyTile")) {
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000403 useTiles = true;
404 mode = *argv;
keyar@chromium.orgf4959ab2012-08-23 20:53:25 +0000405
406 if (0 == strcmp(*argv, "pow2tile")) {
407 isPowerOf2Mode = true;
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000408 } else if (0 == strcmp(*argv, "copyTile")) {
409 isCopyMode = true;
junov@chromium.org7b537062012-11-06 18:58:43 +0000410 } else {
411 gridSupported = true;
keyar@chromium.orgf4959ab2012-08-23 20:53:25 +0000412 }
413
keyar@chromium.org795cd472012-08-02 18:57:53 +0000414 ++argv;
415 if (argv >= stop) {
scroggo@google.com9a412522012-09-07 15:21:18 +0000416 SkString err;
417 err.printf("Missing width for --mode %s\n", mode);
418 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000419 PRINT_USAGE_AND_EXIT;
keyar@chromium.org795cd472012-08-02 18:57:53 +0000420 }
421
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000422 widthString = *argv;
keyar@chromium.org795cd472012-08-02 18:57:53 +0000423 ++argv;
424 if (argv >= stop) {
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000425 SkString err;
426 err.appendf("Missing height for --mode %s\n", mode);
427 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000428 PRINT_USAGE_AND_EXIT;
keyar@chromium.org795cd472012-08-02 18:57:53 +0000429 }
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000430 heightString = *argv;
scroggo@google.com9a412522012-09-07 15:21:18 +0000431 } else if (0 == strcmp(*argv, "playbackCreation")) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000432 renderer.reset(SkNEW(sk_tools::PlaybackCreationRenderer));
junov@chromium.org7b537062012-11-06 18:58:43 +0000433 gridSupported = true;
reed@google.comfe7b1ed2012-11-29 21:00:39 +0000434 } else if (0 == strcmp(*argv, "gatherPixelRefs")) {
435 renderer.reset(sk_tools::CreateGatherPixelRefsRenderer());
reed@google.com006db0f2012-06-27 19:33:29 +0000436 } else {
scroggo@google.com9a412522012-09-07 15:21:18 +0000437 SkString err;
438 err.printf("%s is not a valid mode for --mode\n", *argv);
439 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000440 PRINT_USAGE_AND_EXIT;
reed@google.com006db0f2012-06-27 19:33:29 +0000441 }
scroggo@google.comc0d5e542012-12-13 21:40:48 +0000442 } else if (0 == strcmp(*argv, "--viewport")) {
443 ++argv;
444 if (argv >= stop) {
445 gLogger.logError("Missing width for --viewport\n");
446 PRINT_USAGE_AND_EXIT;
447 }
448 viewport.fWidth = atoi(*argv);
449 ++argv;
450 if (argv >= stop) {
451 gLogger.logError("Missing height for --viewport\n");
452 PRINT_USAGE_AND_EXIT;
453 }
454 viewport.fHeight = atoi(*argv);
scroggo@google.com82ec0b02012-12-17 19:25:54 +0000455 } else if (0 == strcmp(*argv, "--scale")) {
456 ++argv;
457 if (argv >= stop) {
458 gLogger.logError("Missing scaleFactor for --scale\n");
459 PRINT_USAGE_AND_EXIT;
460 }
reed@google.com89d15a22013-01-07 22:26:05 +0000461 scaleFactor = SkDoubleToScalar(atof(*argv));
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000462 } else if (0 == strcmp(*argv, "--tiles")) {
463 ++argv;
464 if (argv >= stop) {
465 gLogger.logError("Missing x for --tiles\n");
466 PRINT_USAGE_AND_EXIT;
467 }
468 xTilesString = *argv;
469 ++argv;
470 if (argv >= stop) {
471 gLogger.logError("Missing y for --tiles\n");
472 PRINT_USAGE_AND_EXIT;
473 }
474 yTilesString = *argv;
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000475 } else if (0 == strcmp(*argv, "--device")) {
476 ++argv;
477 if (argv >= stop) {
borenet@google.coma49bffd2012-09-13 18:54:48 +0000478 gLogger.logError("Missing mode for --device\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000479 PRINT_USAGE_AND_EXIT;
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000480 }
481
482 if (0 == strcmp(*argv, "bitmap")) {
483 deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType;
484 }
485#if SK_SUPPORT_GPU
486 else if (0 == strcmp(*argv, "gpu")) {
487 deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
488 }
489#endif
scroggo@google.com0556ea02013-02-08 19:38:21 +0000490#if SK_ANGLE
491 else if (0 == strcmp(*argv, "angle")) {
492 deviceType = sk_tools::PictureRenderer::kAngle_DeviceType;
493 }
494#endif
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000495 else {
scroggo@google.com9a412522012-09-07 15:21:18 +0000496 SkString err;
497 err.printf("%s is not a valid mode for --device\n", *argv);
498 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000499 PRINT_USAGE_AND_EXIT;
keyar@chromium.orgc81686c2012-08-20 15:04:04 +0000500 }
scroggo@google.com5239c322012-09-11 19:15:32 +0000501 } else if (0 == strcmp(*argv, "--timers")) {
502 ++argv;
503 if (argv < stop) {
504 bool timerWall = false;
505 bool truncatedTimerWall = false;
506 bool timerCpu = false;
507 bool truncatedTimerCpu = false;
508 bool timerGpu = false;
509 for (char* t = *argv; *t; ++t) {
510 switch (*t) {
511 case 'w':
512 timerWall = true;
513 break;
514 case 'c':
515 timerCpu = true;
516 break;
517 case 'W':
518 truncatedTimerWall = true;
519 break;
520 case 'C':
521 truncatedTimerCpu = true;
522 break;
523 case 'g':
524 timerGpu = true;
525 break;
526 default: {
527 break;
528 }
529 }
530 }
531 benchmark->setTimersToShow(timerWall, truncatedTimerWall, timerCpu,
532 truncatedTimerCpu, timerGpu);
533 } else {
534 gLogger.logError("Missing arg for --timers\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000535 PRINT_USAGE_AND_EXIT;
scroggo@google.com5239c322012-09-11 19:15:32 +0000536 }
scroggo@google.comcbcef702012-12-13 22:09:28 +0000537 } else if (0 == strcmp(*argv, "--timeIndividualTiles")) {
538 benchmark->setTimeIndividualTiles(true);
scroggo@google.com5239c322012-09-11 19:15:32 +0000539 } else if (0 == strcmp(*argv, "--min")) {
540 benchmark->setPrintMin(true);
541 } else if (0 == strcmp(*argv, "--logPerIter")) {
542 ++argv;
543 if (argv < stop) {
544 bool log = atoi(*argv) != 0;
545 benchmark->setLogPerIter(log);
546 } else {
547 gLogger.logError("Missing arg for --logPerIter\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000548 PRINT_USAGE_AND_EXIT;
scroggo@google.com5239c322012-09-11 19:15:32 +0000549 }
caryclark@google.coma3622372012-11-06 21:26:13 +0000550 } else if (0 == strcmp(*argv, "--filter")) {
551 ++argv;
552 if (argv < stop) {
553 const char* colon = strchr(*argv, ':');
554 if (colon) {
555 int type = -1;
556 size_t typeLen = colon - *argv;
557 for (size_t tIndex = 0; tIndex < kFilterTypesCount; ++tIndex) {
558 if (typeLen == strlen(gFilterTypes[tIndex])
559 && !strncmp(*argv, gFilterTypes[tIndex], typeLen)) {
560 type = tIndex;
561 break;
562 }
563 }
564 if (type < 0) {
565 SkString err;
566 err.printf("Unknown type for --filter %s\n", *argv);
567 gLogger.logError(err);
568 PRINT_USAGE_AND_EXIT;
569 }
570 int flag = -1;
571 size_t flagLen = strlen(*argv) - typeLen - 1;
572 for (size_t fIndex = 0; fIndex < kFilterFlagsCount; ++fIndex) {
573 if (flagLen == strlen(gFilterFlags[fIndex])
574 && !strncmp(colon + 1, gFilterFlags[fIndex], flagLen)) {
575 flag = 1 << fIndex;
576 break;
577 }
578 }
579 if (flag < 0) {
580 SkString err;
581 err.printf("Unknown flag for --filter %s\n", *argv);
582 gLogger.logError(err);
583 PRINT_USAGE_AND_EXIT;
584 }
585 for (int index = 0; index < SkDrawFilter::kTypeCount; ++index) {
586 if (type != SkDrawFilter::kTypeCount && index != type) {
587 continue;
588 }
589 drawFilters[index] = (sk_tools::PictureRenderer::DrawFilterFlags)
590 (drawFilters[index] | flag);
591 }
592 } else {
593 SkString err;
594 err.printf("Unknown arg for --filter %s : missing colon\n", *argv);
595 gLogger.logError(err);
596 PRINT_USAGE_AND_EXIT;
597 }
598 } else {
599 gLogger.logError("Missing arg for --filter\n");
600 PRINT_USAGE_AND_EXIT;
601 }
reed@google.com006db0f2012-06-27 19:33:29 +0000602 } else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000603 PRINT_USAGE_AND_EXIT;
reed@google.com006db0f2012-06-27 19:33:29 +0000604 } else {
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000605 inputs->push_back(SkString(*argv));
reed@google.com006db0f2012-06-27 19:33:29 +0000606 }
607 }
608
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000609 if (numThreads > 1 && !useTiles) {
610 gLogger.logError("Multithreaded drawing requires tiled rendering.\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000611 PRINT_USAGE_AND_EXIT;
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000612 }
613
junov@chromium.org9313ca42012-11-02 18:11:49 +0000614 if (usePipe && sk_tools::PictureRenderer::kNone_BBoxHierarchyType != bbhType) {
615 gLogger.logError("--pipe and --bbh cannot be used together\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000616 PRINT_USAGE_AND_EXIT;
junov@chromium.org9313ca42012-11-02 18:11:49 +0000617 }
618
junov@chromium.org7b537062012-11-06 18:58:43 +0000619 if (sk_tools::PictureRenderer::kTileGrid_BBoxHierarchyType == bbhType &&
620 !gridSupported) {
621 gLogger.logError("'--bbh grid' is not compatible with specified --mode.\n");
622 PRINT_USAGE_AND_EXIT;
623 }
624
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000625 if (useTiles) {
scroggo@google.com5239c322012-09-11 19:15:32 +0000626 SkASSERT(NULL == renderer);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000627 sk_tools::TiledPictureRenderer* tiledRenderer;
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000628 if (isCopyMode) {
629 int x, y;
630 if (xTilesString != NULL) {
631 SkASSERT(yTilesString != NULL);
632 x = atoi(xTilesString);
633 y = atoi(yTilesString);
634 if (x <= 0 || y <= 0) {
635 gLogger.logError("--tiles must be given values > 0\n");
636 PRINT_USAGE_AND_EXIT;
637 }
638 } else {
639 x = y = 4;
640 }
641 tiledRenderer = SkNEW_ARGS(sk_tools::CopyTilesRenderer, (x, y));
scroggo@google.comcbcef702012-12-13 22:09:28 +0000642 if (benchmark->timeIndividualTiles()) {
643 gLogger.logError("timeIndividualTiles is not compatible with copyTile\n");
644 PRINT_USAGE_AND_EXIT;
645 }
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000646 } else if (numThreads > 1) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000647 tiledRenderer = SkNEW_ARGS(sk_tools::MultiCorePictureRenderer, (numThreads));
648 } else {
649 tiledRenderer = SkNEW(sk_tools::TiledPictureRenderer);
650 }
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000651 if (isPowerOf2Mode) {
652 int minWidth = atoi(widthString);
653 if (!SkIsPow2(minWidth) || minWidth < 0) {
scroggo@google.com5239c322012-09-11 19:15:32 +0000654 tiledRenderer->unref();
scroggo@google.com9a412522012-09-07 15:21:18 +0000655 SkString err;
scroggo@google.com5239c322012-09-11 19:15:32 +0000656 err.printf("-mode %s must be given a width"
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000657 " value that is a power of two\n", mode);
scroggo@google.com9a412522012-09-07 15:21:18 +0000658 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000659 PRINT_USAGE_AND_EXIT;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000660 }
scroggo@google.com5239c322012-09-11 19:15:32 +0000661 tiledRenderer->setTileMinPowerOf2Width(minWidth);
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000662 } else if (sk_tools::is_percentage(widthString)) {
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000663 if (isCopyMode) {
664 tiledRenderer->unref();
665 SkString err;
666 err.printf("--mode %s does not support percentages.\n", mode);
667 gLogger.logError(err.c_str());
668 PRINT_USAGE_AND_EXIT;
669 }
scroggo@google.com5239c322012-09-11 19:15:32 +0000670 tiledRenderer->setTileWidthPercentage(atof(widthString));
671 if (!(tiledRenderer->getTileWidthPercentage() > 0)) {
672 tiledRenderer->unref();
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000673 SkString err;
674 err.appendf("--mode %s must be given a width percentage > 0\n", mode);
675 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000676 PRINT_USAGE_AND_EXIT;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000677 }
678 } else {
scroggo@google.com5239c322012-09-11 19:15:32 +0000679 tiledRenderer->setTileWidth(atoi(widthString));
680 if (!(tiledRenderer->getTileWidth() > 0)) {
681 tiledRenderer->unref();
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000682 SkString err;
683 err.appendf("--mode %s must be given a width > 0\n", mode);
684 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000685 PRINT_USAGE_AND_EXIT;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000686 }
687 }
688
689 if (sk_tools::is_percentage(heightString)) {
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000690 if (isCopyMode) {
691 tiledRenderer->unref();
692 SkString err;
693 err.printf("--mode %s does not support percentages.\n", mode);
694 gLogger.logError(err.c_str());
695 PRINT_USAGE_AND_EXIT;
696 }
scroggo@google.com5239c322012-09-11 19:15:32 +0000697 tiledRenderer->setTileHeightPercentage(atof(heightString));
698 if (!(tiledRenderer->getTileHeightPercentage() > 0)) {
699 tiledRenderer->unref();
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000700 SkString err;
701 err.appendf("--mode %s must be given a height percentage > 0\n", mode);
702 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000703 PRINT_USAGE_AND_EXIT;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000704 }
705 } else {
scroggo@google.com5239c322012-09-11 19:15:32 +0000706 tiledRenderer->setTileHeight(atoi(heightString));
707 if (!(tiledRenderer->getTileHeight() > 0)) {
708 tiledRenderer->unref();
scroggo@google.com4a26d9d2012-11-07 18:01:46 +0000709 SkString err;
710 err.appendf("--mode %s must be given a height > 0\n", mode);
711 gLogger.logError(err);
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000712 PRINT_USAGE_AND_EXIT;
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000713 }
714 }
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000715 if (numThreads > 1) {
scroggo@google.com0556ea02013-02-08 19:38:21 +0000716 switch (deviceType) {
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000717#if SK_SUPPORT_GPU
scroggo@google.com0556ea02013-02-08 19:38:21 +0000718 case sk_tools::PictureRenderer::kGPU_DeviceType:
719 // fall through
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000720#endif
scroggo@google.com0556ea02013-02-08 19:38:21 +0000721#if SK_ANGLE
722 case sk_tools::PictureRenderer::kAngle_DeviceType:
723#endif
724 tiledRenderer->unref();
725 gLogger.logError("GPU not compatible with multithreaded tiling.\n");
726 PRINT_USAGE_AND_EXIT;
727 break;
728 default:
729 break;
730 }
scroggo@google.combcdf2ec2012-09-20 14:42:33 +0000731 }
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000732 renderer.reset(tiledRenderer);
733 if (usePipe) {
scroggo@google.comcbcef702012-12-13 22:09:28 +0000734 gLogger.logError("Pipe rendering is currently not compatible with tiling.\n"
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000735 "Turning off pipe.\n");
736 }
scroggo@google.comcbcef702012-12-13 22:09:28 +0000737 } else {
738 if (benchmark->timeIndividualTiles()) {
739 gLogger.logError("timeIndividualTiles requires tiled rendering.\n");
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000740 PRINT_USAGE_AND_EXIT;
741 }
scroggo@google.comcbcef702012-12-13 22:09:28 +0000742 if (usePipe) {
743 if (renderer.get() != NULL) {
744 gLogger.logError("Pipe is incompatible with other modes.\n");
745 PRINT_USAGE_AND_EXIT;
746 }
747 renderer.reset(SkNEW(sk_tools::PipePictureRenderer));
748 }
scroggo@google.com58b4ead2012-08-31 16:15:22 +0000749 }
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000750 if (inputs->count() < 1) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000751 PRINT_USAGE_AND_EXIT;
reed@google.com006db0f2012-06-27 19:33:29 +0000752 }
keyar@chromium.org163b5672012-08-01 17:53:29 +0000753
scroggo@google.com5239c322012-09-11 19:15:32 +0000754 if (NULL == renderer) {
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000755 renderer.reset(SkNEW(sk_tools::SimplePictureRenderer));
keyar@chromium.org163b5672012-08-01 17:53:29 +0000756 }
junov@chromium.org9313ca42012-11-02 18:11:49 +0000757
758 renderer->setBBoxHierarchyType(bbhType);
caryclark@google.coma3622372012-11-06 21:26:13 +0000759 renderer->setDrawFilters(drawFilters, filtersName(drawFilters));
junov@chromium.org7b537062012-11-06 18:58:43 +0000760 renderer->setGridSize(gridWidth, gridHeight);
scroggo@google.comc0d5e542012-12-13 21:40:48 +0000761 renderer->setViewport(viewport);
scroggo@google.com82ec0b02012-12-17 19:25:54 +0000762 renderer->setScaleFactor(scaleFactor);
scroggo@google.com0556ea02013-02-08 19:38:21 +0000763 if (!renderer->setDeviceType(deviceType)) {
764 gLogger.logError("Invalid deviceType.\n");
765 PRINT_USAGE_AND_EXIT;
766 }
scroggo@google.coma62da2f2012-11-02 21:28:12 +0000767 benchmark->setRenderer(renderer);
keyar@chromium.org163b5672012-08-01 17:53:29 +0000768 benchmark->setRepeats(repeats);
scroggo@google.com9a412522012-09-07 15:21:18 +0000769 benchmark->setLogger(&gLogger);
770 // Report current settings:
771 gLogger.logProgress(commandLine);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000772}
reed@google.com006db0f2012-06-27 19:33:29 +0000773
borenet@google.com66bcbd12012-09-17 18:26:06 +0000774static int process_input(const SkString& input,
775 sk_tools::PictureBenchmark& benchmark) {
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000776 SkOSFile::Iter iter(input.c_str(), "skp");
777 SkString inputFilename;
borenet@google.com66bcbd12012-09-17 18:26:06 +0000778 int failures = 0;
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000779 if (iter.next(&inputFilename)) {
780 do {
781 SkString inputPath;
keyar@chromium.org163b5672012-08-01 17:53:29 +0000782 sk_tools::make_filepath(&inputPath, input, inputFilename);
borenet@google.com57837bf2012-09-19 17:28:29 +0000783 if (!run_single_benchmark(inputPath, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000784 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000785 }
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000786 } while(iter.next(&inputFilename));
borenet@google.com57837bf2012-09-19 17:28:29 +0000787 } else if (SkStrEndsWith(input.c_str(), ".skp")) {
788 if (!run_single_benchmark(input, benchmark)) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000789 ++failures;
borenet@google.com57837bf2012-09-19 17:28:29 +0000790 }
791 } else {
792 SkString warning;
793 warning.printf("Warning: skipping %s\n", input.c_str());
794 gLogger.logError(warning);
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000795 }
borenet@google.com66bcbd12012-09-17 18:26:06 +0000796 return failures;
reed@google.com006db0f2012-06-27 19:33:29 +0000797}
798
caryclark@google.com5987f582012-10-02 18:33:14 +0000799int tool_main(int argc, char** argv);
800int tool_main(int argc, char** argv) {
bsalomon@google.com4e230682013-01-15 20:37:04 +0000801#if SK_ENABLE_INST_COUNT
scroggo@google.com5239c322012-09-11 19:15:32 +0000802 gPrintInstCount = true;
803#endif
scroggo@google.com0a36f432012-09-10 20:29:13 +0000804 SkAutoGraphics ag;
reed@google.com006db0f2012-06-27 19:33:29 +0000805
scroggo@google.com5239c322012-09-11 19:15:32 +0000806 SkTArray<SkString> inputs;
807 sk_tools::PictureBenchmark benchmark;
808
809 parse_commandline(argc, argv, &inputs, &benchmark);
reed@google.com006db0f2012-06-27 19:33:29 +0000810
borenet@google.com66bcbd12012-09-17 18:26:06 +0000811 int failures = 0;
keyar@chromium.orgd1dc9202012-07-09 18:32:08 +0000812 for (int i = 0; i < inputs.count(); ++i) {
borenet@google.com66bcbd12012-09-17 18:26:06 +0000813 failures += process_input(inputs[i], benchmark);
814 }
815
816 if (failures != 0) {
817 SkString err;
818 err.printf("Failed to run %i benchmarks.\n", failures);
819 gLogger.logError(err);
820 return 1;
reed@google.com006db0f2012-06-27 19:33:29 +0000821 }
caryclark@google.com868e1f62012-10-02 20:00:03 +0000822 return 0;
reed@google.com006db0f2012-06-27 19:33:29 +0000823}
caryclark@google.com5987f582012-10-02 18:33:14 +0000824
825#if !defined SK_BUILD_FOR_IOS
826int main(int argc, char * const argv[]) {
827 return tool_main(argc, (char**) argv);
828}
829#endif