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

Unified Diff: src/utils/SkLua.cpp

Issue 109793010: Prevent crash in Lua bindings. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years 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 | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/utils/SkLua.cpp
===================================================================
--- src/utils/SkLua.cpp (revision 12711)
+++ 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)
@@ -491,6 +493,16 @@
return 1;
}
+static int lpaint_getTextScaleX(lua_State* L) {
+ SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getTextScaleX());
+ return 1;
+}
+
+static int lpaint_getTextSkewX(lua_State* L) {
+ SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getTextSkewX());
+ return 1;
+}
+
static int lpaint_setTextSize(lua_State* L) {
get_obj<SkPaint>(L, 1)->setTextSize(lua2scalar(L, 2));
return 0;
@@ -574,6 +586,11 @@
return 0;
}
+static int lpaint_getStrokeMiter(lua_State* L) {
+ SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getStrokeMiter());
+ return 1;
+}
+
static int lpaint_measureText(lua_State* L) {
if (lua_isstring(L, 2)) {
size_t len;
@@ -635,6 +652,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;
@@ -647,6 +674,8 @@
{ "setColor", lpaint_setColor },
{ "getTextSize", lpaint_getTextSize },
{ "setTextSize", lpaint_setTextSize },
+ { "getTextScaleX", lpaint_getTextScaleX },
+ { "getTextSkewX", lpaint_getTextSkewX },
{ "getTypeface", lpaint_getTypeface },
{ "setTypeface", lpaint_setTypeface },
{ "getFontID", lpaint_getFontID },
@@ -656,10 +685,12 @@
{ "setStroke", lpaint_setStroke },
{ "getStrokeWidth", lpaint_getStrokeWidth },
{ "setStrokeWidth", lpaint_setStrokeWidth },
+ { "getStrokeMiter", lpaint_getStrokeMiter },
{ "measureText", lpaint_measureText },
{ "getFontMetrics", lpaint_getFontMetrics },
{ "getEffects", lpaint_getEffects },
{ "getShader", lpaint_getShader },
+ { "getAnnotation", lpaint_getAnnotation },
{ "__gc", lpaint_gc },
{ NULL, NULL }
};
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698