Commit 48ebcdb1 authored by Joel Martin's avatar Joel Martin

Rename canvas.js routines to not have "rfb" prefix.

- Also, try making set fillStyle called less often.
parent 31af85b9
...@@ -6,6 +6,8 @@ c_wx : 0, ...@@ -6,6 +6,8 @@ c_wx : 0,
c_wy : 0, c_wy : 0,
ctx : null, ctx : null,
prevStyle: "",
mouseDown: function (e) { mouseDown: function (e) {
var evt = e.event || window.event; var evt = e.event || window.event;
e.stop(); e.stop();
...@@ -71,6 +73,8 @@ init: function (id, width, height, keyDown, keyUp, mouseDown, mouseUp) { ...@@ -71,6 +73,8 @@ init: function (id, width, height, keyDown, keyUp, mouseDown, mouseUp) {
if (! c.getContext) return; if (! c.getContext) return;
Canvas.ctx = c.getContext('2d'); Canvas.ctx = c.getContext('2d');
Canvas.prevStyle = "";
console.log("<< init_canvas"); console.log("<< init_canvas");
}, },
...@@ -119,7 +123,7 @@ draw: function () { ...@@ -119,7 +123,7 @@ draw: function () {
Canvas.ctx.putImageData(img, 100, 100); Canvas.ctx.putImageData(img, 100, 100);
}, },
rfbImage: function(x, y, width, height, arr) { rgbxImage: function(x, y, width, height, arr) {
var img = Canvas.ctx.createImageData(width, height); var img = Canvas.ctx.createImageData(width, height);
for (var i=0; i < (width * height); i++) { for (var i=0; i < (width * height); i++) {
img.data[i*4 + 0] = arr[i*4 + 0]; img.data[i*4 + 0] = arr[i*4 + 0];
...@@ -131,8 +135,12 @@ rfbImage: function(x, y, width, height, arr) { ...@@ -131,8 +135,12 @@ rfbImage: function(x, y, width, height, arr) {
}, },
rfbRect: function(x, y, width, height, color) { fillRect: function(x, y, width, height, color) {
Canvas.ctx.fillStyle = "rgb(" + color[0] + "," + color[1] + "," + color[2] + ")"; var newStyle = "rgb(" + color[0] + "," + color[1] + "," + color[2] + ")";
if (newStyle != Canvas.prevStyle) {
Canvas.ctx.fillStyle = newStyle;
prevStyle = newStyle;
}
Canvas.ctx.fillRect(x, y, width, height); Canvas.ctx.fillRect(x, y, width, height);
}, },
......
...@@ -338,7 +338,7 @@ normal_msg: function () { ...@@ -338,7 +338,7 @@ normal_msg: function () {
display_raw: function () { display_raw: function () {
console.log(">> display_raw"); console.log(">> display_raw");
Canvas.rfbImage(FBU.x, FBU.y, FBU.width, FBU.height, RFB.d); Canvas.rgbxImage(FBU.x, FBU.y, FBU.width, FBU.height, RFB.d);
RFB.d.shiftBytes(FBU.width * FBU.height * RFB.fb_Bpp); RFB.d.shiftBytes(FBU.width * FBU.height * RFB.fb_Bpp);
FBU.rects --; FBU.rects --;
}, },
...@@ -357,7 +357,7 @@ display_rre: function () { ...@@ -357,7 +357,7 @@ display_rre: function () {
FBU.subrects = RFB.d.shift32(); FBU.subrects = RFB.d.shift32();
console.log(">> display_rre " + "(" + FBU.subrects + " subrects)"); console.log(">> display_rre " + "(" + FBU.subrects + " subrects)");
var color = RFB.d.shiftBytes(RFB.fb_Bpp); // Background var color = RFB.d.shiftBytes(RFB.fb_Bpp); // Background
Canvas.rfbRect(FBU.x, FBU.y, FBU.width, FBU.height, color); Canvas.fillRect(FBU.x, FBU.y, FBU.width, FBU.height, color);
} }
while ((FBU.subrects > 0) && (RFB.d.length >= (RFB.fb_Bpp + 8))) { while ((FBU.subrects > 0) && (RFB.d.length >= (RFB.fb_Bpp + 8))) {
FBU.subrects --; FBU.subrects --;
...@@ -366,7 +366,7 @@ display_rre: function () { ...@@ -366,7 +366,7 @@ display_rre: function () {
var y = RFB.d.shift16(); var y = RFB.d.shift16();
var width = RFB.d.shift16(); var width = RFB.d.shift16();
var height = RFB.d.shift16(); var height = RFB.d.shift16();
Canvas.rfbRect(FBU.x + x, FBU.y + y, width, height, color); Canvas.fillRect(FBU.x + x, FBU.y + y, width, height, color);
} }
//console.log(" display_rre: rects: " + FBU.rects + ", FBU.subrects: " + FBU.subrects); //console.log(" display_rre: rects: " + FBU.rects + ", FBU.subrects: " + FBU.subrects);
...@@ -452,10 +452,10 @@ display_hextile: function() { ...@@ -452,10 +452,10 @@ display_hextile: function() {
//FBU.lastsubencoding = 0; //FBU.lastsubencoding = 0;
continue; continue;
} else { } else {
Canvas.rfbRect(x, y, w, h, FBU.background); Canvas.fillRect(x, y, w, h, FBU.background);
} }
} else if (FBU.subencoding & 0x01) { // Raw } else if (FBU.subencoding & 0x01) { // Raw
Canvas.rfbImage(x, y, w, h, RFB.d); Canvas.rgbxImage(x, y, w, h, RFB.d);
} else { } else {
var idx = 0; var idx = 0;
if (FBU.subencoding & 0x02) { // Background if (FBU.subencoding & 0x02) { // Background
...@@ -468,7 +468,7 @@ display_hextile: function() { ...@@ -468,7 +468,7 @@ display_hextile: function() {
idx += RFB.fb_Bpp; idx += RFB.fb_Bpp;
//console.log(" foreground: " + FBU.foreground); //console.log(" foreground: " + FBU.foreground);
} }
Canvas.rfbRect(x, y, w, h, FBU.background); Canvas.fillRect(x, y, w, h, FBU.background);
if (FBU.subencoding & 0x08) { // AnySubrects if (FBU.subencoding & 0x08) { // AnySubrects
subrects = RFB.d[idx]; subrects = RFB.d[idx];
idx++; idx++;
...@@ -490,7 +490,7 @@ display_hextile: function() { ...@@ -490,7 +490,7 @@ display_hextile: function() {
sw = (wh >> 4) + 1; sw = (wh >> 4) + 1;
sh = (wh & 0x0f) + 1; sh = (wh & 0x0f) + 1;
Canvas.rfbRect(sx, sy, sw, sh, color); Canvas.fillRect(sx, sy, sw, sh, color);
} }
} }
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment