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 "SkForceLinking.h" |
| 11 | #include "SkGraphics.h" |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 12 | #include <QApplication> |
| 13 | |
kkinnunen | 5caff91 | 2015-01-02 07:24:14 -0800 | [diff] [blame] | 14 | __SK_FORCE_IMAGE_DECODER_LINKING; |
| 15 | |
| 16 | |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 17 | static 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 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 24 | int main(int argc, char *argv[]) { |
kkinnunen | 6438f9a | 2014-11-13 05:13:50 -0800 | [diff] [blame] | 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 |
kkinnunen | 5caff91 | 2015-01-02 07:24:14 -0800 | [diff] [blame] | 31 | SkGraphics::Init(); |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 32 | QApplication a(argc, argv); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 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 | |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 43 | SkString commandName(iter->toAscii().data()); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 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()) { |
robertphillips@google.com | e219baf | 2013-01-28 19:25:43 +0000 | [diff] [blame] | 51 | input = SkString(iter->toAscii().data()); |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 52 | } else { |
| 53 | usage(commandName.c_str()); |
| 54 | return -1; |
| 55 | } |
| 56 | } |
| 57 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 58 | SkDebuggerGUI w; |
robertphillips@google.com | ff6e6ba | 2013-01-28 17:43:26 +0000 | [diff] [blame] | 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 | |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 68 | w.show(); |
kkinnunen | 5caff91 | 2015-01-02 07:24:14 -0800 | [diff] [blame] | 69 | int result = a.exec(); |
| 70 | SkGraphics::Term(); |
| 71 | return result; |
chudy@google.com | 607357f | 2012-08-07 16:12:23 +0000 | [diff] [blame] | 72 | } |