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 1182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1193 }; | 1193 }; |
1194 SkASSERT((unsigned)t < SK_ARRAY_COUNT(gNames)); | 1194 SkASSERT((unsigned)t < SK_ARRAY_COUNT(gNames)); |
1195 return gNames[t]; | 1195 return gNames[t]; |
1196 } | 1196 } |
1197 | 1197 |
1198 static int lshader_isOpaque(lua_State* L) { | 1198 static int lshader_isOpaque(lua_State* L) { |
1199 SkShader* shader = get_ref<SkShader>(L, 1); | 1199 SkShader* shader = get_ref<SkShader>(L, 1); |
1200 return shader && shader->isOpaque(); | 1200 return shader && shader->isOpaque(); |
1201 } | 1201 } |
1202 | 1202 |
1203 static int lshader_asABitmap(lua_State* L) { | 1203 static int lshader_isABitmap(lua_State* L) { |
1204 SkShader* shader = get_ref<SkShader>(L, 1); | 1204 SkShader* shader = get_ref<SkShader>(L, 1); |
1205 if (shader) { | 1205 if (shader) { |
1206 SkBitmap bm; | 1206 SkBitmap bm; |
1207 SkMatrix matrix; | 1207 SkMatrix matrix; |
1208 SkShader::TileMode modes[2]; | 1208 SkShader::TileMode modes[2]; |
1209 switch (shader->asABitmap(&bm, &matrix, modes)) { | 1209 if (shader->isABitmap(&bm, &matrix, modes)) { |
1210 case SkShader::kDefault_BitmapType: | 1210 lua_newtable(L); |
1211 lua_newtable(L); | 1211 setfield_number(L, "genID", bm.pixelRef() ? bm.pixelRef()->getGenera
tionID() : 0); |
1212 setfield_number(L, "genID", bm.pixelRef() ? bm.pixelRef()->getGe
nerationID() : 0); | 1212 setfield_number(L, "width", bm.width()); |
1213 setfield_number(L, "width", bm.width()); | 1213 setfield_number(L, "height", bm.height()); |
1214 setfield_number(L, "height", bm.height()); | 1214 setfield_string(L, "tileX", mode2string(modes[0])); |
1215 setfield_string(L, "tileX", mode2string(modes[0])); | 1215 setfield_string(L, "tileY", mode2string(modes[1])); |
1216 setfield_string(L, "tileY", mode2string(modes[1])); | 1216 return 1; |
1217 return 1; | |
1218 default: | |
1219 break; | |
1220 } | 1217 } |
1221 } | 1218 } |
1222 return 0; | 1219 return 0; |
1223 } | 1220 } |
1224 | 1221 |
1225 static int lshader_asAGradient(lua_State* L) { | 1222 static int lshader_asAGradient(lua_State* L) { |
1226 SkShader* shader = get_ref<SkShader>(L, 1); | 1223 SkShader* shader = get_ref<SkShader>(L, 1); |
1227 if (shader) { | 1224 if (shader) { |
1228 SkShader::GradientInfo info; | 1225 SkShader::GradientInfo info; |
1229 sk_bzero(&info, sizeof(info)); | 1226 sk_bzero(&info, sizeof(info)); |
(...skipping 23 matching lines...) Expand all Loading... |
1253 return 0; | 1250 return 0; |
1254 } | 1251 } |
1255 | 1252 |
1256 static int lshader_gc(lua_State* L) { | 1253 static int lshader_gc(lua_State* L) { |
1257 get_ref<SkShader>(L, 1)->unref(); | 1254 get_ref<SkShader>(L, 1)->unref(); |
1258 return 0; | 1255 return 0; |
1259 } | 1256 } |
1260 | 1257 |
1261 static const struct luaL_Reg gSkShader_Methods[] = { | 1258 static const struct luaL_Reg gSkShader_Methods[] = { |
1262 { "isOpaque", lshader_isOpaque }, | 1259 { "isOpaque", lshader_isOpaque }, |
1263 { "asABitmap", lshader_asABitmap }, | 1260 { "isABitmap", lshader_isABitmap }, |
1264 { "asAGradient", lshader_asAGradient }, | 1261 { "asAGradient", lshader_asAGradient }, |
1265 { "__gc", lshader_gc }, | 1262 { "__gc", lshader_gc }, |
1266 { NULL, NULL } | 1263 { NULL, NULL } |
1267 }; | 1264 }; |
1268 | 1265 |
1269 /////////////////////////////////////////////////////////////////////////////// | 1266 /////////////////////////////////////////////////////////////////////////////// |
1270 | 1267 |
1271 static int lpatheffect_asADash(lua_State* L) { | 1268 static int lpatheffect_asADash(lua_State* L) { |
1272 SkPathEffect* pe = get_ref<SkPathEffect>(L, 1); | 1269 SkPathEffect* pe = get_ref<SkPathEffect>(L, 1); |
1273 if (pe) { | 1270 if (pe) { |
(...skipping 791 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2065 REG_CLASS(L, SkSurface); | 2062 REG_CLASS(L, SkSurface); |
2066 REG_CLASS(L, SkTextBlob); | 2063 REG_CLASS(L, SkTextBlob); |
2067 REG_CLASS(L, SkTypeface); | 2064 REG_CLASS(L, SkTypeface); |
2068 } | 2065 } |
2069 | 2066 |
2070 extern "C" int luaopen_skia(lua_State* L); | 2067 extern "C" int luaopen_skia(lua_State* L); |
2071 extern "C" int luaopen_skia(lua_State* L) { | 2068 extern "C" int luaopen_skia(lua_State* L) { |
2072 SkLua::Load(L); | 2069 SkLua::Load(L); |
2073 return 0; | 2070 return 0; |
2074 } | 2071 } |
OLD | NEW |