Added "--list" command line option to SampleApp
authorrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 3 May 2012 18:22:28 +0000 (18:22 +0000)
committerrobertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81>
Thu, 3 May 2012 18:22:28 +0000 (18:22 +0000)
http://codereview.appspot.com/6161043/

committed on behalf of Guanqun

git-svn-id: http://skia.googlecode.com/svn/trunk@3835 2bbb7eff-a529-9590-31e7-b0007b416f81

samplecode/SampleApp.cpp
samplecode/SampleApp.h

index 213a39f0c4cb0ab5a0af251fcace87fe8716f4ab..05f9c820312d2f98d6b57225245952f1c27ebaf8 100644 (file)
@@ -691,6 +691,7 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
                 fCurrIndex = findByTitle(*argv);
                 if (fCurrIndex < 0) {
                     fprintf(stderr, "Unknown sample \"%s\"\n", *argv);
+                    listTitles();
                 }
             }
         } else if (strcmp(*argv, "--msaa") == 0) {
@@ -698,6 +699,8 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
             if (argv < stop && **argv) {
                 fMSAASampleCount = atoi(*argv);
             }
+        } else if (strcmp(*argv, "--list") == 0) {
+            listTitles();
         }
         else {
             usage(commandName);
@@ -873,6 +876,14 @@ int SampleWindow::findByTitle(const char title[]) {
     return -1;
 }
 
+void SampleWindow::listTitles() {
+    int count = fSamples.count();
+    SkDebugf("All Slides:\n");
+    for (int i = 0; i < count; i++) {
+        SkDebugf("    %s\n", getSampleTitle(i).c_str());
+    }
+}
+
 static SkBitmap capture_bitmap(SkCanvas* canvas) {
     SkBitmap bm;
     const SkBitmap& src = canvas->getDevice()->accessBitmap(false);
index eb49236ba172bedd686f5d2b6104a1ef1b293f53..e587e1ff6295a4860f195a5d3c95edbbaf7914e2 100644 (file)
@@ -198,6 +198,7 @@ private:
     void postAnimatingEvent();
     void installDrawFilter(SkCanvas*);
     int findByTitle(const char*);
+    void listTitles();
 
     typedef SkOSWindow INHERITED;
 };