Make render queue scratch variables instance variables

This commit is contained in:
Ilari Liusvaara 2014-06-07 03:24:33 +03:00
parent 0631826095
commit 63dfbd59d6
3 changed files with 16 additions and 13 deletions

View file

@ -99,6 +99,9 @@ struct lua_state
std::set<std::string> hooked_keys; std::set<std::string> hooked_keys;
uint64_t idle_hook_time; uint64_t idle_hook_time;
uint64_t timer_hook_time; uint64_t timer_hook_time;
lua::render_context* renderq_saved;
lua::render_context* renderq_last;
bool renderq_redirect;
std::list<std::string> startup_scripts; std::list<std::string> startup_scripts;
std::map<std::string, std::u32string> watch_vars; std::map<std::string, std::u32string> watch_vars;

View file

@ -5,10 +5,6 @@
namespace namespace
{ {
lua::render_context* saved = NULL;
lua::render_context* last = NULL;
bool redirect = false;
struct lua_renderqueue struct lua_renderqueue
{ {
lua_renderqueue(lua::state& L, uint32_t width, uint32_t height) throw(); lua_renderqueue(lua::state& L, uint32_t width, uint32_t height) throw();
@ -69,10 +65,10 @@ namespace
P(q); P(q);
lua::render_context* ptr = q->get(); lua::render_context* ptr = q->get();
if(!redirect || last != core.lua2->render_ctx) if(!core.lua2->renderq_redirect || core.lua2->renderq_last != core.lua2->render_ctx)
saved = core.lua2->render_ctx; core.lua2->renderq_saved = core.lua2->render_ctx;
core.lua2->render_ctx = last = ptr; core.lua2->render_ctx = core.lua2->renderq_last = ptr;
redirect = true; core.lua2->renderq_redirect = true;
return 0; return 0;
} }
int render(lua::state& L, lua::parameters& P) int render(lua::state& L, lua::parameters& P)
@ -132,12 +128,12 @@ namespace
int lua_renderqueue::setnull(lua::state& L, lua::parameters& P) int lua_renderqueue::setnull(lua::state& L, lua::parameters& P)
{ {
auto& core = CORE(); auto& core = CORE();
if(redirect && last == core.lua2->render_ctx) if(core.lua2->renderq_redirect && core.lua2->renderq_last == core.lua2->render_ctx)
//If there is valid redirect, undo it. //If there is valid redirect, undo it.
core.lua2->render_ctx = saved; core.lua2->render_ctx = core.lua2->renderq_saved;
redirect = false; core.lua2->renderq_redirect = false;
last = NULL; core.lua2->renderq_last = NULL;
saved = NULL; core.lua2->renderq_saved = NULL;
return 0; return 0;
} }

View file

@ -167,6 +167,10 @@ lua_state::lua_state(lua::state& _L, command::group& _command)
recursive_flag = false; recursive_flag = false;
luareader_fragment = NULL; luareader_fragment = NULL;
renderq_saved = NULL;
renderq_last = NULL;
renderq_redirect = false;
on_paint = new lua::state::callback_list(L, "paint", "on_paint"); on_paint = new lua::state::callback_list(L, "paint", "on_paint");
on_video = new lua::state::callback_list(L, "video", "on_video"); on_video = new lua::state::callback_list(L, "video", "on_video");
on_reset = new lua::state::callback_list(L, "reset", "on_reset"); on_reset = new lua::state::callback_list(L, "reset", "on_reset");