blob: eebcd5f3f110750e731461bad22e1be07b8567a2 [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 "SkForceLinking.h"
11#include "SkGraphics.h"
chudy@google.com607357f2012-08-07 16:12:23 +000012#include <QApplication>
13
kkinnunen5caff912015-01-02 07:24:14 -080014__SK_FORCE_IMAGE_DECODER_LINKING;
15
16
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000017static 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.com607357f2012-08-07 16:12:23 +000024int main(int argc, char *argv[]) {
kkinnunen6438f9a2014-11-13 05:13:50 -080025#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
kkinnunen5caff912015-01-02 07:24:14 -080031 SkGraphics::Init();
chudy@google.com607357f2012-08-07 16:12:23 +000032 QApplication a(argc, argv);
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000033 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.come219baf2013-01-28 19:25:43 +000043 SkString commandName(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000044 ++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.come219baf2013-01-28 19:25:43 +000051 input = SkString(iter->toAscii().data());
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000052 } else {
53 usage(commandName.c_str());
54 return -1;
55 }
56 }
57
chudy@google.com607357f2012-08-07 16:12:23 +000058 SkDebuggerGUI w;
robertphillips@google.comff6e6ba2013-01-28 17:43:26 +000059
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.com607357f2012-08-07 16:12:23 +000068 w.show();
kkinnunen5caff912015-01-02 07:24:14 -080069 int result = a.exec();
kkinnunen5caff912015-01-02 07:24:14 -080070 return result;
chudy@google.com607357f2012-08-07 16:12:23 +000071}