blob: 30c23356b07b87c1a4d3c5d550a1f0d3b89e30b3 [file] [log] [blame]
chudy@google.com607357f2012-08-07 16:12:23 +00001
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"
kkinnunen5caff912015-01-02 07:24:14 -080010#include "SkGraphics.h"
chudy@google.com607357f2012-08-07 16:12:23 +000011#include <QApplication>
12
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000013static 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.com607357f2012-08-07 16:12:23 +000020int main(int argc, char *argv[]) {
kkinnunen6438f9a2014-11-13 05:13:50 -080021#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
kkinnunen5caff912015-01-02 07:24:14 -080027 SkGraphics::Init();
chudy@google.com607357f2012-08-07 16:12:23 +000028 QApplication a(argc, argv);
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000029 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.come219baf2013-01-28 19:25:43 +000039 SkString commandName(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000040 ++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.come219baf2013-01-28 19:25:43 +000047 input = SkString(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000048 } else {
49 usage(commandName.c_str());
50 return -1;
51 }
52 }
53
chudy@google.com607357f2012-08-07 16:12:23 +000054 SkDebuggerGUI w;
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000055
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.com607357f2012-08-07 16:12:23 +000064 w.show();
kkinnunen5caff912015-01-02 07:24:14 -080065 int result = a.exec();
kkinnunen5caff912015-01-02 07:24:14 -080066 return result;
chudy@google.com607357f2012-08-07 16:12:23 +000067}