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 1989 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2000 push_ref(L, surface)->unref(); | 2000 push_ref(L, surface)->unref(); |
2001 } | 2001 } |
2002 return 1; | 2002 return 1; |
2003 } | 2003 } |
2004 | 2004 |
2005 static int lsk_loadImage(lua_State* L) { | 2005 static int lsk_loadImage(lua_State* L) { |
2006 if (lua_gettop(L) > 0 && lua_isstring(L, 1)) { | 2006 if (lua_gettop(L) > 0 && lua_isstring(L, 1)) { |
2007 const char* name = lua_tolstring(L, 1, NULL); | 2007 const char* name = lua_tolstring(L, 1, NULL); |
2008 SkAutoDataUnref data(SkData::NewFromFileName(name)); | 2008 SkAutoDataUnref data(SkData::NewFromFileName(name)); |
2009 if (data.get()) { | 2009 if (data.get()) { |
2010 SkImage* image = SkImage::NewFromData(data); | 2010 SkImage* image = SkImage::NewFromEncoded(data); |
2011 if (image) { | 2011 if (image) { |
2012 push_ref(L, image)->unref(); | 2012 push_ref(L, image)->unref(); |
2013 return 1; | 2013 return 1; |
2014 } | 2014 } |
2015 } | 2015 } |
2016 } | 2016 } |
2017 return 0; | 2017 return 0; |
2018 } | 2018 } |
2019 | 2019 |
2020 static void register_Sk(lua_State* L) { | 2020 static void register_Sk(lua_State* L) { |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2064 REG_CLASS(L, SkSurface); | 2064 REG_CLASS(L, SkSurface); |
2065 REG_CLASS(L, SkTextBlob); | 2065 REG_CLASS(L, SkTextBlob); |
2066 REG_CLASS(L, SkTypeface); | 2066 REG_CLASS(L, SkTypeface); |
2067 } | 2067 } |
2068 | 2068 |
2069 extern "C" int luaopen_skia(lua_State* L); | 2069 extern "C" int luaopen_skia(lua_State* L); |
2070 extern "C" int luaopen_skia(lua_State* L) { | 2070 extern "C" int luaopen_skia(lua_State* L) { |
2071 SkLua::Load(L); | 2071 SkLua::Load(L); |
2072 return 0; | 2072 return 0; |
2073 } | 2073 } |
OLD | NEW |