Chromium Code Reviews| 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 #include "SkCanvas.h" | 9 #include "SkCanvas.h" |
| 10 #include "SkData.h" | 10 #include "SkData.h" |
| (...skipping 694 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 705 } | 705 } |
| 706 } | 706 } |
| 707 return 0; | 707 return 0; |
| 708 } | 708 } |
| 709 | 709 |
| 710 static int lshader_asAGradient(lua_State* L) { | 710 static int lshader_asAGradient(lua_State* L) { |
| 711 SkShader* shader = get_ref<SkShader>(L, 1); | 711 SkShader* shader = get_ref<SkShader>(L, 1); |
| 712 if (shader) { | 712 if (shader) { |
| 713 SkShader::GradientInfo info; | 713 SkShader::GradientInfo info; |
| 714 sk_bzero(&info, sizeof(info)); | 714 sk_bzero(&info, sizeof(info)); |
| 715 | |
| 716 SkColor colors[3]; // hacked in for extracting info on 3 color case. | |
| 717 SkScalar pos[3]; | |
| 718 | |
| 719 info.fColorCount = 3; | |
| 720 info.fColors = &colors[0]; | |
| 721 info.fColorOffsets = &pos[0]; | |
| 722 | |
| 715 SkShader::GradientType t = shader->asAGradient(&info); | 723 SkShader::GradientType t = shader->asAGradient(&info); |
| 724 | |
| 716 if (SkShader::kNone_GradientType != t) { | 725 if (SkShader::kNone_GradientType != t) { |
| 717 lua_newtable(L); | 726 lua_newtable(L); |
| 718 setfield_string(L, "type", gradtype2string(t)); | 727 setfield_string(L, "type", gradtype2string(t)); |
| 719 setfield_number(L, "colorCount", info.fColorCount); | 728 setfield_number(L, "colorCount", info.fColorCount); |
| 720 setfield_string(L, "tile", mode2string(info.fTileMode)); | 729 setfield_string(L, "tile", mode2string(info.fTileMode)); |
| 730 | |
| 731 if (info.fColorCount == 3){ | |
|
reed1
2013/08/01 16:23:26
nit: 3 == info.fColorCount
This ordering ensures
| |
| 732 setfield_number(L, "midPos", pos[1]); | |
| 733 } | |
| 734 | |
| 721 return 1; | 735 return 1; |
| 722 } | 736 } |
| 723 } | 737 } |
| 724 return 0; | 738 return 0; |
| 725 } | 739 } |
| 726 | 740 |
| 727 static int lshader_gc(lua_State* L) { | 741 static int lshader_gc(lua_State* L) { |
| 728 get_ref<SkShader>(L, 1)->unref(); | 742 get_ref<SkShader>(L, 1)->unref(); |
| 729 return 0; | 743 return 0; |
| 730 } | 744 } |
| (...skipping 375 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1106 REG_CLASS(L, SkShader); | 1120 REG_CLASS(L, SkShader); |
| 1107 REG_CLASS(L, SkTypeface); | 1121 REG_CLASS(L, SkTypeface); |
| 1108 REG_CLASS(L, SkMatrix); | 1122 REG_CLASS(L, SkMatrix); |
| 1109 } | 1123 } |
| 1110 | 1124 |
| 1111 extern "C" int luaopen_skia(lua_State* L); | 1125 extern "C" int luaopen_skia(lua_State* L); |
| 1112 extern "C" int luaopen_skia(lua_State* L) { | 1126 extern "C" int luaopen_skia(lua_State* L) { |
| 1113 SkLua::Load(L); | 1127 SkLua::Load(L); |
| 1114 return 0; | 1128 return 0; |
| 1115 } | 1129 } |
| OLD | NEW |