# HG changeset patch # User wycc # Date 1289747400 -28800 # Node ID a3f2fbf791918f8deb7b182b30d6c2a1e2458425 # Parent 9ba94c577a6ffda48db5abef9a32b649e844d361# Parent 652199a55802299e6d22b1f787b6f51330ebb215 merge the head diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/INSTALL.txt --- a/nodejs/INSTALL.txt Sun Nov 14 23:09:02 2010 +0800 +++ b/nodejs/INSTALL.txt Sun Nov 14 23:10:00 2010 +0800 @@ -20,5 +20,5 @@ ~user/MadButterfly/nodejs$ export NODE_PATH=objs/default (5) Execute testsvg.js - ~user/MadButterfly/nodejs$ node testsvg.js + ~user/MadButterfly/nodejs$ ./run examples/testsvg/testsvg.js diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/animate.js --- a/nodejs/animate.js Sun Nov 14 23:09:02 2010 +0800 +++ b/nodejs/animate.js Sun Nov 14 23:10:00 2010 +0800 @@ -15,12 +15,12 @@ x = (this.targetx - this.startposx) * percent + this.startposx; y = (this.targety - this.startposy) * percent + this.startposy; this.obj.center.move(x, y); - this.app.refresh(); + this._app.refresh(); } function shift(app,obj,shiftx,shifty) { obj.animated_shift = this; - this.app = app; + this._app = app; this.obj = obj; this.end = 0; this.targetx = shiftx + obj.center.x; diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/desktop.svg --- a/nodejs/desktop.svg Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,507 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up7:00-7:30 - Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up7:30-8:30 - Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up8:30-9:30 - Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up9:30-10:30 - Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up10:30-11:30 - - diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/desktop/desktop.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/desktop/desktop.svg Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,507 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up7:00-7:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up7:30-8:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up8:30-9:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up9:30-10:30 + Lim JeongHee (J.Lim) & JoKwon (2AM) - The Road to Break Up10:30-11:30 + + diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/desktop/music.png Binary file nodejs/examples/desktop/music.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/desktop/photo.png Binary file nodejs/examples/desktop/photo.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/desktop/testdesktop.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/desktop/testdesktop.js Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,126 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); + +app = new mbapp.app(); +app.loadSVG("desktop.svg"); + +video = app.get("video"); +//var an = new animate.alpha(app,video,0,1); +//an.start(); +audio = app.get("audio"); +picture = app.get("picture"); +setting = app.get("setting"); + +lightbar = app.get("lightbar"); +lines = []; +for(i = 0; i < 5; i++) { + line = app.get("line" + (i + 1)); + lines.push(line); +} +line=0; + +items=[video, audio, picture, setting]; + +item = 0; + +animate.run([new animate.scale(app,items[item], 1, 1.5)], 0, 0.1); +app.refresh(); + +app.addKeyListener(mbapp.KEY_LEFT, function() { + var old = items[item]; + item = item - 1; + if (item == -1) { + item = 0; + return; + } + + var target = items[item]; + + old.bbox.update(); + target.bbox.update(); + + var an = new animate.scale(app, old, 1, 1); + animate.run([an], 0, 0.1); + an = new animate.scale(app, target, 1, 1.5); + animate.run([an], 0, 0.3); +}); + +app.addKeyListener(mbapp.KEY_RIGHT, function() { + var old = items[item]; + item = item + 1; + if (item == items.length) { + item = item - 1; + return; + } + + var target = items[item]; + + old.bbox.update(); + target.bbox.update(); + + var an = new animate.scale(app, old, 1, 1); + animate.run([an], 0, 0.1); + an = new animate.scale(app, target, 1, 1.5); + animate.run([an], 0, 0.3); +}); + +app.addKeyListener(mbapp.KEY_UP, function() { + var old = lines[line]; + line = line - 1; + if (line == -1) { + line = 0; + return; + } + var target = lines[line]; + var sy = target.center.y - lightbar.center.y; + sys.puts(sy); + var an = new animate.shift(app, lightbar, 0, sy); + animate.run([an], 0, 0.3); +}); +app.addKeyListener(mbapp.KEY_DOWN, function() { + var old = lines[line]; + line = line + 1; + if (line == lines.length) { + line = line - 1; + return; + } + var target = lines[line]; + var sy = target.center.y - lightbar.center.y; + sys.puts("line="+line); + sys.puts("sy="+sy); + sys.puts("target.y="+target.center.y); + sys.puts("lightbar.y="+lightbar.center.y); + var an = new animate.shift(app, lightbar, 0, sy); + animate.run([an], 0, 0.3); +}); + +app.addKeyListener(mbapp.KEY_ENTER, function() { + var target = items[item]; + var sx = 500 - target.center.x; + var sy = 220 - target.center.y; + sys.puts("target "+sx+','+sy); + var an = new animate.shift(app,target,sx,sy,1); + an.start(); + for(i=0;i 0.5) x = 900; + else x = -500; + if (y > 0.5) y = 900; + else y = -500; + sx = x - items[i].center.x; + sy = y - items[i].center.y; + an = new animate.shift(app,items[i], sx, sy); + animate.run([an], 0, 2); + alpha = new animate.alpha(app,items[i], 0); + animate.run([an], 0, 1); + } +}); + +app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/desktop/tool.png Binary file nodejs/examples/desktop/tool.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/desktop/video.png Binary file nodejs/examples/desktop/video.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/phone/phone.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/phone/phone.js Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,61 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); + +app = new mbapp.app(":0.0", 320, 480); +app.loadSVG("phone_ui.svg"); + +var icons = []; +var r, c; +var mbname; +for(c = 0; c < 4; c++) { // 4 columns + for(r = 0; r < 5; r++) { // 5 rows + mbname = "icon" + c + "" + r; + icons.push(app.get(mbname)); + } +} + +var overhint, presshint; +var overholder, pressholder; +overhint = app.get("overhint"); +presshint = app.get("presshint"); +overholder = new animate.holder(app, overhint); +pressholder = new animate.holder(app, presshint); + +var dock; +var dockholder; +dock = app.get("dock"); +dockholder = new animate.holder(app, dock); + +var i; +var icon; +for(i = 0; i < icons.length; i++) { + icon = icons[i]; + icon.mouse_event.add_event_observer(1, function(evt) { + overholder.go_center(evt.cur_tgt); + }); + icon.mouse_event.add_event_observer(2, function(evt) { + overholder.home(); + }); + icon.mouse_event.add_event_observer(4, function(evt) { + pressholder.go_center(evt.cur_tgt); + var rotate = new animate.rotate(app, evt.cur_tgt, 2 * 3.1415); + animate.run([rotate], 0, 0.7); + }); +} + +var sw = 0; +var dock_up = new animate.shift(app, dock, 0, -300); +var dock_down = new animate.shift(app, dock, 0, 0); +dock.mouse_event.add_event_observer(4, function(evt) { + if(sw == 0) { + animate.run([dock_up], 0, 0.5); + } else { + animate.run([dock_down], 0, 0.2); + } + sw = sw ^ 1; + }); + +app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/phone/phone_ui.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/phone/phone_ui.svg Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,491 @@ + + + + + + + + + + image/svg+xml + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/simple/sample.png Binary file nodejs/examples/simple/sample.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/simple/testcanvas.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/simple/testcanvas.js Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,31 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var mbapp = require("mbapp"); +var sys=require("sys"); +var canvas=require("canvas"); + +app = new mbapp.app(); + +app.canvas = new canvas.canvas(app,app.mb_rt.root); + +app.canvas.background(0,0,0,1); +app.canvas.rect(0,0,400,400); +app.canvas.strokeWeight(8); +width=200; +height=200; + +setInterval(function() { + app.canvas.clear(); + + for(i=0;i 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase2() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) + coord = mbrt.coord_new(coords[i]); + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase3() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) { + coord = mbrt.coord_new(coords[i]); + shape = mbrt.rect_new(15, 15, 20, 20, 0, 0); + coord.add_shape(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase4() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) { + coord = mbrt.coord_new(coords[i]); + shape = mbrt.path_new("m 10,10 l 55,27 l -30,-3 z"); + coord.add_shape(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase5() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var paint; + + while(true) { + paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); + } +} + +function testcase6() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var paint; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + /* Paint is free, but rdman is dirty */ + paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); + for(j = 0; j < 10; j++) { + coord = mbrt.coord_new(coords[i]); + shape = mbrt.rect_new(5, 5, 20, 20, 0, 0); + coord.add_shape(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +function testcase7() { + var mbrt = new mbfly.mb_rt(":32.0", 300, 200); + var root = mbrt.root; + var coords = []; + var coord; + var shape; + var paint; + var i, j; + + while(true) { + for(i = 0; i < 200; i++) { + coords.push(mbrt.coord_new(root)); + for(j = 0; j < 10; j++) { + /* paint is not free, and rdman is dirty */ + paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); + coord = mbrt.coord_new(coords[i]); + shape = mbrt.path_new("M 100,100 L 30,30 L 0,30 z"); + coord.add_shape(shape); + paint.stroke(shape); + } + } + mbrt.redraw_changed(); + mbrt.flush(); + + while(coords.length > 0) { + coord = coords.pop(); + coord.remove(); + } + } +} + +cproc.exec("killall -9 Xvfb; Xvfb :32 -screen 0 800x600x24"); +setTimeout(function() { + if(process.argv.length == 1) + testcase1(); + else if(process.argv.length == 3) { + sys.puts("testcase " + process.argv[2]); + switch(process.argv[2]) { + case "1": + testcase1(); + break; + + case "2": + testcase2(); + break; + + case "3": + testcase3(); + break; + + case "4": + testcase4(); + break; + + case "5": + testcase5(); + break; + + case "6": + testcase6(); + break; + + case "7": + testcase7(); + break; + + default: + sys.puts("Usage: node testleak.js [1|2|3...7]"); + } + } else + sys.puts("Usage: node testleak.js [1|2|3...7]"); + cproc.exec("killall -9 Xvfb"); + }, 1500); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/testsvg/logo.png Binary file nodejs/examples/testsvg/logo.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/testsvg/svgviewer.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/testsvg/svgviewer.js Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,8 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); + +app = new mbapp.app(); +app.loadSVG("test.svg"); +app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/testsvg/test.svg --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/testsvg/test.svg Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,538 @@ + + + + + + + + + + + + + + + + + image/svg+xml + + + + + + + + + + + item1 + + + item1 + + + item1 + + + item1 + + + item1 + + + item1 + + + item1 + + + item1 + + + item1 + + Menu test + + + + + + + + + + + + + + + + + diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/examples/testsvg/testsvg.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/examples/testsvg/testsvg.js Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,53 @@ +// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- +// vim: sw=4:ts=8:sts=4 +var svg = require("svg"); +var mbapp = require("mbapp"); +var sys=require("sys"); +var animate=require("animate"); +var fs = require("fs"); + +app = new mbapp.app(); +app.loadSVG("test.svg"); +lightbar = app.get("item_lightbar"); +item=1; +var target = app.get("item" + item); +lightbar.center.move_pnt(target.center); + +app.files=fs.readdirSync("/tmp/"); +for(i=1;i<10;i++) { + var o = app.get("item"+i+"text"); + o.set_text(app.files[i]); +} + + + + +app.addKeyListener(mbapp.KEY_UP, function() { + item = item - 1; + if (item == 0) + item = 1; + else { + var target = app.get("item"+item); + var shx = target.center.x - lightbar.center.x; + var shy = target.center.y - lightbar.center.y; + var action = new animate.shift(app, lightbar, shx, shy); + var an = new animate.linear(action, 0, 0.3); + an.start(); + } +}); + +app.addKeyListener(mbapp.KEY_DOWN, function() { + item = item + 1; + if (item == 10) { + item = 9; + } else { + var target = app.get("item"+item); + var shx = target.center.x - lightbar.center.x; + var shy = target.center.y - lightbar.center.y; + var action = new animate.shift(app, lightbar, shx, shy); + var an = new animate.linear(action, 0, 0.3); + an.start(); + } +}); + +app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/logo.png Binary file nodejs/logo.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/music.png Binary file nodejs/music.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/phone.js --- a/nodejs/phone.js Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,61 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var mbapp = require("./mbapp"); -var sys=require("sys"); -var animate=require("./animate"); - -app = new mbapp.app(":0.0", 320, 480); -app.loadSVG("phone_ui.svg"); - -var icons = []; -var r, c; -var mbname; -for(c = 0; c < 4; c++) { // 4 columns - for(r = 0; r < 5; r++) { // 5 rows - mbname = "icon" + c + "" + r; - icons.push(app.get(mbname)); - } -} - -var overhint, presshint; -var overholder, pressholder; -overhint = app.get("overhint"); -presshint = app.get("presshint"); -overholder = new animate.holder(app, overhint); -pressholder = new animate.holder(app, presshint); - -var dock; -var dockholder; -dock = app.get("dock"); -dockholder = new animate.holder(app, dock); - -var i; -var icon; -for(i = 0; i < icons.length; i++) { - icon = icons[i]; - icon.mouse_event.add_event_observer(1, function(evt) { - overholder.go_center(evt.cur_tgt); - }); - icon.mouse_event.add_event_observer(2, function(evt) { - overholder.home(); - }); - icon.mouse_event.add_event_observer(4, function(evt) { - pressholder.go_center(evt.cur_tgt); - var rotate = new animate.rotate(app, evt.cur_tgt, 2 * 3.1415); - animate.run([rotate], 0, 0.7); - }); -} - -var sw = 0; -var dock_up = new animate.shift(app, dock, 0, -300); -var dock_down = new animate.shift(app, dock, 0, 0); -dock.mouse_event.add_event_observer(4, function(evt) { - if(sw == 0) { - animate.run([dock_up], 0, 0.5); - } else { - animate.run([dock_down], 0, 0.2); - } - sw = sw ^ 1; - }); - -app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/phone_ui.svg --- a/nodejs/phone_ui.svg Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,491 +0,0 @@ - - - - - - - - - - image/svg+xml - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/photo.png Binary file nodejs/photo.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/run.sh --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/nodejs/run.sh Sun Nov 14 23:10:00 2010 +0800 @@ -0,0 +1,11 @@ +#!/bin/sh + +ABS=`realpath $0` +BASE=`dirname $ABS` +NODE_PATH=$BASE:$BASE/objs/default:$NODE_PATH +export NODE_PATH + +DIR=`dirname $1` +FNAME=`basename $1` + +cd $DIR; node $FNAME diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/sample.png Binary file nodejs/sample.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/svg.js --- a/nodejs/svg.js Sun Nov 14 23:09:02 2010 +0800 +++ b/nodejs/svg.js Sun Nov 14 23:10:00 2010 +0800 @@ -453,8 +453,7 @@ var c = this.owner; var mtx; - if(c.type != "coord") - c = c.parent; // is a shape! + c = c.parent; mtx = c._mbapp_saved_rev_mtx; while(c.parent && typeof c.parent != "undefined") { @@ -469,8 +468,7 @@ var c = this.owner; var mtx; - if(c.type != "coord") - c = c.parent; // is a shape! + c = c.parent; mtx = [c[0], c[1], c[2], c[3], c[4], c[5]]; while(c.parent) { @@ -509,8 +507,7 @@ var c = this.owner; var mtx; - if(c.type != "coord") - c = c.parent; // is a shape! + c = c.parent; mtx = c._mbapp_saved_rev_mtx; while(c.parent && typeof c.parent != "undefined") { @@ -525,8 +522,7 @@ var c = this.owner; var mtx; - if(c.type != "coord") - c = c.parent; // is a shape! + c = c.parent; mtx = [c[0], c[1], c[2], c[3], c[4], c[5]]; while(c.parent) { @@ -611,6 +607,8 @@ */ get y() { return this._y; }, + /*! \brief Center position in the relative space defined by parent. + */ get rel() { var rev; var xy; diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/svgviewer.js --- a/nodejs/svgviewer.js Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,8 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var svg = require("./svg"); -var mbapp = require("./mbapp"); - -app = new mbapp.app(); -app.loadSVG("test.svg"); -app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/test.svg --- a/nodejs/test.svg Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,358 +0,0 @@ - - - - - - - - - - - - - - - - - image/svg+xml - - - - - - - - - - - item1 - - - item1 - - - item1 - - - item1 - - - item1 - - - item1 - - - item1 - - - item1 - - - item1 - - Menu test - - - - - - - - - - - - - - - - - diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/testcanvas.js --- a/nodejs/testcanvas.js Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,31 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var mbapp = require("./mbapp"); -var sys=require("sys"); -var canvas=require("./canvas"); - -app = new mbapp.app(); - -app.canvas = new canvas.canvas(app,app.mb_rt.root); - -app.canvas.background(0,0,0,1); -app.canvas.rect(0,0,400,400); -app.canvas.strokeWeight(8); -width=200; -height=200; - -setInterval(function() { - app.canvas.clear(); - - for(i=0;i 0.5) x = 900; - else x = -500; - if (y > 0.5) y = 900; - else y = -500; - sx = x - items[i].center.x; - sy = y - items[i].center.y; - an = new animate.shift(app,items[i], sx, sy); - animate.run([an], 0, 2); - alpha = new animate.alpha(app,items[i], 0); - animate.run([an], 0, 1); - } -}); - -app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/testimage.js --- a/nodejs/testimage.js Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,19 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var svg = require("./svg"); -var mbapp = require("./mbapp"); -var sys=require("sys"); -var animate=require("./animate"); -var fs = require("fs"); - -app = new mbapp.app(); - -coord = app.mb_rt.coord_new(app.mb_rt.root); -data=mbapp.ldr.load("sample.png"); -paint = app.mb_rt.paint_image_new(data); -img = app.mb_rt.image_new(10,10,50,50); -paint.fill(img); -coord.opacity = 0.9; -coord.add_shape(img); - -app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/testleak.js --- a/nodejs/testleak.js Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,217 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var mbfly = require("mbfly"); -var sys = require("sys"); -var cproc = require("child_process"); - -function testcase1() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var i; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase2() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) - coord = mbrt.coord_new(coords[i]); - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase3() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) { - coord = mbrt.coord_new(coords[i]); - shape = mbrt.rect_new(15, 15, 20, 20, 0, 0); - coord.add_shape(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase4() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) { - coord = mbrt.coord_new(coords[i]); - shape = mbrt.path_new("m 10,10 l 55,27 l -30,-3 z"); - coord.add_shape(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase5() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var paint; - - while(true) { - paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); - } -} - -function testcase6() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var paint; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - /* Paint is free, but rdman is dirty */ - paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); - for(j = 0; j < 10; j++) { - coord = mbrt.coord_new(coords[i]); - shape = mbrt.rect_new(5, 5, 20, 20, 0, 0); - coord.add_shape(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -function testcase7() { - var mbrt = new mbfly.mb_rt(":32.0", 300, 200); - var root = mbrt.root; - var coords = []; - var coord; - var shape; - var paint; - var i, j; - - while(true) { - for(i = 0; i < 200; i++) { - coords.push(mbrt.coord_new(root)); - for(j = 0; j < 10; j++) { - /* paint is not free, and rdman is dirty */ - paint = mbrt.paint_color_new(0.5, 0.5, 0.5, 1); - coord = mbrt.coord_new(coords[i]); - shape = mbrt.path_new("M 100,100 L 30,30 L 0,30 z"); - coord.add_shape(shape); - paint.stroke(shape); - } - } - mbrt.redraw_changed(); - mbrt.flush(); - - while(coords.length > 0) { - coord = coords.pop(); - coord.remove(); - } - } -} - -cproc.exec("killall -9 Xvfb; Xvfb :32 -screen 0 800x600x24"); -setTimeout(function() { - if(process.argv.length == 1) - testcase1(); - else if(process.argv.length == 3) { - sys.puts("testcase " + process.argv[2]); - switch(process.argv[2]) { - case "1": - testcase1(); - break; - - case "2": - testcase2(); - break; - - case "3": - testcase3(); - break; - - case "4": - testcase4(); - break; - - case "5": - testcase5(); - break; - - case "6": - testcase6(); - break; - - case "7": - testcase7(); - break; - - default: - sys.puts("Usage: node testleak.js [1|2|3...7]"); - } - } else - sys.puts("Usage: node testleak.js [1|2|3...7]"); - cproc.exec("killall -9 Xvfb"); - }, 1500); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/testsvg.js --- a/nodejs/testsvg.js Sun Nov 14 23:09:02 2010 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,45 +0,0 @@ -// -*- indent-tabs-mode: t; tab-width: 8; c-basic-offset: 4; -*- -// vim: sw=4:ts=8:sts=4 -var svg = require("./svg"); -var mbapp = require("./mbapp"); -var sys=require("sys"); -var animate=require("./animate"); -var fs = require("fs"); - -app = new mbapp.app(); -app.loadSVG("test.svg"); -lightbar = app.get("item_lightbar"); -item=1; -lightbar[5] = app.get("item"+item)[5]; - -app.files=fs.readdirSync("/tmp/"); -for(i=1;i<10;i++) { - var o = app.get("item"+i+"text"); - o.set_text(app.files[i]); -} - - - - -app.addKeyListener(mbapp.KEY_UP, function() { - item = item - 1; - if (item == 0) item = 1; - else { - var target = app.get("item"+item); - var an = new animate.linear(app,lightbar,target[2],target[5],0.3); - an.start(); - } -}); - -app.addKeyListener(mbapp.KEY_DOWN, function() { - item = item + 1; - if (item == 10) { - item = 9; - } else { - var target = app.get("item"+item); - var an = new animate.linear(app,lightbar,target[2],target[5],0.3); - an.start(); - } -}); - -app.loop(); diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/tool.png Binary file nodejs/tool.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 nodejs/video.png Binary file nodejs/video.png has changed diff -r 9ba94c577a6f -r a3f2fbf79191 src/redraw_man.c --- a/src/redraw_man.c Sun Nov 14 23:09:02 2010 +0800 +++ b/src/redraw_man.c Sun Nov 14 23:10:00 2010 +0800 @@ -1828,8 +1828,22 @@ n_areas = _coord_get_dirty_areas(coord)->num; areas = _coord_get_dirty_areas(coord)->ds; - if(n_areas == 0) - abort(); /* should not happen! */ + if(n_areas == 0) { + /* Go here for cached one that is descendant of another zeroed + * one, but itself is not zeroed. It is here for recomputing + * pcache areas. + */ + if(coord_get_flags(coord, COF_JUST_CLEAN | COF_JUST_ZERO)) + abort(); /* should not happen! */ + + parent = coord_get_parent(coord); + pcached_coord = coord_get_cached(parent); + area = coord_get_pcache_area(coord); + add_dirty_area(rdman, pcached_coord, area); + area = coord_get_pcache_last_area(coord); + add_dirty_area(rdman, pcached_coord, area); + return; + } area0 = _coord_get_aggr_dirty_areas(coord); area1 = area0 + 1;