From a8892c648d7cf5201a5836410fa708f28b539294 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: 2012年3月28日 13:08:31 +0200 Subject: Optimize plot's show method to avoid double drawing --- agg-plot/lua-plot.cpp | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) (limited to 'agg-plot/lua-plot.cpp') diff --git a/agg-plot/lua-plot.cpp b/agg-plot/lua-plot.cpp index 8ba21bbc..0b0f9a19 100644 --- a/agg-plot/lua-plot.cpp +++ b/agg-plot/lua-plot.cpp @@ -28,6 +28,7 @@ extern "C" { #include "lua-cpp-utils.h" #include "bitmap-plot.h" #include "window.h" +#include "window-cpp.h" #include "gs-types.h" #include "lua-utils.h" #include "window_registry.h" @@ -463,11 +464,19 @@ plot_flush (lua_State *L) int plot_show (lua_State *L) { - lua_pushcfunction (L, window_attach); - window_new (L); - lua_pushvalue (L, 1); - lua_pushstring (L, ""); - lua_call (L, 3, 0); + sg_plot* plot = object_check(L, 1, GS_PLOT); + window* win = push_new_object(L, GS_WINDOW, colors::white); + + int slot_id = win->attach (plot, ""); + assert(slot_id>= 0); + window_refs_add (L, slot_id, -1, 1); + + gslshell::ret_status st; + win->start(L, st); + + if (st.error_msg()) + return luaL_error (L, "%s (reported during %s)", st.error_msg(), st.context()); + return 0; } -- cgit v1.2.3

AltStyle によって変換されたページ (->オリジナル) /