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 2058 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2069 SkRect bounds; | 2069 SkRect bounds; |
2070 lua2rect(L, 2, &bounds); | 2070 lua2rect(L, 2, &bounds); |
2071 const SkPaint& paint = *get_obj<SkPaint>(L, 3); | 2071 const SkPaint& paint = *get_obj<SkPaint>(L, 3); |
2072 | 2072 |
2073 SkTextBox box; | 2073 SkTextBox box; |
2074 box.setMode(SkTextBox::kLineBreak_Mode); | 2074 box.setMode(SkTextBox::kLineBreak_Mode); |
2075 box.setBox(bounds); | 2075 box.setBox(bounds); |
2076 box.setText(text, strlen(text), paint); | 2076 box.setText(text, strlen(text), paint); |
2077 | 2077 |
2078 SkScalar newBottom; | 2078 SkScalar newBottom; |
2079 SkAutoTUnref<SkTextBlob> blob(box.snapshotTextBlob(&newBottom)); | 2079 push_ref<SkTextBlob>(L, box.snapshotTextBlob(&newBottom)); |
2080 push_ref<SkTextBlob>(L, blob); | |
2081 SkLua(L).pushScalar(newBottom); | 2080 SkLua(L).pushScalar(newBottom); |
2082 return 2; | 2081 return 2; |
2083 } | 2082 } |
2084 | 2083 |
2085 static int lsk_newTypeface(lua_State* L) { | 2084 static int lsk_newTypeface(lua_State* L) { |
2086 const char* name = nullptr; | 2085 const char* name = nullptr; |
2087 int style = SkTypeface::kNormal; | 2086 int style = SkTypeface::kNormal; |
2088 | 2087 |
2089 int count = lua_gettop(L); | 2088 int count = lua_gettop(L); |
2090 if (count > 0 && lua_isstring(L, 1)) { | 2089 if (count > 0 && lua_isstring(L, 1)) { |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2181 REG_CLASS(L, SkTextBlob); | 2180 REG_CLASS(L, SkTextBlob); |
2182 REG_CLASS(L, SkTypeface); | 2181 REG_CLASS(L, SkTypeface); |
2183 REG_CLASS(L, SkXfermode); | 2182 REG_CLASS(L, SkXfermode); |
2184 } | 2183 } |
2185 | 2184 |
2186 extern "C" int luaopen_skia(lua_State* L); | 2185 extern "C" int luaopen_skia(lua_State* L); |
2187 extern "C" int luaopen_skia(lua_State* L) { | 2186 extern "C" int luaopen_skia(lua_State* L) { |
2188 SkLua::Load(L); | 2187 SkLua::Load(L); |
2189 return 0; | 2188 return 0; |
2190 } | 2189 } |
OLD | NEW |