Chromium Code Reviews| Index: src/utils/SkLua.cpp |
| diff --git a/src/utils/SkLua.cpp b/src/utils/SkLua.cpp |
| index 346899a5dde785b0e00fd233aa1df8df494b7c06..bbf6cfaabfe52aba3112ca0856c3a7173feafc80 100644 |
| --- a/src/utils/SkLua.cpp |
| +++ b/src/utils/SkLua.cpp |
| @@ -18,7 +18,6 @@ |
| #include "SkMatrix.h" |
| #include "SkPaint.h" |
| #include "SkPath.h" |
| -#include "SkPathEffect.h" |
| #include "SkPixelRef.h" |
| #include "SkRRect.h" |
| #include "SkString.h" |
| @@ -233,6 +232,14 @@ void SkLua::pushRRect(const SkRRect& rr, const char key[]) { |
| CHECK_SETFIELD(key); |
| } |
| +void SkLua::pushDash(const SkPathEffect::DashInfo& info, const char key[]) { |
| + lua_newtable(fL); |
| + setfield_scalar(fL, "fCount", info.fCount); |
| + setfield_scalar(fL, "fPhase", info.fPhase); |
| + CHECK_SETFIELD(key); |
| +} |
| + |
| + |
| void SkLua::pushMatrix(const SkMatrix& matrix, const char key[]) { |
| push_obj(fL, matrix); |
| CHECK_SETFIELD(key); |
| @@ -1006,12 +1013,29 @@ static const struct luaL_Reg gSkShader_Methods[] = { |
| /////////////////////////////////////////////////////////////////////////////// |
| +static int lpatheffect_asADash(lua_State* L) { |
| + SkPathEffect* pe = get_ref<SkPathEffect>(L, 1); |
|
robertphillips
2014/05/14 14:01:35
NULL != ?
|
| + if (pe) { |
| + SkPathEffect::DashInfo info; |
| + SkPathEffect::DashType dashType = pe->asADash(&info); |
| + if (SkPathEffect::kDash_DashType == dashType) { |
| + SkAutoTArray<SkScalar> intervals(info.fCount); |
| + info.fIntervals = intervals.get(); |
| + pe->asADash(&info); |
| + SkLua(L).pushDash(info); |
| + return 1; |
| + } |
| + } |
| + return 0; |
| +} |
| + |
| static int lpatheffect_gc(lua_State* L) { |
| get_ref<SkPathEffect>(L, 1)->unref(); |
| return 0; |
| } |
| static const struct luaL_Reg gSkPathEffect_Methods[] = { |
| + { "asADash", lpatheffect_asADash }, |
| { "__gc", lpatheffect_gc }, |
| { NULL, NULL } |
| }; |