Index: src/utils/SkLua.cpp |
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp |
index d85fb91a033a4164046f934e7b6e1f2dbb8232eb..edd336afdf04c5867e6fe512cf67121932013083 100644 |
--- a/src/utils/SkLua.cpp |
+++ b/src/utils/SkLua.cpp |
@@ -28,6 +28,7 @@ |
#include "SkSurface.h" |
#include "SkTextBlob.h" |
#include "SkTypeface.h" |
+#include "SkXfermode.h" |
extern "C" { |
#include "lua.h" |
@@ -58,6 +59,7 @@ DEF_MTNAME(SkShader) |
DEF_MTNAME(SkSurface) |
DEF_MTNAME(SkTextBlob) |
DEF_MTNAME(SkTypeface) |
+DEF_MTNAME(SkXfermode) |
template <typename T> T* push_new(lua_State* L) { |
T* addr = (T*)lua_newuserdata(L, sizeof(T)); |
@@ -1081,6 +1083,22 @@ static int lpaint_getEffects(lua_State* L) { |
return 1; |
} |
+static int lpaint_getXfermode(lua_State* L) { |
+ const SkPaint* paint = get_obj<SkPaint>(L, 1); |
+ SkXfermode* xfermode = paint->getXfermode(); |
+ if (xfermode) { |
+ push_ref(L, xfermode); |
+ return 1; |
+ } |
+ return 0; |
+} |
+ |
+static int lpaint_setXfermode(lua_State* L) { |
+ SkPaint* paint = get_obj<SkPaint>(L, 1); |
+ paint->setXfermode(get_ref<SkXfermode>(L, 2)); |
+ return 0; |
+} |
+ |
static int lpaint_getColorFilter(lua_State* L) { |
const SkPaint* paint = get_obj<SkPaint>(L, 1); |
SkColorFilter* cf = paint->getColorFilter(); |
@@ -1192,6 +1210,8 @@ static const struct luaL_Reg gSkPaint_Methods[] = { |
{ "setColorFilter", lpaint_setColorFilter }, |
{ "getImageFilter", lpaint_getImageFilter }, |
{ "setImageFilter", lpaint_setImageFilter }, |
+ { "getXfermode", lpaint_getXfermode }, |
+ { "setXfermode", lpaint_setXfermode }, |
{ "getShader", lpaint_getShader }, |
{ "setShader", lpaint_setShader }, |
{ "getPathEffect", lpaint_getPathEffect }, |
@@ -1314,6 +1334,24 @@ static const struct luaL_Reg gSkPathEffect_Methods[] = { |
/////////////////////////////////////////////////////////////////////////////// |
+static int lpxfermode_getTypeName(lua_State* L) { |
+ lua_pushstring(L, get_ref<SkXfermode>(L, 1)->getTypeName()); |
+ return 1; |
+} |
+ |
+static int lpxfermode_gc(lua_State* L) { |
+ get_ref<SkXfermode>(L, 1)->unref(); |
+ return 0; |
+} |
+ |
+static const struct luaL_Reg gSkXfermode_Methods[] = { |
+ { "getTypeName", lpxfermode_getTypeName }, |
+ { "__gc", lpxfermode_gc }, |
+ { nullptr, nullptr } |
+}; |
+ |
+/////////////////////////////////////////////////////////////////////////////// |
+ |
static int lpcolorfilter_gc(lua_State* L) { |
get_ref<SkColorFilter>(L, 1)->unref(); |
return 0; |
@@ -2095,6 +2133,7 @@ void SkLua::Load(lua_State* L) { |
REG_CLASS(L, SkSurface); |
REG_CLASS(L, SkTextBlob); |
REG_CLASS(L, SkTypeface); |
+ REG_CLASS(L, SkXfermode); |
} |
extern "C" int luaopen_skia(lua_State* L); |