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

Side by Side Diff: src/utils/SkLuaCanvas.cpp

Issue 15742009: expand SkLua to handle creation of its own State (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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLuaCanvas.h" 8 #include "SkLuaCanvas.h"
9 #include "SkLua.h" 9 #include "SkLua.h"
10 10
11 extern "C" { 11 extern "C" {
12 #include "lua.h" 12 #include "lua.h"
13 #include "lauxlib.h" 13 #include "lauxlib.h"
14 } 14 }
15 15
16 class AutoCallLua : public SkLua { 16 class AutoCallLua : public SkLua {
17 public: 17 public:
18 AutoCallLua(lua_State* L, const char func[], const char verb[]) : INHERITED( L) { 18 AutoCallLua(lua_State* L, const char func[], const char verb[]) : INHERITED( L) {
19 lua_getglobal(L, func); 19 lua_getglobal(L, func);
20 if (!lua_isfunction(L, -1)) { 20 if (!lua_isfunction(L, -1)) {
21 int t = lua_type(L, -1); 21 int t = lua_type(L, -1);
22 SkDebugf("--- expected function %d\n", t); 22 SkDebugf("--- expected function %d\n", t);
23 } 23 }
24 24
25 lua_newtable(L); 25 lua_newtable(L);
26 this->pushString(verb, "verb"); 26 this->pushString(verb, "verb");
27 } 27 }
28 28
29 ~AutoCallLua() { 29 ~AutoCallLua() {
30 lua_State* L = this->getL(); 30 lua_State* L = this->get();
31 if (lua_pcall(L, 1, 0, 0) != LUA_OK) { 31 if (lua_pcall(L, 1, 0, 0) != LUA_OK) {
32 SkDebugf("lua err: %s\n", lua_tostring(L, -1)); 32 SkDebugf("lua err: %s\n", lua_tostring(L, -1));
33 } 33 }
34 lua_settop(L, -1); 34 lua_settop(L, -1);
35 } 35 }
36 36
37 private: 37 private:
38 typedef SkLua INHERITED; 38 typedef SkLua INHERITED;
39 }; 39 };
40 40
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after
251 const SkColor colors[], SkXfermode* xmode, 251 const SkColor colors[], SkXfermode* xmode,
252 const uint16_t indices[], int indexCount, 252 const uint16_t indices[], int indexCount,
253 const SkPaint& paint) { 253 const SkPaint& paint) {
254 AUTO_LUA("drawVertices"); 254 AUTO_LUA("drawVertices");
255 lua.pushPaint(paint, "paint"); 255 lua.pushPaint(paint, "paint");
256 } 256 }
257 257
258 void SkLuaCanvas::drawData(const void* data, size_t length) { 258 void SkLuaCanvas::drawData(const void* data, size_t length) {
259 AUTO_LUA("drawData"); 259 AUTO_LUA("drawData");
260 } 260 }
OLDNEW
« samplecode/SampleLua.cpp ('K') | « src/utils/SkLua.cpp ('k') | tools/lua/lua_pictures.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698