Index: src/utils/SkLua.cpp |
=================================================================== |
--- src/utils/SkLua.cpp (revision 12703) |
+++ src/utils/SkLua.cpp (working copy) |
@@ -6,6 +6,7 @@ |
*/ |
#include "SkLua.h" |
+#include "SkAnnotation.h" |
#include "SkCanvas.h" |
#include "SkData.h" |
#include "SkDocument.h" |
@@ -31,6 +32,7 @@ |
return #T "_LuaMetaTableName"; \ |
} |
+DEF_MTNAME(SkAnnotation) |
DEF_MTNAME(SkCanvas) |
DEF_MTNAME(SkDocument) |
DEF_MTNAME(SkImage) |
@@ -56,7 +58,7 @@ |
} |
template <typename T> void push_ref(lua_State* L, T* ref) { |
- *(T**)lua_newuserdata(L, sizeof(T*)) = SkRef(ref); |
+ *(T**)lua_newuserdata(L, sizeof(T*)) = SkSafeRef(ref); |
luaL_getmetatable(L, get_mtname<T>()); |
lua_setmetatable(L, -2); |
} |
@@ -635,6 +637,16 @@ |
return 0; |
} |
+static int lpaint_getAnnotation(lua_State* L) { |
+ const SkPaint* paint = get_obj<SkPaint>(L, 1); |
+ SkAnnotation* annotation = paint->getAnnotation(); |
+ if (annotation) { |
+ push_ref(L, annotation); |
+ return 1; |
+ } |
+ return 0; |
+} |
+ |
static int lpaint_gc(lua_State* L) { |
get_obj<SkPaint>(L, 1)->~SkPaint(); |
return 0; |
@@ -660,6 +672,7 @@ |
{ "getFontMetrics", lpaint_getFontMetrics }, |
{ "getEffects", lpaint_getEffects }, |
{ "getShader", lpaint_getShader }, |
+ { "getAnnotation", lpaint_getAnnotation }, |
{ "__gc", lpaint_gc }, |
{ NULL, NULL } |
}; |
@@ -974,7 +987,7 @@ |
/////////////////////////////////////////////////////////////////////////////// |
static int ltypeface_gc(lua_State* L) { |
- get_ref<SkTypeface>(L, 1)->unref(); |
+ SkSafeUnref(get_ref<SkTypeface>(L, 1)); |
reed1
2013/12/17 16:31:50
I believe you, but this just seems wrong. If we ha
|
return 0; |
} |