From 0bfff69053e27fbb6e541a6b8afa6c8e61a62403 Mon Sep 17 00:00:00 2001 From: chai Date: Wed, 14 Nov 2018 00:51:15 +0800 Subject: =?UTF-8?q?*shared=20=E5=A2=9E=E5=8A=A0=E4=BE=9D=E8=B5=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/modules/graphics/je_lua_texture_font.cpp | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) (limited to 'src/lua/modules/graphics/je_lua_texture_font.cpp') 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(); + Proxy* pxyTexFont = (Proxy*)luax_checktype(L, 1, JIN_GRAPHICS_TEXTUREFONT); + Shared& shrTexFont = pxyTexFont->getShared(); + TextureFont* tf = pxyTexFont->getObject(); 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(); page = tf->typeset(*text, lineheight, spacing); } - Proxy* proxy = luax_newinstance(L, JIN_GRAPHICS_PAGE); - Shared* refPage = new Shared(page, JIN_GRAPHICS_PAGE); - { - /* retain related ttf */ - Shared& refTF = p->getShared(); - refTF.retain(); - refPage->setUserdata(&refTF); - } - proxy->bind(refPage); + Proxy* pxyPage = luax_newinstance(L, JIN_GRAPHICS_PAGE); + Shared* shrPage = new Shared(page, JIN_GRAPHICS_PAGE); + shrPage->setDependency(DEP_TEXTURE_FONT, &shrTexFont); + pxyPage->bind(shrPage); return 1; } -- cgit v1.1-26-g67d0