aboutsummaryrefslogtreecommitdiff
path: root/src/lua/modules/graphics/je_lua_bitmap.cpp
diff options
context:
space:
mode:
authorchai <chaifix@163.com>2018-12-08 22:05:31 +0800
committerchai <chaifix@163.com>2018-12-08 22:05:31 +0800
commita16ce94158c9cf22a19c0e73dfe2e992a8302af1 (patch)
tree52d80d950cd410ba82af909e18f77e3b11cd6eda /src/lua/modules/graphics/je_lua_bitmap.cpp
parentd34e5c9d7c6135e805f2cc231411cdcc9910190c (diff)
*去除shared template
Diffstat (limited to 'src/lua/modules/graphics/je_lua_bitmap.cpp')
-rw-r--r--src/lua/modules/graphics/je_lua_bitmap.cpp35
1 files changed, 16 insertions, 19 deletions
diff --git a/src/lua/modules/graphics/je_lua_bitmap.cpp b/src/lua/modules/graphics/je_lua_bitmap.cpp
index 8d8b76e..cd0bb18 100644
--- a/src/lua/modules/graphics/je_lua_bitmap.cpp
+++ b/src/lua/modules/graphics/je_lua_bitmap.cpp
@@ -13,12 +13,10 @@ namespace JinEngine
const char* Jin_Lua_Bitmap = "Bitmap";
- typedef Shared<Bitmap>& SharedBitmap;
-
- LUA_IMPLEMENT inline SharedBitmap checkBitmap(lua_State* L)
+ LUA_IMPLEMENT inline Bitmap* checkBitmap(lua_State* L)
{
- LuaObject* luaObj = (LuaObject*)luax_checktype(L, 1, Jin_Lua_Bitmap);
- return luaObj->getShared<Bitmap>();
+ LuaObject* luaObj = luax_checkobject(L, 1, Jin_Lua_Bitmap);
+ return luaObj->getObject<Bitmap>();
}
LUA_IMPLEMENT int l_gc(lua_State* L)
@@ -30,25 +28,25 @@ namespace JinEngine
LUA_IMPLEMENT int l_getWidth(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- int w = shared->getWidth();
+ Bitmap* bitmap = checkBitmap(L);
+ int w = bitmap->getWidth();
luax_pushinteger(L, w);
return 1;
}
LUA_IMPLEMENT int l_getHeight(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- int h = shared->getHeight();
+ Bitmap* bitmap = checkBitmap(L);
+ int h = bitmap->getHeight();
luax_pushinteger(L, h);
return 1;
}
LUA_IMPLEMENT int l_getSize(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- int w = shared->getWidth();
- int h = shared->getHeight();
+ Bitmap* bitmap = checkBitmap(L);
+ int w = bitmap->getWidth();
+ int h = bitmap->getHeight();
luax_pushinteger(L, w);
luax_pushinteger(L, h);
return 2;
@@ -56,10 +54,10 @@ namespace JinEngine
LUA_IMPLEMENT int l_getPixel(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
+ Bitmap* bitmap = checkBitmap(L);
int x = luax_checkinteger(L, 2);
int y = luax_checkinteger(L, 3);
- Color col = shared->getPixel(x, y);
+ Color col = bitmap->getPixel(x, y);
luax_pushinteger(L, col.r);
luax_pushinteger(L, col.g);
luax_pushinteger(L, col.b);
@@ -69,7 +67,7 @@ namespace JinEngine
LUA_IMPLEMENT int l_setPixel(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
+ Bitmap* bitmap = checkBitmap(L);
int x = luax_checkinteger(L, 2);
int y = luax_checkinteger(L, 3);
if (!luax_istable(L, 4))
@@ -81,16 +79,15 @@ namespace JinEngine
unsigned int g = luax_rawgetnumber(L, 4, 2);
unsigned int b = luax_rawgetnumber(L, 4, 3);
unsigned int a = luax_rawgetnumber(L, 4, 4);
- shared->setPixel(Color(r, g, b, a), x, y);
+ bitmap->setPixel(Color(r, g, b, a), x, y);
return 0;
}
LUA_IMPLEMENT int l_clone(lua_State* L)
{
- SharedBitmap shared = checkBitmap(L);
- Bitmap* bitmap = shared.getObject();
+ Bitmap* bitmap = checkBitmap(L);
Bitmap* b = bitmap->clone();
- LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared<Bitmap>(b, Jin_Lua_Bitmap));
+ LuaObject* luaObj = luax_newinstance(L, Jin_Lua_Bitmap, new Shared(b, Jin_Lua_Bitmap));
return 1;
}