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

Unified Diff: src/utils/SkLua.cpp

Issue 267423006: Add asADash to Lua for scraping (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: add pushDash Created 6 years, 7 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') | no next file » | 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 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 }
};
« no previous file with comments | « include/utils/SkLua.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698