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
This commit is contained in:
robertphillips@google.com 2012-03-22 14:12:15 +00:00
parent 9afc656df6
commit 76d4021ee1

View File

@ -591,13 +591,22 @@ static inline SampleWindow::DeviceType cycle_devicetype(SampleWindow::DeviceType
} }
static void usage(const char * argv0) { 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(" sampleName: sample at which to start.\n");
SkDebugf(" resourcePath: directory that stores image resources.\n"); SkDebugf(" resourcePath: directory that stores image resources.\n");
} }
SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* devManager) : INHERITED(hwnd) { 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; const char* resourcePath = NULL;
fCurrIndex = -1; fCurrIndex = -1;
@ -609,11 +618,16 @@ SampleWindow::SampleWindow(void* hwnd, int argc, char** argv, DeviceManager* dev
if (argv < stop && **argv) { if (argv < stop && **argv) {
resourcePath = *argv; resourcePath = *argv;
} }
} else { } else if (strcmp(*argv, "--slide") == 0) {
fCurrIndex = findByTitle(*argv); argv++;
if (fCurrIndex < 0) { if (argv < stop && **argv) {
fprintf(stderr, "Unknown sample \"%s\"\n", *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); skiagm::GM::SetResourcePath(resourcePath);
SkGMRegistyToSampleRegistry();
{
const SkViewRegister* reg = SkViewRegister::Head();
while (reg) {
*fSamples.append() = reg->factory();
reg = reg->next();
}
}
this->loadView((*fSamples[fCurrIndex])()); this->loadView((*fSamples[fCurrIndex])());
fPDFData = NULL; fPDFData = NULL;