aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/utils/SkLua.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/utils/SkLua.cpp')
-rw-r--r--src/utils/SkLua.cpp40
1 files changed, 40 insertions, 0 deletions
diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp
index ba311af61c..e80708c71c 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));
@@ -1071,9 +1073,26 @@ static int lpaint_getEffects(lua_State* L) {
setfield_bool_if(L, "shader", !!paint->getShader());
setfield_bool_if(L, "colorFilter", !!paint->getColorFilter());
setfield_bool_if(L, "imageFilter", !!paint->getImageFilter());
+ setfield_bool_if(L, "xfermode", !!paint->getXfermode());
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(sk_ref_sp(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();
@@ -1198,6 +1217,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 },
@@ -1320,6 +1341,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;
@@ -2139,6 +2178,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);