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 169 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
180 if (lua_isnumber(L, index)) { | 180 if (lua_isnumber(L, index)) { |
181 return SkLuaToScalar(lua_tonumber(L, index)); | 181 return SkLuaToScalar(lua_tonumber(L, index)); |
182 } else { | 182 } else { |
183 return defaultValue; | 183 return defaultValue; |
184 } | 184 } |
185 } | 185 } |
186 | 186 |
187 static SkScalar getarray_scalar(lua_State* L, int stackIndex, int arrayIndex) { | 187 static SkScalar getarray_scalar(lua_State* L, int stackIndex, int arrayIndex) { |
188 SkASSERT(lua_istable(L, stackIndex)); | 188 SkASSERT(lua_istable(L, stackIndex)); |
189 lua_rawgeti(L, stackIndex, arrayIndex); | 189 lua_rawgeti(L, stackIndex, arrayIndex); |
190 | 190 |
191 SkScalar value = lua2scalar(L, -1); | 191 SkScalar value = lua2scalar(L, -1); |
192 lua_pop(L, 1); | 192 lua_pop(L, 1); |
193 return value; | 193 return value; |
194 } | 194 } |
195 | 195 |
196 static void getarray_scalars(lua_State* L, int stackIndex, SkScalar dst[], int c
ount) { | 196 static void getarray_scalars(lua_State* L, int stackIndex, SkScalar dst[], int c
ount) { |
197 for (int i = 0; i < count; ++i) { | 197 for (int i = 0; i < count; ++i) { |
198 dst[i] = getarray_scalar(L, stackIndex, i + 1); | 198 dst[i] = getarray_scalar(L, stackIndex, i + 1); |
199 } | 199 } |
200 } | 200 } |
(...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
397 } | 397 } |
398 | 398 |
399 | 399 |
400 /////////////////////////////////////////////////////////////////////////////// | 400 /////////////////////////////////////////////////////////////////////////////// |
401 /////////////////////////////////////////////////////////////////////////////// | 401 /////////////////////////////////////////////////////////////////////////////// |
402 | 402 |
403 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[]) { |
404 SkASSERT(lua_istable(L, index)); | 404 SkASSERT(lua_istable(L, index)); |
405 lua_pushstring(L, key); | 405 lua_pushstring(L, key); |
406 lua_gettable(L, index); | 406 lua_gettable(L, index); |
407 | 407 |
408 SkScalar value = lua2scalar(L, -1); | 408 SkScalar value = lua2scalar(L, -1); |
409 lua_pop(L, 1); | 409 lua_pop(L, 1); |
410 return value; | 410 return value; |
411 } | 411 } |
412 | 412 |
413 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) { |
414 SkASSERT(lua_istable(L, index)); | 414 SkASSERT(lua_istable(L, index)); |
415 lua_pushstring(L, key); | 415 lua_pushstring(L, key); |
416 lua_gettable(L, index); | 416 lua_gettable(L, index); |
417 | 417 |
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
526 if (NULL == image) { | 526 if (NULL == image) { |
527 return 0; | 527 return 0; |
528 } | 528 } |
529 | 529 |
530 SkRect srcR, dstR; | 530 SkRect srcR, dstR; |
531 SkRect* srcRPtr = NULL; | 531 SkRect* srcRPtr = NULL; |
532 if (!lua_isnil(L, 3)) { | 532 if (!lua_isnil(L, 3)) { |
533 srcRPtr = lua2rect(L, 3, &srcR); | 533 srcRPtr = lua2rect(L, 3, &srcR); |
534 } | 534 } |
535 lua2rect(L, 4, &dstR); | 535 lua2rect(L, 4, &dstR); |
536 | 536 |
537 SkPaint paint; | 537 SkPaint paint; |
538 canvas->drawImageRect(image, srcRPtr, dstR, lua2OptionalPaint(L, 5, &paint))
; | 538 canvas->drawImageRect(image, srcRPtr, dstR, lua2OptionalPaint(L, 5, &paint))
; |
539 return 0; | 539 return 0; |
540 } | 540 } |
541 | 541 |
542 static int lcanvas_drawPatch(lua_State* L) { | 542 static int lcanvas_drawPatch(lua_State* L) { |
543 SkPoint cubics[12]; | 543 SkPoint cubics[12]; |
544 SkColor colorStorage[4]; | 544 SkColor colorStorage[4]; |
545 SkPoint texStorage[4]; | 545 SkPoint texStorage[4]; |
546 | 546 |
(...skipping 1025 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1572 { "cubicTo", lpath_cubicTo }, | 1572 { "cubicTo", lpath_cubicTo }, |
1573 { "close", lpath_close }, | 1573 { "close", lpath_close }, |
1574 { "__gc", lpath_gc }, | 1574 { "__gc", lpath_gc }, |
1575 { NULL, NULL } | 1575 { NULL, NULL } |
1576 }; | 1576 }; |
1577 | 1577 |
1578 /////////////////////////////////////////////////////////////////////////////// | 1578 /////////////////////////////////////////////////////////////////////////////// |
1579 | 1579 |
1580 static const char* rrect_type(const SkRRect& rr) { | 1580 static const char* rrect_type(const SkRRect& rr) { |
1581 switch (rr.getType()) { | 1581 switch (rr.getType()) { |
1582 case SkRRect::kUnknown_Type: return "unknown"; | |
1583 case SkRRect::kEmpty_Type: return "empty"; | 1582 case SkRRect::kEmpty_Type: return "empty"; |
1584 case SkRRect::kRect_Type: return "rect"; | 1583 case SkRRect::kRect_Type: return "rect"; |
1585 case SkRRect::kOval_Type: return "oval"; | 1584 case SkRRect::kOval_Type: return "oval"; |
1586 case SkRRect::kSimple_Type: return "simple"; | 1585 case SkRRect::kSimple_Type: return "simple"; |
1587 case SkRRect::kNinePatch_Type: return "nine-patch"; | 1586 case SkRRect::kNinePatch_Type: return "nine-patch"; |
1588 case SkRRect::kComplex_Type: return "complex"; | 1587 case SkRRect::kComplex_Type: return "complex"; |
1589 } | 1588 } |
1590 SkDEBUGFAIL("never get here"); | 1589 SkDEBUGFAIL("never get here"); |
1591 return ""; | 1590 return ""; |
1592 } | 1591 } |
(...skipping 475 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2068 REG_CLASS(L, SkSurface); | 2067 REG_CLASS(L, SkSurface); |
2069 REG_CLASS(L, SkTextBlob); | 2068 REG_CLASS(L, SkTextBlob); |
2070 REG_CLASS(L, SkTypeface); | 2069 REG_CLASS(L, SkTypeface); |
2071 } | 2070 } |
2072 | 2071 |
2073 extern "C" int luaopen_skia(lua_State* L); | 2072 extern "C" int luaopen_skia(lua_State* L); |
2074 extern "C" int luaopen_skia(lua_State* L) { | 2073 extern "C" int luaopen_skia(lua_State* L) { |
2075 SkLua::Load(L); | 2074 SkLua::Load(L); |
2076 return 0; | 2075 return 0; |
2077 } | 2076 } |
OLD | NEW |