1 2/* 3 * Copyright 2012 Google Inc. 4 * 5 * Use of this source code is governed by a BSD-style license that can be 6 * found in the LICENSE file. 7 */ 8 9#include "SkDebuggerGUI.h" 10#include "SkForceLinking.h" 11#include "SkGraphics.h" 12#include <QApplication> 13 14__SK_FORCE_IMAGE_DECODER_LINKING; 15 16 17static void usage(const char * argv0) { 18 SkDebugf("%s <input> \n", argv0); 19 SkDebugf(" [--help|-h]: show this help message\n"); 20 SkDebugf("\n\n"); 21 SkDebugf(" input: Either a directory or a single .skp file.\n"); 22} 23 24int main(int argc, char *argv[]) { 25#ifndef SK_BUILD_FOR_WIN32 26 // Set numeric formatting to default. Otherwise shaders will have numbers with wrong comma. 27 // QApplication documentation recommends setlocale("LC_NUMERIC", "C") after QApplication 28 // constuction. However, the components Qt calls (X11 libs, ..) will override that. 29 setenv("LC_NUMERIC", "C", 1); 30#endif 31 SkGraphics::Init(); 32 QApplication a(argc, argv); 33 QStringList argList = a.arguments(); 34 35 if (argList.count() <= 0) { 36 return -1; // should at least have command name 37 } 38 39 SkString input; 40 41 QStringList::const_iterator iter = argList.begin(); 42 43 SkString commandName(iter->toAscii().data()); 44 ++iter; // skip the command name 45 46 for ( ; iter != argList.end(); ++iter) { 47 if (0 == iter->compare("--help") || 0 == iter->compare("-h")) { 48 usage(commandName.c_str()); 49 return -1; 50 } else if (input.isEmpty()) { 51 input = SkString(iter->toAscii().data()); 52 } else { 53 usage(commandName.c_str()); 54 return -1; 55 } 56 } 57 58 SkDebuggerGUI w; 59 60 if (!input.isEmpty()) { 61 if (SkStrEndsWith(input.c_str(), ".skp")) { 62 w.openFile(input.c_str()); 63 } else { 64 w.setupDirectoryWidget(input.c_str()); 65 } 66 } 67 68 w.show(); 69 int result = a.exec(); 70 return result; 71} 72