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

Unified Diff: src/utils/SkLua.cpp

Issue 196603027: add initial scraper for dashing (Closed) Base URL: https://skia.googlecode.com/svn/trunk
Patch Set: rename pushArray to pushArrayPoint Created 6 years, 9 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 | « include/utils/SkLua.h ('k') | src/utils/SkLuaCanvas.cpp » ('j') | 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 44f2211b8f4f37253678a44d120fb0f9885d32df..346899a5dde785b0e00fd233aa1df8df494b7c06 100644
--- a/src/utils/SkLua.cpp
+++ b/src/utils/SkLua.cpp
@@ -18,6 +18,7 @@
#include "SkMatrix.h"
#include "SkPaint.h"
#include "SkPath.h"
+#include "SkPathEffect.h"
#include "SkPixelRef.h"
#include "SkRRect.h"
#include "SkString.h"
@@ -43,6 +44,7 @@ DEF_MTNAME(SkMatrix)
DEF_MTNAME(SkRRect)
DEF_MTNAME(SkPath)
DEF_MTNAME(SkPaint)
+DEF_MTNAME(SkPathEffect)
DEF_MTNAME(SkShader)
DEF_MTNAME(SkTypeface)
@@ -205,6 +207,18 @@ void SkLua::pushArrayU16(const uint16_t array[], int count, const char key[]) {
CHECK_SETFIELD(key);
}
+void SkLua::pushArrayPoint(const SkPoint array[], int count, const char key[]) {
+ lua_newtable(fL);
+ for (int i = 0; i < count; ++i) {
+ // make it base-1 to match lua convention
+ lua_newtable(fL);
+ this->pushScalar(array[i].fX, "x");
+ this->pushScalar(array[i].fY, "y");
+ lua_rawseti(fL, -2, i + 1);
+ }
+ CHECK_SETFIELD(key);
+}
+
void SkLua::pushRect(const SkRect& r, const char key[]) {
lua_newtable(fL);
setfield_scalar(fL, "left", r.fLeft);
@@ -845,6 +859,16 @@ static int lpaint_getShader(lua_State* L) {
return 0;
}
+static int lpaint_getPathEffect(lua_State* L) {
+ const SkPaint* paint = get_obj<SkPaint>(L, 1);
+ SkPathEffect* pe = paint->getPathEffect();
+ if (pe) {
+ push_ref(L, pe);
+ return 1;
+ }
+ return 0;
+}
+
static int lpaint_gc(lua_State* L) {
get_obj<SkPaint>(L, 1)->~SkPaint();
return 0;
@@ -888,6 +912,7 @@ static const struct luaL_Reg gSkPaint_Methods[] = {
{ "getFontMetrics", lpaint_getFontMetrics },
{ "getEffects", lpaint_getEffects },
{ "getShader", lpaint_getShader },
+ { "getPathEffect", lpaint_getPathEffect },
{ "__gc", lpaint_gc },
{ NULL, NULL }
};
@@ -981,6 +1006,18 @@ static const struct luaL_Reg gSkShader_Methods[] = {
///////////////////////////////////////////////////////////////////////////////
+static int lpatheffect_gc(lua_State* L) {
+ get_ref<SkPathEffect>(L, 1)->unref();
+ return 0;
+}
+
+static const struct luaL_Reg gSkPathEffect_Methods[] = {
+ { "__gc", lpatheffect_gc },
+ { NULL, NULL }
+};
+
+///////////////////////////////////////////////////////////////////////////////
+
static int lmatrix_getType(lua_State* L) {
SkMatrix::TypeMask mask = get_obj<SkMatrix>(L, 1)->getType();
@@ -1419,8 +1456,9 @@ void SkLua::Load(lua_State* L) {
REG_CLASS(L, SkCanvas);
REG_CLASS(L, SkDocument);
REG_CLASS(L, SkImage);
- REG_CLASS(L, SkPath);
REG_CLASS(L, SkPaint);
+ REG_CLASS(L, SkPath);
+ REG_CLASS(L, SkPathEffect);
REG_CLASS(L, SkRRect);
REG_CLASS(L, SkShader);
REG_CLASS(L, SkTypeface);
« no previous file with comments | « include/utils/SkLua.h ('k') | src/utils/SkLuaCanvas.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698