render_pictures and bench_pictures now use a --mode parameter.

This replaces the --tile, --pipe, etc. options from before as they are mutually exclusive.

Review URL: https://codereview.appspot.com/6443076

git-svn-id: http://skia.googlecode.com/svn/trunk@4930 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index c595eb5..ae9e850 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -21,30 +21,32 @@
     SkDebugf("\n"
 "Usage: \n"
 "     %s <inputDir>...\n"
-"     [--repeat] [--tile width height]"
+"     [--repeat] \n"
+"     [--mode pipe | record | simple | tile width[%] height[%] | unflatten]"
 , argv0);
     SkDebugf("\n\n");
     SkDebugf(
-"     inputDir:  A list of directories and files to use as input.\n"
-"                    Files are expected to have the .skp extension.\n\n");
+"     inputDir:  A list of directories and files to use as input. Files are\n"
+"                expected to have the .skp extension.\n\n");
     SkDebugf(
-"     --pipe : "
-"Set to use piping."
-" Default is to not use piping.\n");
+"     --mode pipe | record | simple | tile width[%] height[%] | unflatten: Run\n"
+"                in the corresponding mode. Default is simple.\n");
     SkDebugf(
-"     --record : "
-"Set to do a picture recording benchmark. Default is not to do this.\n");
+"                     pipe, Benchmark SkGPipe rendering.\n");
     SkDebugf(
-"     --repeat : "
+"                     record, Benchmark picture to picture recording.\n");
+    SkDebugf(
+"                     simple, Benchmark a simple rendering.\n");
+    SkDebugf(
+"                     tile width[%] height[%], Benchmark simple rendering using\n"
+"                                              tiles with the given dimensions.\n");
+    SkDebugf(
+"                     unflatten, Benchmark picture unflattening.\n");
+    SkDebugf("\n");
+    SkDebugf(
+"     --repeat:  "
 "Set the number of times to repeat each test."
 " Default is %i.\n", DEFAULT_REPEATS);
-    SkDebugf(
-"     --tile width[%] height[%]: "
-"Set to use the tiling size and specify the dimensions of each tile.\n"
-"                                     Default is to not use tiling\n");
-    SkDebugf(
-"     --unflatten: "
-"Set to do a picture unflattening benchmark. Default is not to do this.\n");
 }
 
 static void run_single_benchmark(const SkString& inputPath,
@@ -80,7 +82,7 @@
             if (argv < stop) {
                 repeats = atoi(*argv);
                 if (repeats < 1) {
-		    SkDELETE(benchmark);
+                    SkDELETE(benchmark);
                     SkDebugf("--repeat must be given a value > 0\n");
                     exit(-1);
                 }
@@ -90,61 +92,81 @@
                 usage(argv0);
                 exit(-1);
             }
-        } else if (0 == strcmp(*argv, "--tile")) {
-            sk_tools::TiledPictureBenchmark* tileBenchmark = SkNEW(sk_tools::TiledPictureBenchmark);
+        } else if (0 == strcmp(*argv, "--mode")) {
+            SkDELETE(benchmark);
+
             ++argv;
-            if (argv < stop) {
+            if (argv >= stop) {
+                SkDebugf("Missing mode for --mode\n");
+                usage(argv0);
+                exit(-1);
+            }
+
+            if (0 == strcmp(*argv, "pipe")) {
+                benchmark = SkNEW(sk_tools::PipePictureBenchmark);
+            } else if (0 == strcmp(*argv, "record")) {
+                benchmark = SkNEW(sk_tools::RecordPictureBenchmark);
+            } else if (0 == strcmp(*argv, "simple")) {
+                benchmark = SkNEW(sk_tools::SimplePictureBenchmark);
+            } else if (0 == strcmp(*argv, "tile")) {
+                sk_tools::TiledPictureBenchmark* tileBenchmark =
+                    SkNEW(sk_tools::TiledPictureBenchmark);
+                ++argv;
+                if (argv >= stop) {
+                    SkDELETE(tileBenchmark);
+                    SkDebugf("Missing width for --mode tile\n");
+                    usage(argv0);
+                    exit(-1);
+                }
+
                 if (sk_tools::is_percentage(*argv)) {
                     tileBenchmark->setTileWidthPercentage(atof(*argv));
                     if (!(tileBenchmark->getTileWidthPercentage() > 0)) {
                         SkDELETE(tileBenchmark);
-                        SkDebugf("--tile must be given a width percentage > 0\n");
+                        SkDebugf("--mode tile must be given a width percentage > 0\n");
                         exit(-1);
                     }
                 } else {
                     tileBenchmark->setTileWidth(atoi(*argv));
                     if (!(tileBenchmark->getTileWidth() > 0)) {
                         SkDELETE(tileBenchmark);
-                        SkDebugf("--tile must be given a width > 0\n");
+                        SkDebugf("--mode tile must be given a width > 0\n");
                         exit(-1);
                     }
                 }
-            } else {
-                SkDELETE(tileBenchmark);
-                SkDebugf("Missing width for --tile\n");
-                usage(argv0);
-                exit(-1);
-            }
-            ++argv;
-            if (argv < stop) {
+
+                ++argv;
+                if (argv >= stop) {
+                    SkDELETE(tileBenchmark);
+                    SkDebugf("Missing height for --mode tile\n");
+                    usage(argv0);
+                    exit(-1);
+                }
+
                 if (sk_tools::is_percentage(*argv)) {
                     tileBenchmark->setTileHeightPercentage(atof(*argv));
                     if (!(tileBenchmark->getTileHeightPercentage() > 0)) {
                         SkDELETE(tileBenchmark);
-                        SkDebugf("--tile must be given a height percentage > 0\n");
+                        SkDebugf("--mode tile must be given a height percentage > 0\n");
                         exit(-1);
                     }
                 } else {
                     tileBenchmark->setTileHeight(atoi(*argv));
                     if (!(tileBenchmark->getTileHeight() > 0)) {
                         SkDELETE(tileBenchmark);
-                        SkDebugf("--tile must be given a height > 0\n");
+                        SkDebugf("--mode tile must be given a height > 0\n");
                         exit(-1);
                     }
                 }
+
+                benchmark = tileBenchmark;
+            } else if (0 == strcmp(*argv, "unflatten")) {
+                benchmark = SkNEW(sk_tools::UnflattenPictureBenchmark);
             } else {
-                SkDELETE(tileBenchmark);
-                SkDebugf("Missing height for --tile\n");
+                SkDebugf("%s is not a valid mode for --mode\n", *argv);
                 usage(argv0);
                 exit(-1);
             }
-            benchmark = tileBenchmark;
-        } else if (0 == strcmp(*argv, "--pipe")) {
-            benchmark = SkNEW(sk_tools::PipePictureBenchmark);
-        } else if (0 == strcmp(*argv, "--record")) {
-            benchmark = SkNEW(sk_tools::RecordPictureBenchmark);
-        } else if (0 == strcmp(*argv, "--unflatten")) {
-            benchmark = SkNEW(sk_tools::UnflattenPictureBenchmark);
         } else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) {
             SkDELETE(benchmark);
             usage(argv0);