Mercurial > MadButterfly
changeset 693:8b7964869f7a
Update window with XImage through XSHM
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Mon, 09 Aug 2010 10:03:54 +0800 |
parents | 201cc86720a3 |
children | 7e64e0f70cb6 |
files | nodejs/Makefile.am nodejs/mbfly_njs.m4 nodejs/testcase.js src/Makefile.am src/X_supp.c |
diffstat | 5 files changed, 33 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/nodejs/Makefile.am Mon Aug 09 09:09:19 2010 +0800 +++ b/nodejs/Makefile.am Mon Aug 09 10:03:54 2010 +0800 @@ -5,7 +5,7 @@ -I$(abs_top_srcdir)/include \ -I$(prefix)/include \ @pangocairo_CFLAGS@ $(CFLAGS) -mbfly_node_LDFLAGS = -L$(abs_top_builddir)/src/.libs @pangocairo_LIBS@ +mbfly_node_LDFLAGS = -L$(abs_top_builddir)/src/.libs @pangocairo_LIBS@ -lXext all: mbfly.node clean: clean-mbfly-node
--- a/nodejs/mbfly_njs.m4 Mon Aug 09 09:09:19 2010 +0800 +++ b/nodejs/mbfly_njs.m4 Mon Aug 09 10:03:54 2010 +0800 @@ -8,6 +8,7 @@ (([MOD], [xnjsmb_mb_rt_objs_mod]))), METHOD([redraw_changed], [xnjsmb_redraw_changed], (), 0, []), METHOD([redraw_all], [xnjsmb_redraw_all], (), 0, []), + METHOD([flush], [X_njs_MB_flush], (), 0, []), METHOD([path_new], [xnjsmb_path_new], (STR(txt)), 1, [OBJ([path], [shape_t])], (([MOD], [xnjsmb_mb_rt_objs_mod]))), METHOD([stext_new], [xnjsmb_stext_new],
--- a/nodejs/testcase.js Mon Aug 09 09:09:19 2010 +0800 +++ b/nodejs/testcase.js Mon Aug 09 10:03:54 2010 +0800 @@ -56,6 +56,7 @@ var deg = (i++) * 0.1; coord[2] = (i % 20) * 10; mb_rt.redraw_changed(); + mb_rt.flush(); }, 20); setTimeout(function() { sys.puts("timeout"); }, 1000);
--- a/src/Makefile.am Mon Aug 09 09:09:19 2010 +0800 +++ b/src/Makefile.am Mon Aug 09 10:03:54 2010 +0800 @@ -40,7 +40,7 @@ libmbfly_la_SOURCES += graph_engine_cairo.c libmbfly_la_CPPFLAGS = @cairo_CFLAGS@ @pangocairo_CFLAGS@ -libmbfly_la_LDFLAGS = @cairo_LIBS@ @pangocairo_LIBS@ +libmbfly_la_LDFLAGS = @cairo_LIBS@ @pangocairo_LIBS@ -lXext endif if SKIA_GRAPH_ENGINE
--- a/src/X_supp.c Mon Aug 09 09:09:19 2010 +0800 +++ b/src/X_supp.c Mon Aug 09 10:03:54 2010 +0800 @@ -69,6 +69,23 @@ #endif }; +#ifdef XSHM +static void +XSHM_update(X_MB_runtime_t *xmb_rt) { + GC gc; + + gc = DefaultGC(xmb_rt->display, DefaultScreen(xmb_rt->display)); + if(xmb_rt->ximage) { /* support XSHM */ + XShmPutImage(xmb_rt->display, + xmb_rt->win, + gc, + xmb_rt->ximage, + 0, 0, 0, 0, + xmb_rt->w, xmb_rt->h, 0); + } +} +#endif + /*! \defgroup xkb X Keyboard Handling * * Accept keyboard events from X server and delivery it to @@ -343,6 +360,9 @@ rdman_redraw_area(rdman, ex1, ey1, (ex2 - ex1), (ey2 - ey1)); eflag = 0; } +#ifdef XSHM + XSHM_update(rt); +#endif XFlush(display); } @@ -401,6 +421,9 @@ get_now(&now); mb_tman_handle_timeout(tman, &now); rdman_redraw_changed(rdman); +#ifdef XSHM + XSHM_update(rt); +#endif XFlush(display); } else if(FD_ISSET(fd, &rfds)){ handle_x_event(rt); @@ -585,7 +608,7 @@ xmb_rt->surface_ptn = mbe_pattern_create_for_surface(xmb_rt->surface); - if(xmb_rt->backend_surface != NULL) /* xshm_init() may create one */ + if(xmb_rt->backend_surface == NULL) /* xshm_init() may create one */ xmb_rt->backend_surface = mbe_xlib_surface_create(xmb_rt->display, xmb_rt->win, @@ -778,7 +801,11 @@ /*! \brief Flush buffer for the X connection of a runtime object. */ int _X_MB_flush_x_conn_for_nodejs(void *rt) { - return XFlush(((X_MB_runtime_t *)rt)->display); + X_MB_runtime_t *xmb_rt = (X_MB_runtime_t *)rt; +#ifdef XSHM + XSHM_update(xmb_rt); +#endif + return XFlush(xmb_rt->display); } /* @} */