diff options
author | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-22 14:12:15 +0000 |
---|---|---|
committer | robertphillips@google.com <robertphillips@google.com@2bbb7eff-a529-9590-31e7-b0007b416f81> | 2012-03-22 14:12:15 +0000 |
commit | 76d4021ee1bfbf31da274e9feb4c675cfd86e6d3 (patch) | |
tree | 6f61c0cfa105e266b398bf46c5aebec7755adf44 /samplecode | |
parent | 9afc656df6e81a17ab591b607a92755a5a2e06cc (diff) |
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
Diffstat (limited to 'samplecode')
-rw-r--r-- | samplecode/SampleApp.cpp | 33 |
1 files changed, 19 insertions, 14 deletions
diff --git a/samplecode/SampleApp.cpp b/samplecode/SampleApp.cpp index c93bae8e57..b2af16a8f6 100644 --- a/samplecode/SampleApp.cpp +++ b/samplecode/SampleApp.cpp @@ -591,13 +591,22 @@ static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType } 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 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev 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 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev 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; |