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

Unified Diff: src/utils/SkLua.cpp

Issue 648083002: add canvas:clear to lua (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | « resources/slides.lua ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkLua.cpp
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index 578166b2e34fc3c79d784f5572c4d4b56c78dc03..3dbcf8e629c91791628094d57a7c383dea2a002d 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -424,6 +424,11 @@ static SkRect* lua2rect(lua_State* L, int index, SkRect* rect) {
return rect;
}
+static int lcanvas_clear(lua_State* L) {
+ get_ref<SkCanvas>(L, 1)->clear(0);
+ return 0;
+}
+
static int lcanvas_drawColor(lua_State* L) {
get_ref<SkCanvas>(L, 1)->drawColor(lua2color(L, 2));
return 0;
@@ -455,7 +460,7 @@ static SkPaint* lua2OptionalPaint(lua_State* L, int index, SkPaint* paint) {
if (lua_isnumber(L, index)) {
paint->setAlpha(SkScalarRoundToInt(lua2scalar(L, index) * 255));
return paint;
- } else {
+ } else if (lua_isuserdata(L, index)) {
const SkPaint* ptr = get_obj<SkPaint>(L, index);
if (ptr) {
*paint = *ptr;
@@ -623,6 +628,7 @@ static int lcanvas_gc(lua_State* L) {
}
const struct luaL_Reg gSkCanvas_Methods[] = {
+ { "clear", lcanvas_clear },
{ "drawColor", lcanvas_drawColor },
{ "drawRect", lcanvas_drawRect },
{ "drawOval", lcanvas_drawOval },
« no previous file with comments | « resources/slides.lua ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698