Skip to content

Commit

Permalink
#1424: paint box support for the html5 client, enabled with debug mode
Browse files Browse the repository at this point in the history
git-svn-id: https://xpra.org/svn/Xpra/trunk@15276 3bb7dfac-3a0b-4e04-842a-767bc560f471
  • Loading branch information
totaam committed Mar 12, 2017
1 parent f10b787 commit 1f0241f
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions src/html5/js/Window.js
Original file line number Diff line number Diff line change
Expand Up @@ -918,6 +918,21 @@ XpraWindow.prototype.may_paint_now = function paint() {
}
}

var DEFAULT_BOX_COLORS = {
"png" : "yellow",
"h264" : "blue",
"vp8" : "green",
"rgb24" : "orange",
"rgb32" : "red",
"jpeg" : "purple",
"png/P" : "indigo",
"png/L" : "teal",
"h265" : "khaki",
"vp9" : "lavender",
"mpeg4" : "black",
"scroll" : "brown",
}

XpraWindow.prototype.do_paint = function paint(x, y, width, height, coding, img_data, packet_sequence, rowstride, options, decode_callback) {
if (this.debug) {
console.debug("do_paint("+img_data.length+" bytes of "+("zlib" in options?"zlib ":"")+coding+" data "+width+"x"+height+" at "+x+","+y+") focused="+this.focused);
Expand All @@ -934,10 +949,19 @@ XpraWindow.prototype.do_paint = function paint(x, y, width, height, coding, img_
enc_width = scaled_size[0];
enc_height = scaled_size[1];
}
function paint_box(color, px, py, pw, ph) {
me.offscreen_canvas_ctx.strokeStyle = color;
me.offscreen_canvas_ctx.lineWidth = "2";
me.offscreen_canvas_ctx.strokeRect(px, py, pw, ph);
}

function painted() {
function painted(skip_box) {
me.paint_pending = false;
decode_callback(me.client);
if (me.debug && !skip_box) {
var color = DEFAULT_BOX_COLORS[coding] || "white";
paint_box(color, x, y, width, height);
}
me.may_paint_now();
}

Expand Down Expand Up @@ -1050,8 +1074,11 @@ XpraWindow.prototype.do_paint = function paint(x, y, width, height, coding, img_
xdelta = scroll_data[4],
ydelta = scroll_data[5];
this.offscreen_canvas_ctx.drawImage(this.offscreen_canvas, sx, sy, sw, sh, sx+xdelta, sy+ydelta, sw, sh);
if (this.debug) {
paint_box("brown", sx+xdelta, sy+ydelta, sw, sh);
}
}
painted();
painted(true);
}
else {
throw "unsupported coding " + coding;
Expand Down

0 comments on commit 1f0241f

Please sign in to comment.