chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 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" |
kkinnunen | 5caff91 | 2015-01-02 07:24:14 -0800 | [diff] [blame] | 10 | #include "SkGraphics.h" |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 11 | #include <QApplication> |
| 12 | |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 13 | static void usage(const char * argv0) { |
| 14 | SkDebugf("%s <input> \n", argv0); |
| 15 | SkDebugf(" [--help|-h]: show this help message\n"); |
| 16 | SkDebugf("\n\n"); |
| 17 | SkDebugf(" input: Either a directory or a single .skp file.\n"); |
| 18 | } |
| 19 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 20 | int main(int argc, char *argv[]) { |
kkinnunen | 6438f9a | 2014-11-13 05:13:50 -0800 | [diff] [blame] | 21 | #ifndef SK_BUILD_FOR_WIN32 |
| 22 | // Set numeric formatting to default. Otherwise shaders will have numbers with wrong comma. |
| 23 | // QApplication documentation recommends setlocale("LC_NUMERIC", "C") after QApplication |
| 24 | // constuction. However, the components Qt calls (X11 libs, ..) will override that. |
| 25 | setenv("LC_NUMERIC", "C", 1); |
| 26 | #endif |
kkinnunen | 5caff91 | 2015-01-02 07:24:14 -0800 | [diff] [blame] | 27 | SkGraphics::Init(); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 28 | QApplication a(argc, argv); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 29 | QStringList argList = a.arguments(); |
| 30 | |
| 31 | if (argList.count() <= 0) { |
| 32 | return -1; // should at least have command name |
| 33 | } |
| 34 | |
| 35 | SkString input; |
| 36 | |
| 37 | QStringList::const_iterator iter = argList.begin(); |
| 38 | |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 39 | SkString commandName(iter->toAscii().data()); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 40 | ++iter; // skip the command name |
| 41 | |
| 42 | for ( ; iter != argList.end(); ++iter) { |
| 43 | if (0 == iter->compare("--help") || 0 == iter->compare("-h")) { |
| 44 | usage(commandName.c_str()); |
| 45 | return -1; |
| 46 | } else if (input.isEmpty()) { |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 47 | input = SkString(iter->toAscii().data()); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 48 | } else { |
| 49 | usage(commandName.c_str()); |
| 50 | return -1; |
| 51 | } |
| 52 | } |
| 53 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 54 | SkDebuggerGUI w; |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 55 | |
| 56 | if (!input.isEmpty()) { |
| 57 | if (SkStrEndsWith(input.c_str(), ".skp")) { |
| 58 | w.openFile(input.c_str()); |
| 59 | } else { |
| 60 | w.setupDirectoryWidget(input.c_str()); |
| 61 | } |
| 62 | } |
| 63 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 64 | w.show(); |
kkinnunen | 5caff91 | 2015-01-02 07:24:14 -0800 | [diff] [blame] | 65 | int result = a.exec(); |
kkinnunen | 5caff91 | 2015-01-02 07:24:14 -0800 | [diff] [blame] | 66 | return result; |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 67 | } |