diff options
author | Christian Beier <dontmind@freeshell.org> | 2012-08-19 15:34:40 +0200 |
---|---|---|
committer | Christian Beier <dontmind@freeshell.org> | 2012-08-19 15:34:40 +0200 |
commit | 2b4f616d96f92dc6596f8f4836582048dd57a3a5 (patch) | |
tree | aeaac6647bb0320de605e40905702066144ce786 /webclients/novnc/include/display.js | |
parent | 2fba1be4536511696a266fb504c60167d3015038 (diff) | |
download | libtdevnc-2b4f616d96f92dc6596f8f4836582048dd57a3a5.tar.gz libtdevnc-2b4f616d96f92dc6596f8f4836582048dd57a3a5.zip |
Update noVNC webclient.
Diffstat (limited to 'webclients/novnc/include/display.js')
-rw-r--r-- | webclients/novnc/include/display.js | 61 |
1 files changed, 59 insertions, 2 deletions
diff --git a/webclients/novnc/include/display.js b/webclients/novnc/include/display.js index f2ecdba..5ad99ba 100644 --- a/webclients/novnc/include/display.js +++ b/webclients/novnc/include/display.js @@ -1,6 +1,6 @@ /* * noVNC: HTML5 VNC client - * Copyright (C) 2011 Joel Martin + * Copyright (C) 2012 Joel Martin * Licensed under LGPL-3 (see LICENSE.txt) * * See README.md for usage and integration instructions. @@ -19,9 +19,12 @@ var that = {}, // Public API methods c_ctx = null, c_forceCanvas = false, + // Queued drawing actions for in-order rendering + renderQ = [], + // Predefine function variables (jslint) imageDataGet, rgbImageData, bgrxImageData, cmapImageData, - setFillColor, rescale, + setFillColor, rescale, scan_renderQ, // The full frame buffer (logical canvas) size fb_width = 0, @@ -412,6 +415,8 @@ that.clear = function() { c_ctx.clearRect(0, 0, viewport.w, viewport.h); } + renderQ = []; + // No benefit over default ("source-over") in Chrome and firefox //c_ctx.globalCompositeOperation = "copy"; }; @@ -577,6 +582,58 @@ that.blitStringImage = function(str, x, y) { img.src = str; }; +// Wrap ctx.drawImage but relative to viewport +that.drawImage = function(img, x, y) { + c_ctx.drawImage(img, x - viewport.x, y - viewport.y); +}; + +that.renderQ_push = function(action) { + renderQ.push(action); + if (renderQ.length === 1) { + // If this can be rendered immediately it will be, otherwise + // the scanner will start polling the queue (every + // requestAnimationFrame interval) + scan_renderQ(); + } +}; + +scan_renderQ = function() { + var a, ready = true; + while (ready && renderQ.length > 0) { + a = renderQ[0]; + switch (a.type) { + case 'copy': + that.copyImage(a.old_x, a.old_y, a.x, a.y, a.width, a.height); + break; + case 'fill': + that.fillRect(a.x, a.y, a.width, a.height, a.color); + break; + case 'blit': + that.blitImage(a.x, a.y, a.width, a.height, a.data, 0); + break; + case 'blitRgb': + that.blitRgbImage(a.x, a.y, a.width, a.height, a.data, 0); + break; + case 'img': + if (a.img.complete) { + that.drawImage(a.img, a.x, a.y); + } else { + // We need to wait for this image to 'load' + // to keep things in-order + ready = false; + } + break; + } + if (ready) { + a = renderQ.shift(); + } + } + if (renderQ.length > 0) { + requestAnimFrame(scan_renderQ); + } +}; + + that.changeCursor = function(pixels, mask, hotx, hoty, w, h) { if (conf.cursor_uri === false) { Util.Warn("changeCursor called but no cursor data URI support"); |