Allow files, making ".skp files or directories are required." less of a lie.
BUG=
R=reed@google.com
Author: mtklein@google.com
Review URL: https://chromiumcodereview.appspot.com/17151008
git-svn-id: http://skia.googlecode.com/svn/trunk@9665 2bbb7eff-a529-9590-31e7-b0007b416f81
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index be66a78..106948a 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -33,7 +33,7 @@
// PictureRenderingFlags.cpp
extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap*);
-DEFINE_string2(skpPath, r, "", "Read .skp files from this dir");
+DEFINE_string2(skpPath, r, "", "Read this .skp file or .skp files from this dir");
DEFINE_string2(luaFile, l, "", "File containing lua script to run");
DEFINE_string2(headCode, s, "", "Optional lua code to call at beginning");
DEFINE_string2(tailFunc, s, "", "Optional lua function to call at end");
@@ -116,15 +116,22 @@
}
for (int i = 0; i < FLAGS_skpPath.count(); i ++) {
- SkOSFile::Iter iter(FLAGS_skpPath[i], "skp");
- SkString inputFilename;
+ SkTArray<SkString> paths;
+ if (sk_isdir(FLAGS_skpPath[i])) {
+ // Add all .skp in this directory.
+ const SkString directory(FLAGS_skpPath[i]);
+ SkString filename;
+ SkOSFile::Iter iter(FLAGS_skpPath[i], "skp");
+ while(iter.next(&filename)) {
+ sk_tools::make_filepath(&paths.push_back(), directory, filename);
+ }
+ } else {
+ // Add this as an .skp itself.
+ paths.push_back() = FLAGS_skpPath[i];
+ }
- while (iter.next(&inputFilename)) {
- SkString inputPath;
- SkString inputAsSkString(FLAGS_skpPath[i]);
- sk_tools::make_filepath(&inputPath, inputAsSkString, inputFilename);
-
- const char* path = inputPath.c_str();
+ for (int i = 0; i < paths.count(); i++) {
+ const char* path = paths[i].c_str();
SkDebugf("scraping %s\n", path);
SkAutoTUnref<SkPicture> pic(load_picture(path));
@@ -133,9 +140,9 @@
new SkLuaCanvas(pic->width(), pic->height(),
L.get(), gAccumulateFunc));
- call_canvas(L.get(), canvas.get(), inputFilename.c_str(), gStartCanvasFunc);
+ call_canvas(L.get(), canvas.get(), path, gStartCanvasFunc);
canvas->drawPicture(*pic);
- call_canvas(L.get(), canvas.get(), inputFilename.c_str(), gEndCanvasFunc);
+ call_canvas(L.get(), canvas.get(), path, gEndCanvasFunc);
} else {
SkDebugf("failed to load\n");