Added the option to enable GPU rendering on render_ and bench_pictures.

git-svn-id: http://skia.googlecode.com/svn/trunk@5183 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/bench_pictures_main.cpp b/tools/bench_pictures_main.cpp
index 5fc1bd8..ef0dbf0 100644
--- a/tools/bench_pictures_main.cpp
+++ b/tools/bench_pictures_main.cpp
@@ -22,7 +22,12 @@
 "Usage: \n"
 "     %s <inputDir>...\n"
 "     [--repeat] \n"
-"     [--mode pipe | record | simple | tile width[%] height[%] | unflatten]"
+"     [--mode pipe | record | simple | tile width[%] height[%] | unflatten]\n"
+"     [--device bitmap"
+#if SK_SUPPORT_GPU
+" | gpu"
+#endif
+"]"
 , argv0);
     SkDebugf("\n\n");
     SkDebugf(
@@ -44,6 +49,19 @@
 "                     unflatten, Benchmark picture unflattening.\n");
     SkDebugf("\n");
     SkDebugf(
+"     --device bitmap"
+#if SK_SUPPORT_GPU
+" | gpu"
+#endif
+": Use the corresponding device. Default is bitmap.\n");
+    SkDebugf(
+"                     bitmap, Render to a bitmap.\n");
+    SkDebugf(
+#if SK_SUPPORT_GPU
+"                     gpu, Render to the GPU.\n");
+#endif
+    SkDebugf("\n");
+    SkDebugf(
 "     --repeat:  "
 "Set the number of times to repeat each test."
 " Default is %i.\n", DEFAULT_REPEATS);
@@ -75,6 +93,8 @@
     char* const* stop = argv + argc;
 
     int repeats = DEFAULT_REPEATS;
+    sk_tools::PictureRenderer::SkDeviceTypes deviceType =
+        sk_tools::PictureRenderer::kBitmap_DeviceType;
 
     for (++argv; argv < stop; ++argv) {
         if (0 == strcmp(*argv, "--repeat")) {
@@ -167,6 +187,28 @@
                 usage(argv0);
                 exit(-1);
             }
+        }  else if (0 == strcmp(*argv, "--device")) {
+            ++argv;
+            if (argv >= stop) {
+                SkDebugf("Missing mode for --deivce\n");
+                usage(argv0);
+                exit(-1);
+            }
+
+            if (0 == strcmp(*argv, "bitmap")) {
+                deviceType = sk_tools::PictureRenderer::kBitmap_DeviceType;
+            }
+#if SK_SUPPORT_GPU
+            else if (0 == strcmp(*argv, "gpu")) {
+                deviceType = sk_tools::PictureRenderer::kGPU_DeviceType;
+            }
+#endif
+            else {
+                SkDebugf("%s is not a valid mode for --device\n", *argv);
+                usage(argv0);
+                exit(-1);
+            }
+
         } else if (0 == strcmp(*argv, "--help") || 0 == strcmp(*argv, "-h")) {
             SkDELETE(benchmark);
             usage(argv0);
@@ -187,7 +229,7 @@
     }
 
     benchmark->setRepeats(repeats);
-    benchmark->setUseGpuDevice();
+    benchmark->setDeviceType(deviceType);
 }
 
 static void process_input(const SkString& input, sk_tools::PictureBenchmark& benchmark) {