GUAC-676: Fix flatten(), add missing Guacamole.Display comment.

This commit is contained in:
Michael Jumper
2014-05-12 00:04:47 -07:00
parent 299c341ce0
commit 074e1cf3fa
2 changed files with 33 additions and 20 deletions

View File

@@ -23,6 +23,12 @@
var Guacamole = Guacamole || {}; var Guacamole = Guacamole || {};
/** /**
* The Guacamole display. The display does not deal with the Guacamole
* protocol, and instead implements a set of graphical operations which
* embody the set of operations present in the protocol. The order operations
* are executed is guaranteed to be in the same order as their corresponding
* functions are called.
*
* @constructor * @constructor
*/ */
Guacamole.Display = function() { Guacamole.Display = function() {

View File

@@ -112,19 +112,19 @@ Guacamole.Layer = function(width, height) {
// Only preserve old data if width/height are both non-zero // Only preserve old data if width/height are both non-zero
var oldData = null; var oldData = null;
if (width !== 0 && height !== 0) { if (layer.width !== 0 && layer.height !== 0) {
// Create canvas and context for holding old data // Create canvas and context for holding old data
oldData = document.createElement("canvas"); oldData = document.createElement("canvas");
oldData.width = width; oldData.width = layer.width;
oldData.height = height; oldData.height = layer.height;
var oldDataContext = oldData.getContext("2d"); var oldDataContext = oldData.getContext("2d");
// Copy image data from current // Copy image data from current
oldDataContext.drawImage(canvas, oldDataContext.drawImage(canvas,
0, 0, width, height, 0, 0, layer.width, layer.height,
0, 0, width, height); 0, 0, layer.width, layer.height);
} }
@@ -138,14 +138,14 @@ Guacamole.Layer = function(width, height) {
// Redraw old data, if any // Redraw old data, if any
if (oldData) if (oldData)
context.drawImage(oldData, context.drawImage(oldData,
0, 0, width, height, 0, 0, layer.width, layer.height,
0, 0, width, height); 0, 0, layer.width, layer.height);
// Restore composite operation // Restore composite operation
context.globalCompositeOperation = oldCompositeOperation; context.globalCompositeOperation = oldCompositeOperation;
width = newWidth; layer.width = newWidth;
height = newHeight; layer.height = newHeight;
// Acknowledge reset of stack (happens on resize of canvas) // Acknowledge reset of stack (happens on resize of canvas)
stackSize = 0; stackSize = 0;
@@ -177,21 +177,20 @@ Guacamole.Layer = function(width, height) {
// Determine max width // Determine max width
var resizeWidth; var resizeWidth;
if (opBoundX > width) if (opBoundX > layer.width)
resizeWidth = opBoundX; resizeWidth = opBoundX;
else else
resizeWidth = width; resizeWidth = layer.width;
// Determine max height // Determine max height
var resizeHeight; var resizeHeight;
if (opBoundY > height) if (opBoundY > layer.height)
resizeHeight = opBoundY; resizeHeight = opBoundY;
else else
resizeHeight = height; resizeHeight = layer.height;
// Resize if necessary // Resize if necessary
if (resizeWidth !== width || resizeHeight !== height) layer.resize(resizeWidth, resizeHeight);
resize(resizeWidth, resizeHeight);
} }
@@ -216,6 +215,18 @@ Guacamole.Layer = function(width, height) {
*/ */
this.autosize = false; this.autosize = false;
/**
* The current width of this layer.
* @type Number
*/
this.width = width;
/**
* The current height of this layer.
* @type Number
*/
this.height = height;
/** /**
* Returns the canvas element backing this Layer. * Returns the canvas element backing this Layer.
* @returns {Element} The canvas element backing this Layer. * @returns {Element} The canvas element backing this Layer.
@@ -233,7 +244,7 @@ Guacamole.Layer = function(width, height) {
* @param {Number} newHeight The new height to assign to this Layer. * @param {Number} newHeight The new height to assign to this Layer.
*/ */
this.resize = function(newWidth, newHeight) { this.resize = function(newWidth, newHeight) {
if (newWidth !== width || newHeight !== height) if (newWidth !== layer.width || newHeight !== layer.height)
resize(newWidth, newHeight); resize(newWidth, newHeight);
}; };
@@ -891,7 +902,3 @@ Guacamole.Layer.Pixel = function(r, g, b, a) {
this.alpha = a; this.alpha = a;
}; };
// FIXME: Declaration order hack
Guacamole.Display.VisibleLayer.prototype = new Guacamole.Layer(0, 0);