# HG changeset patch # User Thinker K.F. Li # Date 1281319434 -28800 # Node ID 8b7964869f7a9f54dd2adcd532f72a21853f6e1c # Parent 201cc86720a3a9d3f30cb5d59c0d67ff1f847362 Update window with XImage through XSHM diff -r 201cc86720a3 -r 8b7964869f7a nodejs/Makefile.am --- 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 diff -r 201cc86720a3 -r 8b7964869f7a nodejs/mbfly_njs.m4 --- 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], diff -r 201cc86720a3 -r 8b7964869f7a nodejs/testcase.js --- 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); diff -r 201cc86720a3 -r 8b7964869f7a src/Makefile.am --- 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 diff -r 201cc86720a3 -r 8b7964869f7a src/X_supp.c --- 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); } /* @} */