Mercurial > MadButterfly
changeset 571:13b15b7a463b Android_Skia
Redraw all and changed in Javascript
author | Thinker K.F. Li <thinker@branda.to> |
---|---|
date | Wed, 09 Jun 2010 15:39:24 +0800 |
parents | 49e79253b6d3 |
children | dcd7adb2c0fc df08b68caaf0 |
files | nodejs/X_supp_njs.c nodejs/X_supp_njs.h nodejs/mbfly_njs.cc nodejs/testcase.js |
diffstat | 4 files changed, 57 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/nodejs/X_supp_njs.c Wed Jun 09 15:10:29 2010 +0800 +++ b/nodejs/X_supp_njs.c Wed Jun 09 15:39:24 2010 +0800 @@ -115,6 +115,17 @@ free(rt); } +int +X_njs_MB_flush(njs_runtime_t *rt) { + void *xrt = rt->xrt; + int r; + extern int _X_MB_flush_x_conn_for_nodejs(void *rt); + + _X_MB_flush_x_conn_for_nodejs(xrt); + + return r; +} + njs_runtime_t * X_njs_MB_new(char *display_name, int w, int h) { njs_runtime_t *rt;
--- a/nodejs/X_supp_njs.h Wed Jun 09 15:10:29 2010 +0800 +++ b/nodejs/X_supp_njs.h Wed Jun 09 15:39:24 2010 +0800 @@ -14,6 +14,7 @@ extern void X_njs_MB_init_handle_connection(njs_runtime_t *rt); extern void X_njs_MB_free(njs_runtime_t *rt); extern njs_runtime_t *X_njs_MB_new(char *display_name, int w, int h); +extern int X_njs_MB_flush(njs_runtime_t *rt); extern void *_X_njs_MB_get_X_runtime(njs_runtime_t *rt); #define X_njs_MB_kbevents(rt) X_MB_kbevents((rt)->xrt)
--- a/nodejs/mbfly_njs.cc Wed Jun 09 15:10:29 2010 +0800 +++ b/nodejs/mbfly_njs.cc Wed Jun 09 15:39:24 2010 +0800 @@ -61,6 +61,36 @@ xnjsmb_handle_connection(const Arguments &args) { } +static Handle<Value> +xnjsmb_rt_redraw_changed(const Arguments &args) { + Handle<Object> self = args.This(); + njs_runtime_t *rt; + redraw_man_t *rdman; + + rdman = xnjsmb_rt_rdman(self); + rdman_redraw_changed(rdman); + + rt = (njs_runtime_t *)UNWRAP(self); + X_njs_MB_flush(rt); + + return Null(); +} + +static Handle<Value> +xnjsmb_rt_redraw_all(const Arguments &args) { + Handle<Object> self = args.This(); + njs_runtime_t *rt; + redraw_man_t *rdman; + + rdman = xnjsmb_rt_rdman(self); + rdman_redraw_all(rdman); + + rt = (njs_runtime_t *)UNWRAP(self); + X_njs_MB_flush(rt); + + return Null(); +} + /* @} */ /*! \brief Get rdman associated with the runtime. @@ -106,6 +136,12 @@ func = FunctionTemplate::New(xnjsmb_coord_new); SET(rt_proto_temp, "coord_new", func); + func = FunctionTemplate::New(xnjsmb_rt_redraw_changed); + SET(rt_proto_temp, "redraw_changed", func); + + func = FunctionTemplate::New(xnjsmb_rt_redraw_all); + SET(rt_proto_temp, "redraw_all", func); + /* * Add properties to mb_rt templates for other modules. */
--- a/nodejs/testcase.js Wed Jun 09 15:10:29 2010 +0800 +++ b/nodejs/testcase.js Wed Jun 09 15:39:24 2010 +0800 @@ -12,7 +12,7 @@ [coord[0], coord[1], coord[2], coord[3], coord[4], coord[5]]); sys.puts(mb_rt.path_new); -var path = mb_rt.path_new("m 100,50 L 120,50 L 200,150 L 150,150 z"); +var path = mb_rt.path_new("m 100,50 L 120,50 L 200,150 L 180,150 z"); sys.puts(path); sys.puts(coord.add_shape); coord.add_shape(path); @@ -26,4 +26,12 @@ path.stroke_width = 2; sys.puts(path.stroke_width); +mb_rt.redraw_all(); + +var i = 0; +setInterval(function() { + var deg = (i++) * 0.1; + coord[2] = (i % 20) * 10; + mb_rt.redraw_changed(); + }, 50); setTimeout(function() { sys.puts("timeout"); }, 1000);