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

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

Issue 648083002: add canvas:clear to lua (Closed) Base URL: https://skia.googlesource.com/skia.git@master
Patch Set: Created 6 years, 2 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 | « resources/slides.lua ('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
(...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after
417 } 417 }
418 418
419 static SkRect* lua2rect(lua_State* L, int index, SkRect* rect) { 419 static SkRect* lua2rect(lua_State* L, int index, SkRect* rect) {
420 rect->set(getfield_scalar_default(L, index, "left", 0), 420 rect->set(getfield_scalar_default(L, index, "left", 0),
421 getfield_scalar_default(L, index, "top", 0), 421 getfield_scalar_default(L, index, "top", 0),
422 getfield_scalar(L, index, "right"), 422 getfield_scalar(L, index, "right"),
423 getfield_scalar(L, index, "bottom")); 423 getfield_scalar(L, index, "bottom"));
424 return rect; 424 return rect;
425 } 425 }
426 426
427 static int lcanvas_clear(lua_State* L) {
428 get_ref<SkCanvas>(L, 1)->clear(0);
429 return 0;
430 }
431
427 static int lcanvas_drawColor(lua_State* L) { 432 static int lcanvas_drawColor(lua_State* L) {
428 get_ref<SkCanvas>(L, 1)->drawColor(lua2color(L, 2)); 433 get_ref<SkCanvas>(L, 1)->drawColor(lua2color(L, 2));
429 return 0; 434 return 0;
430 } 435 }
431 436
432 static int lcanvas_drawRect(lua_State* L) { 437 static int lcanvas_drawRect(lua_State* L) {
433 SkRect rect; 438 SkRect rect;
434 get_ref<SkCanvas>(L, 1)->drawRect(*lua2rect(L, 2, &rect), 439 get_ref<SkCanvas>(L, 1)->drawRect(*lua2rect(L, 2, &rect),
435 *get_obj<SkPaint>(L, 3)); 440 *get_obj<SkPaint>(L, 3));
436 return 0; 441 return 0;
(...skipping 11 matching lines...) Expand all
448 lua2scalar(L, 3), 453 lua2scalar(L, 3),
449 lua2scalar(L, 4), 454 lua2scalar(L, 4),
450 *get_obj<SkPaint>(L, 5)); 455 *get_obj<SkPaint>(L, 5));
451 return 0; 456 return 0;
452 } 457 }
453 458
454 static SkPaint* lua2OptionalPaint(lua_State* L, int index, SkPaint* paint) { 459 static SkPaint* lua2OptionalPaint(lua_State* L, int index, SkPaint* paint) {
455 if (lua_isnumber(L, index)) { 460 if (lua_isnumber(L, index)) {
456 paint->setAlpha(SkScalarRoundToInt(lua2scalar(L, index) * 255)); 461 paint->setAlpha(SkScalarRoundToInt(lua2scalar(L, index) * 255));
457 return paint; 462 return paint;
458 } else { 463 } else if (lua_isuserdata(L, index)) {
459 const SkPaint* ptr = get_obj<SkPaint>(L, index); 464 const SkPaint* ptr = get_obj<SkPaint>(L, index);
460 if (ptr) { 465 if (ptr) {
461 *paint = *ptr; 466 *paint = *ptr;
462 return paint; 467 return paint;
463 } 468 }
464 } 469 }
465 return NULL; 470 return NULL;
466 } 471 }
467 472
468 static int lcanvas_drawImage(lua_State* L) { 473 static int lcanvas_drawImage(lua_State* L) {
(...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 } 621 }
617 return 1; 622 return 1;
618 } 623 }
619 624
620 static int lcanvas_gc(lua_State* L) { 625 static int lcanvas_gc(lua_State* L) {
621 get_ref<SkCanvas>(L, 1)->unref(); 626 get_ref<SkCanvas>(L, 1)->unref();
622 return 0; 627 return 0;
623 } 628 }
624 629
625 const struct luaL_Reg gSkCanvas_Methods[] = { 630 const struct luaL_Reg gSkCanvas_Methods[] = {
631 { "clear", lcanvas_clear },
626 { "drawColor", lcanvas_drawColor }, 632 { "drawColor", lcanvas_drawColor },
627 { "drawRect", lcanvas_drawRect }, 633 { "drawRect", lcanvas_drawRect },
628 { "drawOval", lcanvas_drawOval }, 634 { "drawOval", lcanvas_drawOval },
629 { "drawCircle", lcanvas_drawCircle }, 635 { "drawCircle", lcanvas_drawCircle },
630 { "drawImage", lcanvas_drawImage }, 636 { "drawImage", lcanvas_drawImage },
631 { "drawImageRect", lcanvas_drawImageRect }, 637 { "drawImageRect", lcanvas_drawImageRect },
632 { "drawPath", lcanvas_drawPath }, 638 { "drawPath", lcanvas_drawPath },
633 { "drawText", lcanvas_drawText }, 639 { "drawText", lcanvas_drawText },
634 { "getSaveCount", lcanvas_getSaveCount }, 640 { "getSaveCount", lcanvas_getSaveCount },
635 { "getTotalMatrix", lcanvas_getTotalMatrix }, 641 { "getTotalMatrix", lcanvas_getTotalMatrix },
(...skipping 1019 matching lines...) Expand 10 before | Expand all | Expand 10 after
1655 REG_CLASS(L, SkSurface); 1661 REG_CLASS(L, SkSurface);
1656 REG_CLASS(L, SkTypeface); 1662 REG_CLASS(L, SkTypeface);
1657 REG_CLASS(L, SkMatrix); 1663 REG_CLASS(L, SkMatrix);
1658 } 1664 }
1659 1665
1660 extern "C" int luaopen_skia(lua_State* L); 1666 extern "C" int luaopen_skia(lua_State* L);
1661 extern "C" int luaopen_skia(lua_State* L) { 1667 extern "C" int luaopen_skia(lua_State* L) {
1662 SkLua::Load(L); 1668 SkLua::Load(L);
1663 return 0; 1669 return 0;
1664 } 1670 }
OLDNEW
« no previous file with comments | « resources/slides.lua ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698