Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(598)

Unified Diff: tools/lua/lua_pictures.cpp

Issue 15511006: add startcanvas/endcanvas entry-points for the script. rename all "official" entry-points to use "s… (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | tools/lua/scrape.lua » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/lua/lua_pictures.cpp
diff --git a/tools/lua/lua_pictures.cpp b/tools/lua/lua_pictures.cpp
index 36e8c93bf168caf67425d2b9dfdaaf442d8cc26a..1314c699d4ddc57969c3c56d006b5af603143bbe 100644
--- a/tools/lua/lua_pictures.cpp
+++ b/tools/lua/lua_pictures.cpp
@@ -21,6 +21,11 @@ extern "C" {
#include "lauxlib.h"
}
+static const char gStartCanvasFunc[] = "sk_scrape_startcanvas";
+static const char gEndCanvasFunc[] = "sk_scrape_endcanvas";
+static const char gAccumulateFunc[] = "sk_scrape_accumulate";
+static const char gSummarizeFunc[] = "sk_scrape_summarize";
+
// PictureRenderingFlags.cpp
extern bool lazy_decode_bitmap(const void* buffer, size_t size, SkBitmap*);
@@ -99,15 +104,17 @@ private:
SkString fTermCode;
};
-static void call_setcanvas(lua_State* L, SkLuaCanvas* canvas) {
- lua_getglobal(L, "setcanvas");
+static void call_canvas(lua_State* L, SkLuaCanvas* canvas,
+ const char pictureFile[], const char funcName[]) {
+ lua_getglobal(L, funcName);
if (!lua_isfunction(L, -1)) {
int t = lua_type(L, -1);
- SkDebugf("--- expected setcanvas function %d\n", t);
+ SkDebugf("--- expected %s function %d, ignoring.\n", funcName, t);
lua_settop(L, -2);
} else {
canvas->pushThis();
- if (lua_pcall(L, 1, 0, 0) != LUA_OK) {
+ lua_pushstring(L, pictureFile);
+ if (lua_pcall(L, 2, 0, 0) != LUA_OK) {
SkDebugf("lua err: %s\n", lua_tostring(L, -1));
}
}
@@ -128,7 +135,7 @@ int tool_main(int argc, char** argv) {
}
SkAutoGraphics ag;
- SkAutoLua L("summarize");
+ SkAutoLua L(gSummarizeFunc);
for (int i = 0; i < FLAGS_luaFile.count(); ++i) {
SkAutoDataUnref data(read_into_data(FLAGS_luaFile[i]));
@@ -153,11 +160,14 @@ int tool_main(int argc, char** argv) {
SkAutoTUnref<SkPicture> pic(load_picture(path));
if (pic.get()) {
- SkAutoTUnref<SkLuaCanvas> canvas(new SkLuaCanvas(pic->width(), pic->height(), L.get(), "accumulate"));
-
- call_setcanvas(L.get(), canvas.get());
+ SkAutoTUnref<SkLuaCanvas> canvas(
+ new SkLuaCanvas(pic->width(), pic->height(),
+ L.get(), gAccumulateFunc));
+ call_canvas(L.get(), canvas.get(), inputFilename.c_str(), gStartCanvasFunc);
canvas->drawPicture(*pic);
+ call_canvas(L.get(), canvas.get(), inputFilename.c_str(), gEndCanvasFunc);
+
} else {
SkDebugf("failed to load\n");
}
« no previous file with comments | « no previous file | tools/lua/scrape.lua » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698