OLD | NEW |
---|---|
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 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
156 static void setfield_scalar(lua_State* L, const char key[], SkScalar value) { | 156 static void setfield_scalar(lua_State* L, const char key[], SkScalar value) { |
157 setfield_number(L, key, SkScalarToLua(value)); | 157 setfield_number(L, key, SkScalarToLua(value)); |
158 } | 158 } |
159 | 159 |
160 static void setfield_function(lua_State* L, | 160 static void setfield_function(lua_State* L, |
161 const char key[], lua_CFunction value) { | 161 const char key[], lua_CFunction value) { |
162 lua_pushcfunction(L, value); | 162 lua_pushcfunction(L, value); |
163 lua_setfield(L, -2, key); | 163 lua_setfield(L, -2, key); |
164 } | 164 } |
165 | 165 |
166 static int lua2int_def(lua_State* L, int index, int defaultValue) { | |
167 if (lua_isnumber(L, index)) { | |
168 return (int)lua_tonumber(L, index); | |
169 } else { | |
170 return defaultValue; | |
171 } | |
172 } | |
173 | |
174 static SkScalar lua2scalar(lua_State* L, int index) { | |
175 SkASSERT(lua_isnumber(L, index)); | |
176 return SkLuaToScalar(lua_tonumber(L, index)); | |
177 } | |
178 | |
179 static SkScalar lua2scalar_def(lua_State* L, int index, SkScalar defaultValue) { | |
180 if (lua_isnumber(L, index)) { | |
181 return SkLuaToScalar(lua_tonumber(L, index)); | |
182 } else { | |
183 return defaultValue; | |
184 } | |
185 } | |
186 | |
187 static SkScalar getarray_scalar(lua_State* L, int stackIndex, int arrayIndex) { | |
188 SkASSERT(lua_istable(L, stackIndex)); | |
189 lua_rawgeti(L, stackIndex, arrayIndex); | |
190 | |
191 SkScalar value = lua2scalar(L, -1); | |
192 lua_pop(L, 1); | |
193 return value; | |
194 } | |
195 | |
196 static void getarray_scalars(lua_State* L, int stackIndex, SkScalar dst[], int c ount) { | |
197 for (int i = 0; i < count; ++i) { | |
198 dst[i] = getarray_scalar(L, stackIndex, i + 1); | |
199 } | |
200 } | |
201 | |
202 static void getarray_points(lua_State* L, int stackIndex, SkPoint pts[], int cou nt) { | |
203 getarray_scalars(L, stackIndex, &pts[0].fX, count * 2); | |
204 } | |
205 | |
166 static void setarray_number(lua_State* L, int index, double value) { | 206 static void setarray_number(lua_State* L, int index, double value) { |
167 lua_pushnumber(L, value); | 207 lua_pushnumber(L, value); |
168 lua_rawseti(L, -2, index); | 208 lua_rawseti(L, -2, index); |
169 } | 209 } |
170 | 210 |
171 static void setarray_scalar(lua_State* L, int index, SkScalar value) { | 211 static void setarray_scalar(lua_State* L, int index, SkScalar value) { |
172 setarray_number(L, index, SkScalarToLua(value)); | 212 setarray_number(L, index, SkScalarToLua(value)); |
173 } | 213 } |
174 | 214 |
175 void SkLua::pushBool(bool value, const char key[]) { | 215 void SkLua::pushBool(bool value, const char key[]) { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
353 } | 393 } |
354 this->pushString(region_op(element.getOp()), "op"); | 394 this->pushString(region_op(element.getOp()), "op"); |
355 this->pushBool(element.isAA(), "aa"); | 395 this->pushBool(element.isAA(), "aa"); |
356 CHECK_SETFIELD(key); | 396 CHECK_SETFIELD(key); |
357 } | 397 } |
358 | 398 |
359 | 399 |
360 /////////////////////////////////////////////////////////////////////////////// | 400 /////////////////////////////////////////////////////////////////////////////// |
361 /////////////////////////////////////////////////////////////////////////////// | 401 /////////////////////////////////////////////////////////////////////////////// |
362 | 402 |
363 static int lua2int_def(lua_State* L, int index, int defaultValue) { | |
364 if (lua_isnumber(L, index)) { | |
365 return (int)lua_tonumber(L, index); | |
366 } else { | |
367 return defaultValue; | |
368 } | |
369 } | |
370 | |
371 static SkScalar lua2scalar(lua_State* L, int index) { | |
372 SkASSERT(lua_isnumber(L, index)); | |
373 return SkLuaToScalar(lua_tonumber(L, index)); | |
374 } | |
375 | |
376 static SkScalar lua2scalar_def(lua_State* L, int index, SkScalar defaultValue) { | |
377 if (lua_isnumber(L, index)) { | |
378 return SkLuaToScalar(lua_tonumber(L, index)); | |
379 } else { | |
380 return defaultValue; | |
381 } | |
382 } | |
383 | |
384 static SkScalar getfield_scalar(lua_State* L, int index, const char key[]) { | 403 static SkScalar getfield_scalar(lua_State* L, int index, const char key[]) { |
385 SkASSERT(lua_istable(L, index)); | 404 SkASSERT(lua_istable(L, index)); |
386 lua_pushstring(L, key); | 405 lua_pushstring(L, key); |
387 lua_gettable(L, index); | 406 lua_gettable(L, index); |
388 | 407 |
389 SkScalar value = lua2scalar(L, -1); | 408 SkScalar value = lua2scalar(L, -1); |
390 lua_pop(L, 1); | 409 lua_pop(L, 1); |
391 return value; | 410 return value; |
392 } | 411 } |
393 | 412 |
394 static SkScalar getfield_scalar_default(lua_State* L, int index, const char key[ ], SkScalar def) { | 413 static SkScalar getfield_scalar_default(lua_State* L, int index, const char key[ ], SkScalar def) { |
395 SkASSERT(lua_istable(L, index)); | 414 SkASSERT(lua_istable(L, index)); |
396 lua_pushstring(L, key); | 415 lua_pushstring(L, key); |
397 lua_gettable(L, index); | 416 lua_gettable(L, index); |
398 | 417 |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
445 return 0; | 464 return 0; |
446 } | 465 } |
447 | 466 |
448 static int lcanvas_drawPaint(lua_State* L) { | 467 static int lcanvas_drawPaint(lua_State* L) { |
449 get_ref<SkCanvas>(L, 1)->drawPaint(*get_obj<SkPaint>(L, 2)); | 468 get_ref<SkCanvas>(L, 1)->drawPaint(*get_obj<SkPaint>(L, 2)); |
450 return 0; | 469 return 0; |
451 } | 470 } |
452 | 471 |
453 static int lcanvas_drawRect(lua_State* L) { | 472 static int lcanvas_drawRect(lua_State* L) { |
454 SkRect rect; | 473 SkRect rect; |
455 get_ref<SkCanvas>(L, 1)->drawRect(*lua2rect(L, 2, &rect), | 474 lua2rect(L, 2, &rect); |
456 *get_obj<SkPaint>(L, 3)); | 475 const SkPaint* paint = get_obj<SkPaint>(L, 3); |
476 get_ref<SkCanvas>(L, 1)->drawRect(rect, *paint); | |
457 return 0; | 477 return 0; |
458 } | 478 } |
459 | 479 |
460 static int lcanvas_drawOval(lua_State* L) { | 480 static int lcanvas_drawOval(lua_State* L) { |
461 SkRect rect; | 481 SkRect rect; |
462 get_ref<SkCanvas>(L, 1)->drawOval(*lua2rect(L, 2, &rect), | 482 get_ref<SkCanvas>(L, 1)->drawOval(*lua2rect(L, 2, &rect), |
463 *get_obj<SkPaint>(L, 3)); | 483 *get_obj<SkPaint>(L, 3)); |
464 return 0; | 484 return 0; |
465 } | 485 } |
466 | 486 |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
511 SkRect* srcRPtr = NULL; | 531 SkRect* srcRPtr = NULL; |
512 if (!lua_isnil(L, 3)) { | 532 if (!lua_isnil(L, 3)) { |
513 srcRPtr = lua2rect(L, 3, &srcR); | 533 srcRPtr = lua2rect(L, 3, &srcR); |
514 } | 534 } |
515 lua2rect(L, 4, &dstR); | 535 lua2rect(L, 4, &dstR); |
516 | 536 |
517 SkPaint paint; | 537 SkPaint paint; |
518 canvas->drawImageRect(image, srcRPtr, dstR, lua2OptionalPaint(L, 5, &paint)) ; | 538 canvas->drawImageRect(image, srcRPtr, dstR, lua2OptionalPaint(L, 5, &paint)) ; |
519 return 0; | 539 return 0; |
520 } | 540 } |
521 | 541 |
robertphillips
2014/11/07 18:02:54
needed ?
reed1
2014/11/07 18:12:15
Done.
| |
542 //void drawPatch(const SkPoint cubics[12], const SkColor colors[4], | |
543 // const SkPoint texCoords[4], SkXfermode* xmode, const SkPaint& p aint); | |
544 | |
545 static int lcanvas_drawPatch(lua_State* L) { | |
546 SkPoint cubics[12]; | |
547 SkColor colorStorage[4]; | |
548 SkPoint texStorage[4]; | |
549 | |
550 const SkColor* colors = NULL; | |
551 const SkPoint* texs = NULL; | |
552 | |
553 getarray_points(L, 2, cubics, 12); | |
554 | |
555 colorStorage[0] = SK_ColorRED; | |
556 colorStorage[1] = SK_ColorGREEN; | |
557 colorStorage[2] = SK_ColorBLUE; | |
558 colorStorage[3] = SK_ColorGRAY; | |
559 | |
560 if (lua_isnil(L, 4)) { | |
561 colors = colorStorage; | |
562 } else { | |
563 getarray_points(L, 4, texStorage, 4); | |
564 texs = texStorage; | |
565 } | |
566 | |
567 get_ref<SkCanvas>(L, 1)->drawPatch(cubics, colors, texs, NULL, *get_obj<SkPa int>(L, 5)); | |
568 return 0; | |
569 } | |
570 | |
522 static int lcanvas_drawPath(lua_State* L) { | 571 static int lcanvas_drawPath(lua_State* L) { |
523 get_ref<SkCanvas>(L, 1)->drawPath(*get_obj<SkPath>(L, 2), | 572 get_ref<SkCanvas>(L, 1)->drawPath(*get_obj<SkPath>(L, 2), |
524 *get_obj<SkPaint>(L, 3)); | 573 *get_obj<SkPaint>(L, 3)); |
525 return 0; | 574 return 0; |
526 } | 575 } |
527 | 576 |
528 // drawPicture(pic, x, y, paint) | 577 // drawPicture(pic, x, y, paint) |
529 static int lcanvas_drawPicture(lua_State* L) { | 578 static int lcanvas_drawPicture(lua_State* L) { |
530 SkCanvas* canvas = get_ref<SkCanvas>(L, 1); | 579 SkCanvas* canvas = get_ref<SkCanvas>(L, 1); |
531 SkPicture* picture = get_ref<SkPicture>(L, 2); | 580 SkPicture* picture = get_ref<SkPicture>(L, 2); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
655 return 0; | 704 return 0; |
656 } | 705 } |
657 | 706 |
658 static int lcanvas_concat(lua_State* L) { | 707 static int lcanvas_concat(lua_State* L) { |
659 get_ref<SkCanvas>(L, 1)->concat(*get_obj<SkMatrix>(L, 2)); | 708 get_ref<SkCanvas>(L, 1)->concat(*get_obj<SkMatrix>(L, 2)); |
660 return 0; | 709 return 0; |
661 } | 710 } |
662 | 711 |
663 static int lcanvas_newSurface(lua_State* L) { | 712 static int lcanvas_newSurface(lua_State* L) { |
664 int width = lua2int_def(L, 2, 0); | 713 int width = lua2int_def(L, 2, 0); |
665 int height = lua2int_def(L, 2, 0); | 714 int height = lua2int_def(L, 3, 0); |
666 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); | 715 SkImageInfo info = SkImageInfo::MakeN32Premul(width, height); |
667 SkSurface* surface = get_ref<SkCanvas>(L, 1)->newSurface(info); | 716 SkSurface* surface = get_ref<SkCanvas>(L, 1)->newSurface(info); |
668 if (NULL == surface) { | 717 if (NULL == surface) { |
669 lua_pushnil(L); | 718 lua_pushnil(L); |
670 } else { | 719 } else { |
671 push_ref(L, surface)->unref(); | 720 push_ref(L, surface)->unref(); |
672 } | 721 } |
673 return 1; | 722 return 1; |
674 } | 723 } |
675 | 724 |
676 static int lcanvas_gc(lua_State* L) { | 725 static int lcanvas_gc(lua_State* L) { |
677 get_ref<SkCanvas>(L, 1)->unref(); | 726 get_ref<SkCanvas>(L, 1)->unref(); |
678 return 0; | 727 return 0; |
679 } | 728 } |
680 | 729 |
681 const struct luaL_Reg gSkCanvas_Methods[] = { | 730 const struct luaL_Reg gSkCanvas_Methods[] = { |
682 { "clear", lcanvas_clear }, | 731 { "clear", lcanvas_clear }, |
683 { "drawColor", lcanvas_drawColor }, | 732 { "drawColor", lcanvas_drawColor }, |
684 { "drawPaint", lcanvas_drawPaint }, | 733 { "drawPaint", lcanvas_drawPaint }, |
685 { "drawRect", lcanvas_drawRect }, | 734 { "drawRect", lcanvas_drawRect }, |
686 { "drawOval", lcanvas_drawOval }, | 735 { "drawOval", lcanvas_drawOval }, |
687 { "drawCircle", lcanvas_drawCircle }, | 736 { "drawCircle", lcanvas_drawCircle }, |
688 { "drawImage", lcanvas_drawImage }, | 737 { "drawImage", lcanvas_drawImage }, |
689 { "drawImageRect", lcanvas_drawImageRect }, | 738 { "drawImageRect", lcanvas_drawImageRect }, |
739 { "drawPatch", lcanvas_drawPatch }, | |
690 { "drawPath", lcanvas_drawPath }, | 740 { "drawPath", lcanvas_drawPath }, |
691 { "drawPicture", lcanvas_drawPicture }, | 741 { "drawPicture", lcanvas_drawPicture }, |
692 { "drawText", lcanvas_drawText }, | 742 { "drawText", lcanvas_drawText }, |
693 { "drawTextBlob", lcanvas_drawTextBlob }, | 743 { "drawTextBlob", lcanvas_drawTextBlob }, |
694 { "getSaveCount", lcanvas_getSaveCount }, | 744 { "getSaveCount", lcanvas_getSaveCount }, |
695 { "getTotalMatrix", lcanvas_getTotalMatrix }, | 745 { "getTotalMatrix", lcanvas_getTotalMatrix }, |
696 { "getClipStack", lcanvas_getClipStack }, | 746 { "getClipStack", lcanvas_getClipStack }, |
697 #if SK_SUPPORT_GPU | 747 #if SK_SUPPORT_GPU |
698 { "getReducedClipStack", SkLua::lcanvas_getReducedClipStack }, | 748 { "getReducedClipStack", SkLua::lcanvas_getReducedClipStack }, |
699 #endif | 749 #endif |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
874 static int lpaint_setTypeface(lua_State* L) { | 924 static int lpaint_setTypeface(lua_State* L) { |
875 get_obj<SkPaint>(L, 1)->setTypeface(get_ref<SkTypeface>(L, 2)); | 925 get_obj<SkPaint>(L, 1)->setTypeface(get_ref<SkTypeface>(L, 2)); |
876 return 0; | 926 return 0; |
877 } | 927 } |
878 | 928 |
879 static int lpaint_getHinting(lua_State* L) { | 929 static int lpaint_getHinting(lua_State* L) { |
880 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getHinting()); | 930 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getHinting()); |
881 return 1; | 931 return 1; |
882 } | 932 } |
883 | 933 |
934 static int lpaint_getFilterLevel(lua_State* L) { | |
935 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getFilterLevel()); | |
936 return 1; | |
937 } | |
938 | |
939 static int lpaint_setFilterLevel(lua_State* L) { | |
940 int level = lua2int_def(L, 2, -1); | |
941 if (level >= 0 && level <= 3) { | |
942 get_obj<SkPaint>(L, 1)->setFilterLevel((SkPaint::FilterLevel)level); | |
943 } | |
944 return 0; | |
945 } | |
946 | |
884 static int lpaint_getFontID(lua_State* L) { | 947 static int lpaint_getFontID(lua_State* L) { |
885 SkTypeface* face = get_obj<SkPaint>(L, 1)->getTypeface(); | 948 SkTypeface* face = get_obj<SkPaint>(L, 1)->getTypeface(); |
886 SkLua(L).pushU32(SkTypeface::UniqueID(face)); | 949 SkLua(L).pushU32(SkTypeface::UniqueID(face)); |
887 return 1; | 950 return 1; |
888 } | 951 } |
889 | 952 |
890 static const struct { | 953 static const struct { |
891 const char* fLabel; | 954 const char* fLabel; |
892 SkPaint::Align fAlign; | 955 SkPaint::Align fAlign; |
893 } gAlignRec[] = { | 956 } gAlignRec[] = { |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1065 static int lpaint_gc(lua_State* L) { | 1128 static int lpaint_gc(lua_State* L) { |
1066 get_obj<SkPaint>(L, 1)->~SkPaint(); | 1129 get_obj<SkPaint>(L, 1)->~SkPaint(); |
1067 return 0; | 1130 return 0; |
1068 } | 1131 } |
1069 | 1132 |
1070 static const struct luaL_Reg gSkPaint_Methods[] = { | 1133 static const struct luaL_Reg gSkPaint_Methods[] = { |
1071 { "isAntiAlias", lpaint_isAntiAlias }, | 1134 { "isAntiAlias", lpaint_isAntiAlias }, |
1072 { "setAntiAlias", lpaint_setAntiAlias }, | 1135 { "setAntiAlias", lpaint_setAntiAlias }, |
1073 { "isDither", lpaint_isDither }, | 1136 { "isDither", lpaint_isDither }, |
1074 { "setDither", lpaint_setDither }, | 1137 { "setDither", lpaint_setDither }, |
1138 { "getFilterLevel", lpaint_getFilterLevel }, | |
1139 { "setFilterLevel", lpaint_setFilterLevel }, | |
1075 { "isUnderlineText", lpaint_isUnderlineText }, | 1140 { "isUnderlineText", lpaint_isUnderlineText }, |
1076 { "isStrikeThruText", lpaint_isStrikeThruText }, | 1141 { "isStrikeThruText", lpaint_isStrikeThruText }, |
1077 { "isFakeBoldText", lpaint_isFakeBoldText }, | 1142 { "isFakeBoldText", lpaint_isFakeBoldText }, |
1078 { "isLinearText", lpaint_isLinearText }, | 1143 { "isLinearText", lpaint_isLinearText }, |
1079 { "isSubpixelText", lpaint_isSubpixelText }, | 1144 { "isSubpixelText", lpaint_isSubpixelText }, |
1080 { "setSubpixelText", lpaint_setSubpixelText }, | 1145 { "setSubpixelText", lpaint_setSubpixelText }, |
1081 { "isDevKernText", lpaint_isDevKernText }, | 1146 { "isDevKernText", lpaint_isDevKernText }, |
1082 { "isLCDRenderText", lpaint_isLCDRenderText }, | 1147 { "isLCDRenderText", lpaint_isLCDRenderText }, |
1083 { "setLCDRenderText", lpaint_setLCDRenderText }, | 1148 { "setLCDRenderText", lpaint_setLCDRenderText }, |
1084 { "isEmbeddedBitmapText", lpaint_isEmbeddedBitmapText }, | 1149 { "isEmbeddedBitmapText", lpaint_isEmbeddedBitmapText }, |
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1272 static int lmatrix_getTranslateX(lua_State* L) { | 1337 static int lmatrix_getTranslateX(lua_State* L) { |
1273 lua_pushnumber(L, get_obj<SkMatrix>(L,1)->getTranslateX()); | 1338 lua_pushnumber(L, get_obj<SkMatrix>(L,1)->getTranslateX()); |
1274 return 1; | 1339 return 1; |
1275 } | 1340 } |
1276 | 1341 |
1277 static int lmatrix_getTranslateY(lua_State* L) { | 1342 static int lmatrix_getTranslateY(lua_State* L) { |
1278 lua_pushnumber(L, get_obj<SkMatrix>(L,1)->getTranslateY()); | 1343 lua_pushnumber(L, get_obj<SkMatrix>(L,1)->getTranslateY()); |
1279 return 1; | 1344 return 1; |
1280 } | 1345 } |
1281 | 1346 |
1347 static int lmatrix_invert(lua_State* L) { | |
1348 lua_pushboolean(L, get_obj<SkMatrix>(L, 1)->invert(get_obj<SkMatrix>(L, 2))) ; | |
1349 return 1; | |
1350 } | |
1351 | |
1352 static int lmatrix_mapXY(lua_State* L) { | |
1353 SkPoint pt = { lua2scalar(L, 2), lua2scalar(L, 3) }; | |
1354 get_obj<SkMatrix>(L, 1)->mapPoints(&pt, &pt, 1); | |
1355 lua_pushnumber(L, pt.x()); | |
1356 lua_pushnumber(L, pt.y()); | |
1357 return 2; | |
1358 } | |
1359 | |
1282 static int lmatrix_setRectToRect(lua_State* L) { | 1360 static int lmatrix_setRectToRect(lua_State* L) { |
1283 SkMatrix* matrix = get_obj<SkMatrix>(L, 1); | 1361 SkMatrix* matrix = get_obj<SkMatrix>(L, 1); |
1284 SkRect srcR, dstR; | 1362 SkRect srcR, dstR; |
1285 lua2rect(L, 2, &srcR); | 1363 lua2rect(L, 2, &srcR); |
1286 lua2rect(L, 3, &dstR); | 1364 lua2rect(L, 3, &dstR); |
1287 const char* scaleToFitStr = lua_tostring(L, 4); | 1365 const char* scaleToFitStr = lua_tostring(L, 4); |
1288 SkMatrix::ScaleToFit scaleToFit = SkMatrix::kFill_ScaleToFit; | 1366 SkMatrix::ScaleToFit scaleToFit = SkMatrix::kFill_ScaleToFit; |
1289 | 1367 |
1290 if (scaleToFitStr) { | 1368 if (scaleToFitStr) { |
1291 const struct { | 1369 const struct { |
(...skipping 18 matching lines...) Expand all Loading... | |
1310 return 0; | 1388 return 0; |
1311 } | 1389 } |
1312 | 1390 |
1313 static const struct luaL_Reg gSkMatrix_Methods[] = { | 1391 static const struct luaL_Reg gSkMatrix_Methods[] = { |
1314 { "getType", lmatrix_getType }, | 1392 { "getType", lmatrix_getType }, |
1315 { "getScaleX", lmatrix_getScaleX }, | 1393 { "getScaleX", lmatrix_getScaleX }, |
1316 { "getScaleY", lmatrix_getScaleY }, | 1394 { "getScaleY", lmatrix_getScaleY }, |
1317 { "getTranslateX", lmatrix_getTranslateX }, | 1395 { "getTranslateX", lmatrix_getTranslateX }, |
1318 { "getTranslateY", lmatrix_getTranslateY }, | 1396 { "getTranslateY", lmatrix_getTranslateY }, |
1319 { "setRectToRect", lmatrix_setRectToRect }, | 1397 { "setRectToRect", lmatrix_setRectToRect }, |
1398 { "invert", lmatrix_invert }, | |
1399 { "mapXY", lmatrix_mapXY }, | |
1320 { NULL, NULL } | 1400 { NULL, NULL } |
1321 }; | 1401 }; |
1322 | 1402 |
1323 /////////////////////////////////////////////////////////////////////////////// | 1403 /////////////////////////////////////////////////////////////////////////////// |
1324 | 1404 |
1325 static int lpath_getBounds(lua_State* L) { | 1405 static int lpath_getBounds(lua_State* L) { |
1326 SkLua(L).pushRect(get_obj<SkPath>(L, 1)->getBounds()); | 1406 SkLua(L).pushRect(get_obj<SkPath>(L, 1)->getBounds()); |
1327 return 1; | 1407 return 1; |
1328 } | 1408 } |
1329 | 1409 |
(...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1556 static int limage_width(lua_State* L) { | 1636 static int limage_width(lua_State* L) { |
1557 lua_pushinteger(L, get_ref<SkImage>(L, 1)->width()); | 1637 lua_pushinteger(L, get_ref<SkImage>(L, 1)->width()); |
1558 return 1; | 1638 return 1; |
1559 } | 1639 } |
1560 | 1640 |
1561 static int limage_height(lua_State* L) { | 1641 static int limage_height(lua_State* L) { |
1562 lua_pushinteger(L, get_ref<SkImage>(L, 1)->height()); | 1642 lua_pushinteger(L, get_ref<SkImage>(L, 1)->height()); |
1563 return 1; | 1643 return 1; |
1564 } | 1644 } |
1565 | 1645 |
1646 static int limage_newShader(lua_State* L) { | |
1647 SkShader::TileMode tmode = SkShader::kClamp_TileMode; | |
1648 const SkMatrix* localM = NULL; | |
1649 SkAutoTUnref<SkShader> shader(get_ref<SkImage>(L, 1)->newShader(tmode, tmode , localM)); | |
1650 push_ref(L, shader.get()); | |
1651 return 1; | |
1652 } | |
1653 | |
1566 static int limage_gc(lua_State* L) { | 1654 static int limage_gc(lua_State* L) { |
1567 get_ref<SkImage>(L, 1)->unref(); | 1655 get_ref<SkImage>(L, 1)->unref(); |
1568 return 0; | 1656 return 0; |
1569 } | 1657 } |
1570 | 1658 |
1571 static const struct luaL_Reg gSkImage_Methods[] = { | 1659 static const struct luaL_Reg gSkImage_Methods[] = { |
1572 { "width", limage_width }, | 1660 { "width", limage_width }, |
1573 { "height", limage_height }, | 1661 { "height", limage_height }, |
1662 { "newShader", limage_newShader }, | |
1574 { "__gc", limage_gc }, | 1663 { "__gc", limage_gc }, |
1575 { NULL, NULL } | 1664 { NULL, NULL } |
1576 }; | 1665 }; |
1577 | 1666 |
1578 /////////////////////////////////////////////////////////////////////////////// | 1667 /////////////////////////////////////////////////////////////////////////////// |
1579 | 1668 |
1580 static int lsurface_width(lua_State* L) { | 1669 static int lsurface_width(lua_State* L) { |
1581 lua_pushinteger(L, get_ref<SkSurface>(L, 1)->width()); | 1670 lua_pushinteger(L, get_ref<SkSurface>(L, 1)->width()); |
1582 return 1; | 1671 return 1; |
1583 } | 1672 } |
(...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1982 REG_CLASS(L, SkSurface); | 2071 REG_CLASS(L, SkSurface); |
1983 REG_CLASS(L, SkTextBlob); | 2072 REG_CLASS(L, SkTextBlob); |
1984 REG_CLASS(L, SkTypeface); | 2073 REG_CLASS(L, SkTypeface); |
1985 } | 2074 } |
1986 | 2075 |
1987 extern "C" int luaopen_skia(lua_State* L); | 2076 extern "C" int luaopen_skia(lua_State* L); |
1988 extern "C" int luaopen_skia(lua_State* L) { | 2077 extern "C" int luaopen_skia(lua_State* L) { |
1989 SkLua::Load(L); | 2078 SkLua::Load(L); |
1990 return 0; | 2079 return 0; |
1991 } | 2080 } |
OLD | NEW |