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
This commit is contained in:
commit-bot@chromium.org 2013-06-18 18:35:58 +00:00
parent 29247629b6
commit 3da6c56f14

View File

@ -33,7 +33,7 @@ static const char gSummarizeFunc[] = "sk_scrape_summarize";
// 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 @@ int tool_main(int argc, char** argv) {
}
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 @@ int tool_main(int argc, char** argv) {
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");