]> git.proxmox.com Git - mirror_novnc.git/commitdiff
Don't shift off subencoding in hextile.
authorJoel Martin <github@martintribe.org>
Thu, 20 May 2010 22:13:59 +0000 (17:13 -0500)
committerJoel Martin <github@martintribe.org>
Thu, 20 May 2010 22:13:59 +0000 (17:13 -0500)
include/canvas.js
vnc.js

index 68ddc67784b0d0c99fd6e22da049c24cd1b36cd6..28dcc1bdffc48a4fb52038d4848c3b41006c8e2d 100644 (file)
@@ -183,7 +183,7 @@ setTile: function(img, x, y, w, h, color) {
 
 putTile: function(img) {
     if (Canvas.prefer_js) {
-        Canvas.rgbxImage(img.x, img.y, img.width, img.height, img.data);
+        Canvas.rgbxImage(img.x, img.y, img.width, img.height, img.data, 0);
         //Canvas.ctx.putImageData(img, img.x, img.y);
     } else {
         // No-op, under gecko already done by setTile
@@ -191,18 +191,18 @@ putTile: function(img) {
 },
 
 
-rgbxImage: function(x, y, width, height, arr) {
-    var img, i, data;
+rgbxImage: function(x, y, width, height, arr, offset) {
+    var img, i, j, data;
+    //console.log("rfbxImage: img: " + img + " x: " + x + " y: " + y + " width: " + width + " height: " + height);
     /* Old firefox and Opera don't support createImageData */
     img = Canvas.ctx.getImageData(0, 0, width, height);
-    //console.log("rfbxImage: img: " + img + " x: " + x + " y: " + y + " width: " + width + " height: " + height);
-    //img.data = arr.slice();
     data = img.data;
-    for (i=0; i < (width * height); i++) {
-        data[i*4 + 0] = arr[i*4 + 0];
-        data[i*4 + 1] = arr[i*4 + 1];
-        data[i*4 + 2] = arr[i*4 + 2];
-        data[i*4 + 3] = 255; // Set Alpha
+    for (i=0; i < (width * height * 4); i=i+4) {
+        j=i+offset;
+        data[i + 0] = arr[j + 0];
+        data[i + 1] = arr[j + 1];
+        data[i + 2] = arr[j + 2];
+        data[i + 3] = 255; // Set Alpha
     }
     Canvas.ctx.putImageData(img, x, y);
 
diff --git a/vnc.js b/vnc.js
index 622dba9e9e011abbebc64adf27e19e6d765866b4..0d5286f153e69edc2949314ac5ab1e521e0c121d 100644 (file)
--- a/vnc.js
+++ b/vnc.js
@@ -459,7 +459,7 @@ display_raw: function () {
     cur_y = FBU.y + (FBU.height - FBU.lines);
     cur_height = Math.min(FBU.lines,
                           Math.floor(RQ.length/(FBU.width * RFB.fb_Bpp)));
-    Canvas.rgbxImage(FBU.x, cur_y, FBU.width, cur_height, RQ);
+    Canvas.rgbxImage(FBU.x, cur_y, FBU.width, cur_height, RQ, 0);
     RQ.shiftBytes(FBU.width * cur_height * RFB.fb_Bpp);
     FBU.lines -= cur_height;
 
@@ -601,19 +601,18 @@ display_hextile: function() {
         }
 
         /* We know the encoding and have a whole tile */
-        FBU.subencoding = RQ.shift8();
-        FBU.bytes--;
+        FBU.subencoding = RQ[0];
+        idx = 1;
         if (FBU.subencoding === 0) {
             if (FBU.lastsubencoding & 0x01) {
                 /* Weird: ignore blanks after RAW */
                 console.log("     Ignoring blank after RAW");
-                continue;
+            } else {
+                Canvas.fillRect(x, y, w, h, FBU.background);
             }
-            Canvas.fillRect(x, y, w, h, FBU.background);
         } else if (FBU.subencoding & 0x01) { // Raw
-            Canvas.rgbxImage(x, y, w, h, RQ);
+            Canvas.rgbxImage(x, y, w, h, RQ, idx);
         } else {
-            idx = 0;
             if (FBU.subencoding & 0x02) { // Background
                 FBU.background = RQ.slice(idx, idx + RFB.fb_Bpp);
                 idx += RFB.fb_Bpp;