diff options
author | chai <chaifix@163.com> | 2018-11-14 00:51:15 +0800 |
---|---|---|
committer | chai <chaifix@163.com> | 2018-11-14 00:51:15 +0800 |
commit | 0bfff69053e27fbb6e541a6b8afa6c8e61a62403 (patch) | |
tree | d3bd41f8defef8e08f80850d56eaf7a50de3c05a /src/lua/modules/graphics/je_lua_texture_font.cpp | |
parent | d2058dce75ceb67f27c50e9f27d755a4d30c9003 (diff) |
*shared 增加依赖
Diffstat (limited to 'src/lua/modules/graphics/je_lua_texture_font.cpp')
-rw-r--r-- | src/lua/modules/graphics/je_lua_texture_font.cpp | 19 |
1 files changed, 8 insertions, 11 deletions
diff --git a/src/lua/modules/graphics/je_lua_texture_font.cpp b/src/lua/modules/graphics/je_lua_texture_font.cpp index 1cdbfff..dc48ce4 100644 --- a/src/lua/modules/graphics/je_lua_texture_font.cpp +++ b/src/lua/modules/graphics/je_lua_texture_font.cpp @@ -2,6 +2,7 @@ #include "lua/modules/types.h" #include "lua/common/je_lua_common.h" #include "libjin/jin.h" +#include "je_lua_page.h" using namespace JinEngine::Graphics; using namespace JinEngine::Graphics::Fonts; @@ -21,8 +22,9 @@ namespace JinEngine /* typeset(Text | string, lineheight, spacing) */ LUA_IMPLEMENT int l_typeset(lua_State* L) { - Proxy* p = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); - TextureFont* tf = p->getObject<TextureFont>(); + Proxy* pxyTexFont = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); + Shared<TextureFont>& shrTexFont = pxyTexFont->getShared<TextureFont>(); + TextureFont* tf = pxyTexFont->getObject<TextureFont>(); int lineheight = luax_checkinteger(L, 3); int spacing = luax_optnumber(L, 4, 0); Page* page = nullptr; @@ -39,15 +41,10 @@ namespace JinEngine Text* text = p2->getObject<Text>(); page = tf->typeset(*text, lineheight, spacing); } - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_PAGE); - Shared<Page>* refPage = new Shared<Page>(page, JIN_GRAPHICS_PAGE); - { - /* retain related ttf */ - Shared<TextureFont>& refTF = p->getShared<TextureFont>(); - refTF.retain(); - refPage->setUserdata(&refTF); - } - proxy->bind(refPage); + Proxy* pxyPage = luax_newinstance(L, JIN_GRAPHICS_PAGE); + Shared<Page>* shrPage = new Shared<Page>(page, JIN_GRAPHICS_PAGE); + shrPage->setDependency(DEP_TEXTURE_FONT, &shrTexFont); + pxyPage->bind(shrPage); return 1; } |