Fix for SampleApp command line parsing issue.

http://codereview.appspot.com/5785054/



git-svn-id: http://skia.googlecode.com/svn/trunk@3462 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp
index c93bae8..b2af16a 100644
--- a/samplecode/SampleApp.cpp
+++ b/samplecode/SampleApp.cpp
@@ -591,13 +591,22 @@
 }
 
 static void usage(const char * argv0) {
-    SkDebugf("%s [sampleName] [-i resourcePath]\n", argv0);
+    SkDebugf("%s [--slide sampleName] [-i resourcePath]\n", argv0);
     SkDebugf("    sampleName: sample at which to start.\n");
     SkDebugf("    resourcePath: directory that stores image resources.\n");
 }
 
 SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* devManager) : INHERITED(hwnd) {
 
+    SkGMRegistyToSampleRegistry();
+    {
+        const SkViewRegister* reg = SkViewRegister::Head();
+        while (reg) {
+            *fSamples.append() = reg->factory();
+            reg = reg->next();
+        }
+    }
+
     const char* resourcePath = NULL;
     fCurrIndex = -1;
 
@@ -609,11 +618,16 @@
             if (argv < stop && **argv) {
                 resourcePath = *argv;
             }
-        } else {
-            fCurrIndex = findByTitle(*argv);
-            if (fCurrIndex < 0) {
-                fprintf(stderr, "Unknown sample \"%s\"\n", *argv);
+        } else if (strcmp(*argv, "--slide") == 0) {
+            argv++;
+            if (argv < stop && **argv) {
+                fCurrIndex = findByTitle(*argv);
+                if (fCurrIndex < 0) {
+                    fprintf(stderr, "Unknown sample \"%s\"\n", *argv);
+                }
             }
+        } else {
+            usage(commandName);
         }
     }
 
@@ -733,15 +747,6 @@
 
     skiagm::GM::SetResourcePath(resourcePath);
 
-    SkGMRegistyToSampleRegistry();
-    {
-        const SkViewRegister* reg = SkViewRegister::Head();
-        while (reg) {
-            *fSamples.append() = reg->factory();
-            reg = reg->next();
-        }
-    }
-
     this->loadView((*fSamples[fCurrIndex])());
     
     fPDFData = NULL;