mirror of
https://github.com/gyurix1968/guacamole-client.git
synced 2025-09-07 13:41:21 +00:00
Minor performance enhancements - do NOT take thumbnails every 1000ms, and only use transfer function if not NOP and not a simple copy.
This commit is contained in:
@@ -1470,21 +1470,35 @@ Guacamole.Client = function(tunnel) {
|
||||
var srcY = parseInt(parameters[2]);
|
||||
var srcWidth = parseInt(parameters[3]);
|
||||
var srcHeight = parseInt(parameters[4]);
|
||||
var transferFunction = Guacamole.Client.DefaultTransferFunction[parameters[5]];
|
||||
var function_index = parseInt(parameters[5]);
|
||||
var dstL = getLayer(parseInt(parameters[6]));
|
||||
var dstX = parseInt(parameters[7]);
|
||||
var dstY = parseInt(parameters[8]);
|
||||
|
||||
dstL.transfer(
|
||||
srcL,
|
||||
srcX,
|
||||
srcY,
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
dstX,
|
||||
dstY,
|
||||
transferFunction
|
||||
);
|
||||
/* SRC */
|
||||
if (function_index === 0x3)
|
||||
dstL.put(
|
||||
srcL,
|
||||
srcX,
|
||||
srcY,
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
dstX,
|
||||
dstY
|
||||
);
|
||||
|
||||
/* Anything else that isn't a NO-OP */
|
||||
else if (function_index !== 0x5)
|
||||
dstL.transfer(
|
||||
srcL,
|
||||
srcX,
|
||||
srcY,
|
||||
srcWidth,
|
||||
srcHeight,
|
||||
dstX,
|
||||
dstY,
|
||||
Guacamole.Client.DefaultTransferFunction[function_index]
|
||||
);
|
||||
|
||||
},
|
||||
|
||||
|
@@ -647,6 +647,51 @@ Guacamole.Layer = function(width, height) {
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Put a rectangle of image data from one Layer to this Layer directly
|
||||
* without performing any alpha blending. Simply copy the data.
|
||||
*
|
||||
* @param {Guacamole.Layer} srcLayer The Layer to copy image data from.
|
||||
* @param {Number} srcx The X coordinate of the upper-left corner of the
|
||||
* rectangle within the source Layer's coordinate
|
||||
* space to copy data from.
|
||||
* @param {Number} srcy The Y coordinate of the upper-left corner of the
|
||||
* rectangle within the source Layer's coordinate
|
||||
* space to copy data from.
|
||||
* @param {Number} srcw The width of the rectangle within the source Layer's
|
||||
* coordinate space to copy data from.
|
||||
* @param {Number} srch The height of the rectangle within the source
|
||||
* Layer's coordinate space to copy data from.
|
||||
* @param {Number} x The destination X coordinate.
|
||||
* @param {Number} y The destination Y coordinate.
|
||||
*/
|
||||
this.put = function(srcLayer, srcx, srcy, srcw, srch, x, y) {
|
||||
scheduleTaskSynced(srcLayer, function() {
|
||||
|
||||
var srcCanvas = srcLayer.getCanvas();
|
||||
|
||||
// If entire rectangle outside source canvas, stop
|
||||
if (srcx >= srcCanvas.width || srcy >= srcCanvas.height) return;
|
||||
|
||||
// Otherwise, clip rectangle to area
|
||||
if (srcx + srcw > srcCanvas.width)
|
||||
srcw = srcCanvas.width - srcx;
|
||||
|
||||
if (srcy + srch > srcCanvas.height)
|
||||
srch = srcCanvas.height - srcy;
|
||||
|
||||
// Stop if nothing to draw.
|
||||
if (srcw == 0 || srch == 0) return;
|
||||
|
||||
if (layer.autosize != 0) fitRect(x, y, srcw, srch);
|
||||
|
||||
// Get image data from src and dst
|
||||
var src = srcLayer.getCanvas().getContext("2d").getImageData(srcx, srcy, srcw, srch);
|
||||
displayContext.putImageData(src, x, y);
|
||||
|
||||
});
|
||||
};
|
||||
|
||||
/**
|
||||
* Copy a rectangle of image data from one Layer to this Layer. This
|
||||
* operation will copy exactly the image data that will be drawn once all
|
||||
|
@@ -933,24 +933,6 @@ GuacUI.Client.attach = function(guac) {
|
||||
|
||||
};
|
||||
|
||||
var thumbnail_update_interval = null;
|
||||
|
||||
window.onblur = function() {
|
||||
|
||||
// Regularly update screenshot if window not visible
|
||||
if (!thumbnail_update_interval)
|
||||
thumbnail_update_interval =
|
||||
window.setInterval(GuacUI.Client.updateThumbnail, 1000);
|
||||
|
||||
};
|
||||
|
||||
window.onfocus = function() {
|
||||
if (thumbnail_update_interval) {
|
||||
window.clearInterval(thumbnail_update_interval);
|
||||
thumbnail_update_interval = null;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
* Disconnect and update thumbnail on close
|
||||
*/
|
||||
|
Reference in New Issue
Block a user