Framebuffer requests based on clean/dirty areas.

New routine fbUpdateRequests that builds the update request messages
based on the result of display.getCleanDirtyReset().

- Also, fix fbUpdateRequest to properly accept x,y,xw,yw parameters.
This commit is contained in:
Joel Martin 2011-09-13 14:42:38 -05:00
parent 54e7cbdf8f
commit 832c744578
1 changed files with 33 additions and 13 deletions

View File

@ -20,7 +20,7 @@ var that = {}, // Public API methods
init_vars, updateState, fail, handle_message, init_vars, updateState, fail, handle_message,
init_msg, normal_msg, framebufferUpdate, print_stats, init_msg, normal_msg, framebufferUpdate, print_stats,
pixelFormat, clientEncodings, fbUpdateRequest, pixelFormat, clientEncodings, fbUpdateRequest, fbUpdateRequests,
keyEvent, pointerEvent, clientCutText, keyEvent, pointerEvent, clientCutText,
extract_data_uri, scan_tight_imgQ, extract_data_uri, scan_tight_imgQ,
@ -535,10 +535,10 @@ function genDES(password, challenge) {
function flushClient() { function flushClient() {
if (mouse_arr.length > 0) { if (mouse_arr.length > 0) {
//send(mouse_arr.concat(fbUpdateRequest(1))); //send(mouse_arr.concat(fbUpdateRequests()));
ws.send(mouse_arr); ws.send(mouse_arr);
setTimeout(function() { setTimeout(function() {
ws.send(fbUpdateRequest(1)); ws.send(fbUpdateRequests());
}, 50); }, 50);
mouse_arr = []; mouse_arr = [];
@ -556,7 +556,7 @@ checkEvents = function() {
now = new Date().getTime(); now = new Date().getTime();
if (now > last_req_time + conf.fbu_req_rate) { if (now > last_req_time + conf.fbu_req_rate) {
last_req_time = now; last_req_time = now;
ws.send(fbUpdateRequest(1)); ws.send(fbUpdateRequests());
} }
} }
} }
@ -566,7 +566,7 @@ checkEvents = function() {
keyPress = function(keysym, down) { keyPress = function(keysym, down) {
var arr; var arr;
arr = keyEvent(keysym, down); arr = keyEvent(keysym, down);
arr = arr.concat(fbUpdateRequest(1)); arr = arr.concat(fbUpdateRequests());
ws.send(arr); ws.send(arr);
}; };
@ -796,7 +796,7 @@ init_msg = function() {
response = pixelFormat(); response = pixelFormat();
response = response.concat(clientEncodings()); response = response.concat(clientEncodings());
response = response.concat(fbUpdateRequest(0)); response = response.concat(fbUpdateRequests());
timing.fbu_rt_start = (new Date()).getTime(); timing.fbu_rt_start = (new Date()).getTime();
ws.send(response); ws.send(response);
@ -1316,7 +1316,7 @@ encHandlers.DesktopSize = function set_desktopsize() {
display.viewportChange(0, 0, fb_width, fb_height); display.viewportChange(0, 0, fb_width, fb_height);
timing.fbu_rt_start = (new Date()).getTime(); timing.fbu_rt_start = (new Date()).getTime();
// Send a new non-incremental request // Send a new non-incremental request
ws.send(fbUpdateRequest(0)); ws.send(fbUpdateRequests());
FBU.bytes = 0; FBU.bytes = 0;
FBU.rects -= 1; FBU.rects -= 1;
@ -1418,10 +1418,10 @@ clientEncodings = function() {
fbUpdateRequest = function(incremental, x, y, xw, yw) { fbUpdateRequest = function(incremental, x, y, xw, yw) {
//Util.Debug(">> fbUpdateRequest"); //Util.Debug(">> fbUpdateRequest");
if (!x) { x = 0; } if (typeof(x) !== "undefined") { x = 0; }
if (!y) { y = 0; } if (typeof(y) !== "undefined") { y = 0; }
if (!xw) { xw = fb_width; } if (typeof(xw) !== "undefined") { xw = fb_width; }
if (!yw) { yw = fb_height; } if (typeof(yw) !== "undefined") { yw = fb_height; }
var arr; var arr;
arr = [3]; // msg-type arr = [3]; // msg-type
arr.push8(incremental); arr.push8(incremental);
@ -1433,6 +1433,26 @@ fbUpdateRequest = function(incremental, x, y, xw, yw) {
return arr; return arr;
}; };
// Based on clean/dirty areas, generate requests to send
fbUpdateRequests = function() {
var cleanDirty = display.getCleanDirtyReset(),
arr = [], i, cb, db;
cb = cleanDirty.cleanBox;
if (cb.w > 0 && cb.h > 0) {
// Request incremental for clean box
arr = arr.concat(fbUpdateRequest(1, cb.x, cb.y, cb.w, cb.h));
}
for (i = 0; i < cleanDirty.dirtyBoxes.length; i++) {
db = cleanDirty.dirtyBoxes[i];
// Force all (non-incremental for dirty box
arr = arr.concat(fbUpdateRequest(0, db.x, db.y, db.w, db.h));
}
return arr;
};
keyEvent = function(keysym, down) { keyEvent = function(keysym, down) {
//Util.Debug(">> keyEvent, keysym: " + keysym + ", down: " + down); //Util.Debug(">> keyEvent, keysym: " + keysym + ", down: " + down);
var arr; var arr;
@ -1517,7 +1537,7 @@ that.sendCtrlAltDel = function() {
arr = arr.concat(keyEvent(0xFFFF, 0)); // Delete arr = arr.concat(keyEvent(0xFFFF, 0)); // Delete
arr = arr.concat(keyEvent(0xFFE9, 0)); // Alt arr = arr.concat(keyEvent(0xFFE9, 0)); // Alt
arr = arr.concat(keyEvent(0xFFE3, 0)); // Control arr = arr.concat(keyEvent(0xFFE3, 0)); // Control
arr = arr.concat(fbUpdateRequest(1)); arr = arr.concat(fbUpdateRequests());
ws.send(arr); ws.send(arr);
}; };
@ -1534,7 +1554,7 @@ that.sendKey = function(code, down) {
arr = arr.concat(keyEvent(code, 1)); arr = arr.concat(keyEvent(code, 1));
arr = arr.concat(keyEvent(code, 0)); arr = arr.concat(keyEvent(code, 0));
} }
arr = arr.concat(fbUpdateRequest(1)); arr = arr.concat(fbUpdateRequests());
ws.send(arr); ws.send(arr);
}; };