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

Side by Side Diff: src/utils/SkLua.cpp

Issue 105143009: Expose more SkPaint fields in Lua API. (Closed) Base URL: http://skia.googlecode.com/svn/trunk/
Patch Set: Created 7 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | 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 #include "SkCanvas.h" 9 #include "SkCanvas.h"
10 #include "SkData.h" 10 #include "SkData.h"
(...skipping 458 matching lines...) Expand 10 before | Expand all | Expand 10 after
469 static int lpaint_isAntiAlias(lua_State* L) { 469 static int lpaint_isAntiAlias(lua_State* L) {
470 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isAntiAlias()); 470 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isAntiAlias());
471 return 1; 471 return 1;
472 } 472 }
473 473
474 static int lpaint_setAntiAlias(lua_State* L) { 474 static int lpaint_setAntiAlias(lua_State* L) {
475 get_obj<SkPaint>(L, 1)->setAntiAlias(lua2bool(L, 2)); 475 get_obj<SkPaint>(L, 1)->setAntiAlias(lua2bool(L, 2));
476 return 0; 476 return 0;
477 } 477 }
478 478
479 static int lpaint_isDither(lua_State* L) {
480 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isDither());
481 return 1;
482 }
483
484 static int lpaint_isUnderlineText(lua_State* L) {
485 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isUnderlineText());
486 return 1;
487 }
488
489 static int lpaint_isStrikeThruText(lua_State* L) {
490 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isStrikeThruText());
491 return 1;
492 }
493
494 static int lpaint_isFakeBoldText(lua_State* L) {
495 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isFakeBoldText());
496 return 1;
497 }
498
499 static int lpaint_isLinearText(lua_State* L) {
500 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isLinearText());
501 return 1;
502 }
503
504 static int lpaint_isSubpixelText(lua_State* L) {
505 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isSubpixelText());
506 return 1;
507 }
508
509 static int lpaint_isDevKernText(lua_State* L) {
510 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isDevKernText());
511 return 1;
512 }
513
514 static int lpaint_isLCDRenderText(lua_State* L) {
515 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isLCDRenderText());
516 return 1;
517 }
518
519 static int lpaint_isEmbeddedBitmapText(lua_State* L) {
520 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isEmbeddedBitmapText());
521 return 1;
522 }
523
524 static int lpaint_isAutohinted(lua_State* L) {
525 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isAutohinted());
526 return 1;
527 }
528
529 static int lpaint_isVerticalText(lua_State* L) {
530 lua_pushboolean(L, get_obj<SkPaint>(L, 1)->isVerticalText());
531 return 1;
532 }
533
479 static int lpaint_getColor(lua_State* L) { 534 static int lpaint_getColor(lua_State* L) {
480 SkLua(L).pushColor(get_obj<SkPaint>(L, 1)->getColor()); 535 SkLua(L).pushColor(get_obj<SkPaint>(L, 1)->getColor());
481 return 1; 536 return 1;
482 } 537 }
483 538
484 static int lpaint_setColor(lua_State* L) { 539 static int lpaint_setColor(lua_State* L) {
485 get_obj<SkPaint>(L, 1)->setColor(lua2color(L, 2)); 540 get_obj<SkPaint>(L, 1)->setColor(lua2color(L, 2));
486 return 0; 541 return 0;
487 } 542 }
488 543
489 static int lpaint_getTextSize(lua_State* L) { 544 static int lpaint_getTextSize(lua_State* L) {
490 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getTextSize()); 545 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getTextSize());
491 return 1; 546 return 1;
492 } 547 }
493 548
549 static int lpaint_getTextScaleX(lua_State* L) {
550 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getTextScaleX());
551 return 1;
552 }
553
554 static int lpaint_getTextSkewX(lua_State* L) {
555 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getTextSkewX());
556 return 1;
557 }
558
494 static int lpaint_setTextSize(lua_State* L) { 559 static int lpaint_setTextSize(lua_State* L) {
495 get_obj<SkPaint>(L, 1)->setTextSize(lua2scalar(L, 2)); 560 get_obj<SkPaint>(L, 1)->setTextSize(lua2scalar(L, 2));
496 return 0; 561 return 0;
497 } 562 }
498 563
499 static int lpaint_getTypeface(lua_State* L) { 564 static int lpaint_getTypeface(lua_State* L) {
500 push_ref(L, get_obj<SkPaint>(L, 1)->getTypeface()); 565 push_ref(L, get_obj<SkPaint>(L, 1)->getTypeface());
501 return 1; 566 return 1;
502 } 567 }
503 568
504 static int lpaint_setTypeface(lua_State* L) { 569 static int lpaint_setTypeface(lua_State* L) {
505 get_obj<SkPaint>(L, 1)->setTypeface(get_ref<SkTypeface>(L, 2)); 570 get_obj<SkPaint>(L, 1)->setTypeface(get_ref<SkTypeface>(L, 2));
506 return 0; 571 return 0;
507 } 572 }
508 573
574 static int lpaint_getHinting(lua_State* L) {
575 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getHinting());
576 return 1;
577 }
578
509 static int lpaint_getFontID(lua_State* L) { 579 static int lpaint_getFontID(lua_State* L) {
510 SkTypeface* face = get_obj<SkPaint>(L, 1)->getTypeface(); 580 SkTypeface* face = get_obj<SkPaint>(L, 1)->getTypeface();
511 SkLua(L).pushU32(SkTypeface::UniqueID(face)); 581 SkLua(L).pushU32(SkTypeface::UniqueID(face));
512 return 1; 582 return 1;
513 } 583 }
514 584
515 static const struct { 585 static const struct {
516 const char* fLabel; 586 const char* fLabel;
517 SkPaint::Align fAlign; 587 SkPaint::Align fAlign;
518 } gAlignRec[] = { 588 } gAlignRec[] = {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
557 627
558 if (lua_toboolean(L, 2)) { 628 if (lua_toboolean(L, 2)) {
559 style = SkPaint::kStroke_Style; 629 style = SkPaint::kStroke_Style;
560 } else { 630 } else {
561 style = SkPaint::kFill_Style; 631 style = SkPaint::kFill_Style;
562 } 632 }
563 get_obj<SkPaint>(L, 1)->setStyle(style); 633 get_obj<SkPaint>(L, 1)->setStyle(style);
564 return 0; 634 return 0;
565 } 635 }
566 636
637 static int lpaint_getStrokeCap(lua_State* L) {
638 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getStrokeCap());
639 return 1;
640 }
641
642 static int lpaint_getStrokeJoin(lua_State* L) {
643 SkLua(L).pushU32(get_obj<SkPaint>(L, 1)->getStrokeJoin());
644 return 1;
645 }
646
647 static int lpaint_getTextEncoding(lua_State* L) {
648 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getTextEncoding());
649 return 1;
650 }
651
567 static int lpaint_getStrokeWidth(lua_State* L) { 652 static int lpaint_getStrokeWidth(lua_State* L) {
568 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getStrokeWidth()); 653 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getStrokeWidth());
569 return 1; 654 return 1;
570 } 655 }
571 656
572 static int lpaint_setStrokeWidth(lua_State* L) { 657 static int lpaint_setStrokeWidth(lua_State* L) {
573 get_obj<SkPaint>(L, 1)->setStrokeWidth(lua2scalar(L, 2)); 658 get_obj<SkPaint>(L, 1)->setStrokeWidth(lua2scalar(L, 2));
574 return 0; 659 return 0;
575 } 660 }
576 661
662 static int lpaint_getStrokeMiter(lua_State* L) {
663 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->getStrokeMiter());
664 return 1;
665 }
666
577 static int lpaint_measureText(lua_State* L) { 667 static int lpaint_measureText(lua_State* L) {
578 if (lua_isstring(L, 2)) { 668 if (lua_isstring(L, 2)) {
579 size_t len; 669 size_t len;
580 const char* text = lua_tolstring(L, 2, &len); 670 const char* text = lua_tolstring(L, 2, &len);
581 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->measureText(text, len)); 671 SkLua(L).pushScalar(get_obj<SkPaint>(L, 1)->measureText(text, len));
582 return 1; 672 return 1;
583 } 673 }
584 return 0; 674 return 0;
585 } 675 }
586 676
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 } 726 }
637 727
638 static int lpaint_gc(lua_State* L) { 728 static int lpaint_gc(lua_State* L) {
639 get_obj<SkPaint>(L, 1)->~SkPaint(); 729 get_obj<SkPaint>(L, 1)->~SkPaint();
640 return 0; 730 return 0;
641 } 731 }
642 732
643 static const struct luaL_Reg gSkPaint_Methods[] = { 733 static const struct luaL_Reg gSkPaint_Methods[] = {
644 { "isAntiAlias", lpaint_isAntiAlias }, 734 { "isAntiAlias", lpaint_isAntiAlias },
645 { "setAntiAlias", lpaint_setAntiAlias }, 735 { "setAntiAlias", lpaint_setAntiAlias },
736 { "isDither", lpaint_isDither },
737 { "isUnderlineText", lpaint_isUnderlineText },
738 { "isStrikeThruText", lpaint_isStrikeThruText },
739 { "isFakeBoldText", lpaint_isFakeBoldText },
740 { "isLinearText", lpaint_isLinearText },
741 { "isSubpixelText", lpaint_isSubpixelText },
742 { "isDevKernText", lpaint_isDevKernText },
743 { "isLCDRenderText", lpaint_isLCDRenderText },
744 { "isEmbeddedBitmapText", lpaint_isEmbeddedBitmapText },
745 { "isAutohinted", lpaint_isAutohinted },
746 { "isVerticalText", lpaint_isVerticalText },
646 { "getColor", lpaint_getColor }, 747 { "getColor", lpaint_getColor },
647 { "setColor", lpaint_setColor }, 748 { "setColor", lpaint_setColor },
648 { "getTextSize", lpaint_getTextSize }, 749 { "getTextSize", lpaint_getTextSize },
649 { "setTextSize", lpaint_setTextSize }, 750 { "setTextSize", lpaint_setTextSize },
751 { "getTextScaleX", lpaint_getTextScaleX },
752 { "getTextSkewX", lpaint_getTextSkewX },
650 { "getTypeface", lpaint_getTypeface }, 753 { "getTypeface", lpaint_getTypeface },
651 { "setTypeface", lpaint_setTypeface }, 754 { "setTypeface", lpaint_setTypeface },
755 { "getHinting", lpaint_getHinting },
652 { "getFontID", lpaint_getFontID }, 756 { "getFontID", lpaint_getFontID },
653 { "getTextAlign", lpaint_getTextAlign }, 757 { "getTextAlign", lpaint_getTextAlign },
654 { "setTextAlign", lpaint_setTextAlign }, 758 { "setTextAlign", lpaint_setTextAlign },
655 { "getStroke", lpaint_getStroke }, 759 { "getStroke", lpaint_getStroke },
656 { "setStroke", lpaint_setStroke }, 760 { "setStroke", lpaint_setStroke },
761 { "getStrokeCap", lpaint_getStrokeCap },
762 { "getStrokeJoin", lpaint_getStrokeJoin },
763 { "getTextEncoding", lpaint_getTextEncoding },
657 { "getStrokeWidth", lpaint_getStrokeWidth }, 764 { "getStrokeWidth", lpaint_getStrokeWidth },
658 { "setStrokeWidth", lpaint_setStrokeWidth }, 765 { "setStrokeWidth", lpaint_setStrokeWidth },
766 { "getStrokeMiter", lpaint_getStrokeMiter },
659 { "measureText", lpaint_measureText }, 767 { "measureText", lpaint_measureText },
660 { "getFontMetrics", lpaint_getFontMetrics }, 768 { "getFontMetrics", lpaint_getFontMetrics },
661 { "getEffects", lpaint_getEffects }, 769 { "getEffects", lpaint_getEffects },
662 { "getShader", lpaint_getShader }, 770 { "getShader", lpaint_getShader },
663 { "__gc", lpaint_gc }, 771 { "__gc", lpaint_gc },
664 { NULL, NULL } 772 { NULL, NULL }
665 }; 773 };
666 774
667 /////////////////////////////////////////////////////////////////////////////// 775 ///////////////////////////////////////////////////////////////////////////////
668 776
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after
1120 REG_CLASS(L, SkShader); 1228 REG_CLASS(L, SkShader);
1121 REG_CLASS(L, SkTypeface); 1229 REG_CLASS(L, SkTypeface);
1122 REG_CLASS(L, SkMatrix); 1230 REG_CLASS(L, SkMatrix);
1123 } 1231 }
1124 1232
1125 extern "C" int luaopen_skia(lua_State* L); 1233 extern "C" int luaopen_skia(lua_State* L);
1126 extern "C" int luaopen_skia(lua_State* L) { 1234 extern "C" int luaopen_skia(lua_State* L) {
1127 SkLua::Load(L); 1235 SkLua::Load(L);
1128 return 0; 1236 return 0;
1129 } 1237 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698