2012-08-07 16:12:23 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Copyright 2012 Google Inc.
|
|
|
|
*
|
|
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
|
|
* found in the LICENSE file.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "SkDebuggerGUI.h"
|
2015-01-02 15:24:14 +00:00
|
|
|
#include "SkGraphics.h"
|
2012-08-07 16:12:23 +00:00
|
|
|
#include <QApplication>
|
|
|
|
|
2013-01-28 17:43:26 +00:00
|
|
|
static void usage(const char * argv0) {
|
|
|
|
SkDebugf("%s <input> \n", argv0);
|
|
|
|
SkDebugf(" [--help|-h]: show this help message\n");
|
|
|
|
SkDebugf("\n\n");
|
|
|
|
SkDebugf(" input: Either a directory or a single .skp file.\n");
|
|
|
|
}
|
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
int main(int argc, char *argv[]) {
|
2018-01-24 17:42:55 +00:00
|
|
|
#ifndef SK_BUILD_FOR_WIN
|
2014-11-13 13:13:50 +00:00
|
|
|
// Set numeric formatting to default. Otherwise shaders will have numbers with wrong comma.
|
|
|
|
// QApplication documentation recommends setlocale("LC_NUMERIC", "C") after QApplication
|
|
|
|
// constuction. However, the components Qt calls (X11 libs, ..) will override that.
|
|
|
|
setenv("LC_NUMERIC", "C", 1);
|
|
|
|
#endif
|
2015-01-02 15:24:14 +00:00
|
|
|
SkGraphics::Init();
|
2012-08-07 16:12:23 +00:00
|
|
|
QApplication a(argc, argv);
|
2013-01-28 17:43:26 +00:00
|
|
|
QStringList argList = a.arguments();
|
|
|
|
|
|
|
|
if (argList.count() <= 0) {
|
|
|
|
return -1; // should at least have command name
|
|
|
|
}
|
|
|
|
|
|
|
|
SkString input;
|
|
|
|
|
|
|
|
QStringList::const_iterator iter = argList.begin();
|
|
|
|
|
2013-01-28 19:25:43 +00:00
|
|
|
SkString commandName(iter->toAscii().data());
|
2013-01-28 17:43:26 +00:00
|
|
|
++iter; // skip the command name
|
|
|
|
|
|
|
|
for ( ; iter != argList.end(); ++iter) {
|
|
|
|
if (0 == iter->compare("--help") || 0 == iter->compare("-h")) {
|
|
|
|
usage(commandName.c_str());
|
|
|
|
return -1;
|
|
|
|
} else if (input.isEmpty()) {
|
2013-01-28 19:25:43 +00:00
|
|
|
input = SkString(iter->toAscii().data());
|
2013-01-28 17:43:26 +00:00
|
|
|
} else {
|
|
|
|
usage(commandName.c_str());
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
SkDebuggerGUI w;
|
2013-01-28 17:43:26 +00:00
|
|
|
|
|
|
|
if (!input.isEmpty()) {
|
|
|
|
if (SkStrEndsWith(input.c_str(), ".skp")) {
|
|
|
|
w.openFile(input.c_str());
|
|
|
|
} else {
|
|
|
|
w.setupDirectoryWidget(input.c_str());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-08-07 16:12:23 +00:00
|
|
|
w.show();
|
2015-01-02 15:24:14 +00:00
|
|
|
int result = a.exec();
|
|
|
|
return result;
|
2012-08-07 16:12:23 +00:00
|
|
|
}
|