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

Side by Side 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 unified diff | Download patch
« no previous file with comments | « include/utils/SkLua.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright 2013 Google Inc. 2 * Copyright 2013 Google Inc.
3 * 3 *
4 * Use of this source code is governed by a BSD-style license that can be 4 * Use of this source code is governed by a BSD-style license that can be
5 * found in the LICENSE file. 5 * found in the LICENSE file.
6 */ 6 */
7 7
8 #include "SkLua.h" 8 #include "SkLua.h"
9 9
10 #if SK_SUPPORT_GPU 10 #if SK_SUPPORT_GPU
11 #include "GrReducedClip.h" 11 #include "GrReducedClip.h"
12 #endif 12 #endif
13 13
14 #include "SkCanvas.h" 14 #include "SkCanvas.h"
15 #include "SkData.h" 15 #include "SkData.h"
16 #include "SkDocument.h" 16 #include "SkDocument.h"
17 #include "SkImage.h" 17 #include "SkImage.h"
18 #include "SkMatrix.h" 18 #include "SkMatrix.h"
19 #include "SkPaint.h" 19 #include "SkPaint.h"
20 #include "SkPath.h" 20 #include "SkPath.h"
21 #include "SkPathEffect.h"
22 #include "SkPixelRef.h" 21 #include "SkPixelRef.h"
23 #include "SkRRect.h" 22 #include "SkRRect.h"
24 #include "SkString.h" 23 #include "SkString.h"
25 #include "SkTypeface.h" 24 #include "SkTypeface.h"
26 25
27 extern "C" { 26 extern "C" {
28 #include "lua.h" 27 #include "lua.h"
29 #include "lualib.h" 28 #include "lualib.h"
30 #include "lauxlib.h" 29 #include "lauxlib.h"
31 } 30 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 setfield_scalar(fL, "right", r.fRight); 225 setfield_scalar(fL, "right", r.fRight);
227 setfield_scalar(fL, "bottom", r.fBottom); 226 setfield_scalar(fL, "bottom", r.fBottom);
228 CHECK_SETFIELD(key); 227 CHECK_SETFIELD(key);
229 } 228 }
230 229
231 void SkLua::pushRRect(const SkRRect& rr, const char key[]) { 230 void SkLua::pushRRect(const SkRRect& rr, const char key[]) {
232 push_obj(fL, rr); 231 push_obj(fL, rr);
233 CHECK_SETFIELD(key); 232 CHECK_SETFIELD(key);
234 } 233 }
235 234
235 void SkLua::pushDash(const SkPathEffect::DashInfo& info, const char key[]) {
236 lua_newtable(fL);
237 setfield_scalar(fL, "fCount", info.fCount);
238 setfield_scalar(fL, "fPhase", info.fPhase);
239 CHECK_SETFIELD(key);
240 }
241
242
236 void SkLua::pushMatrix(const SkMatrix& matrix, const char key[]) { 243 void SkLua::pushMatrix(const SkMatrix& matrix, const char key[]) {
237 push_obj(fL, matrix); 244 push_obj(fL, matrix);
238 CHECK_SETFIELD(key); 245 CHECK_SETFIELD(key);
239 } 246 }
240 247
241 void SkLua::pushPaint(const SkPaint& paint, const char key[]) { 248 void SkLua::pushPaint(const SkPaint& paint, const char key[]) {
242 push_obj(fL, paint); 249 push_obj(fL, paint);
243 CHECK_SETFIELD(key); 250 CHECK_SETFIELD(key);
244 } 251 }
245 252
(...skipping 753 matching lines...) Expand 10 before | Expand all | Expand 10 after
999 static const struct luaL_Reg gSkShader_Methods[] = { 1006 static const struct luaL_Reg gSkShader_Methods[] = {
1000 { "isOpaque", lshader_isOpaque }, 1007 { "isOpaque", lshader_isOpaque },
1001 { "asABitmap", lshader_asABitmap }, 1008 { "asABitmap", lshader_asABitmap },
1002 { "asAGradient", lshader_asAGradient }, 1009 { "asAGradient", lshader_asAGradient },
1003 { "__gc", lshader_gc }, 1010 { "__gc", lshader_gc },
1004 { NULL, NULL } 1011 { NULL, NULL }
1005 }; 1012 };
1006 1013
1007 /////////////////////////////////////////////////////////////////////////////// 1014 ///////////////////////////////////////////////////////////////////////////////
1008 1015
1016 static int lpatheffect_asADash(lua_State* L) {
1017 SkPathEffect* pe = get_ref<SkPathEffect>(L, 1);
robertphillips 2014/05/14 14:01:35 NULL != ?
1018 if (pe) {
1019 SkPathEffect::DashInfo info;
1020 SkPathEffect::DashType dashType = pe->asADash(&info);
1021 if (SkPathEffect::kDash_DashType == dashType) {
1022 SkAutoTArray<SkScalar> intervals(info.fCount);
1023 info.fIntervals = intervals.get();
1024 pe->asADash(&info);
1025 SkLua(L).pushDash(info);
1026 return 1;
1027 }
1028 }
1029 return 0;
1030 }
1031
1009 static int lpatheffect_gc(lua_State* L) { 1032 static int lpatheffect_gc(lua_State* L) {
1010 get_ref<SkPathEffect>(L, 1)->unref(); 1033 get_ref<SkPathEffect>(L, 1)->unref();
1011 return 0; 1034 return 0;
1012 } 1035 }
1013 1036
1014 static const struct luaL_Reg gSkPathEffect_Methods[] = { 1037 static const struct luaL_Reg gSkPathEffect_Methods[] = {
1038 { "asADash", lpatheffect_asADash },
1015 { "__gc", lpatheffect_gc }, 1039 { "__gc", lpatheffect_gc },
1016 { NULL, NULL } 1040 { NULL, NULL }
1017 }; 1041 };
1018 1042
1019 /////////////////////////////////////////////////////////////////////////////// 1043 ///////////////////////////////////////////////////////////////////////////////
1020 1044
1021 static int lmatrix_getType(lua_State* L) { 1045 static int lmatrix_getType(lua_State* L) {
1022 SkMatrix::TypeMask mask = get_obj<SkMatrix>(L, 1)->getType(); 1046 SkMatrix::TypeMask mask = get_obj<SkMatrix>(L, 1)->getType();
1023 1047
1024 lua_newtable(L); 1048 lua_newtable(L);
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 REG_CLASS(L, SkShader); 1487 REG_CLASS(L, SkShader);
1464 REG_CLASS(L, SkTypeface); 1488 REG_CLASS(L, SkTypeface);
1465 REG_CLASS(L, SkMatrix); 1489 REG_CLASS(L, SkMatrix);
1466 } 1490 }
1467 1491
1468 extern "C" int luaopen_skia(lua_State* L); 1492 extern "C" int luaopen_skia(lua_State* L);
1469 extern "C" int luaopen_skia(lua_State* L) { 1493 extern "C" int luaopen_skia(lua_State* L) {
1470 SkLua::Load(L); 1494 SkLua::Load(L);
1471 return 0; 1495 return 0;
1472 } 1496 }
OLDNEW
« 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