2 /* ***** BEGIN LICENSE BLOCK *****
3 * Version: MPL 1.1/GPL 2.0/LGPL 2.1
5 * The contents of this file are subject to the Mozilla Public License Version
6 * 1.1 (the "License"); you may not use this file except in compliance with
7 * the License. You may obtain a copy of the License at
8 * http://www.mozilla.org/MPL/
10 * Software distributed under the License is distributed on an "AS IS" basis,
11 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
12 * for the specific language governing rights and limitations under the
15 * The Original Code is guacamole-common-js.
17 * The Initial Developer of the Original Code is
19 * Portions created by the Initial Developer are Copyright (C) 2010
20 * the Initial Developer. All Rights Reserved.
24 * Alternatively, the contents of this file may be used under the terms of
25 * either the GNU General Public License Version 2 or later (the "GPL"), or
26 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
27 * in which case the provisions of the GPL or the LGPL are applicable instead
28 * of those above. If you wish to allow use of your version of this file only
29 * under the terms of either the GPL or the LGPL, and not to allow others to
30 * use your version of this file under the terms of the MPL, indicate your
31 * decision by deleting the provisions above and replace them with the notice
32 * and other provisions required by the GPL or the LGPL. If you do not delete
33 * the provisions above, a recipient may use your version of this file under
34 * the terms of any one of the MPL, the GPL or the LGPL.
36 * ***** END LICENSE BLOCK ***** */
39 * Namespace for all Guacamole JavaScript objects.
42 var Guacamole = Guacamole || {};
45 * Abstract ordered drawing surface. Each Layer contains a canvas element and
46 * provides simple drawing instructions for drawing to that canvas element,
47 * however unlike the canvas element itself, drawing operations on a Layer are
48 * guaranteed to run in order, even if such an operation must wait for an image
49 * to load before completing.
53 * @param {Number} width The width of the Layer, in pixels. The canvas element
54 * backing this Layer will be given this width.
56 * @param {Number} height The height of the Layer, in pixels. The canvas element
57 * backing this Layer will be given this height.
59 Guacamole.Layer = function(width, height) {
62 * Reference to this Layer.
68 * The canvas element backing this Layer.
71 var display = document.createElement("canvas");
74 * The 2D display context of the canvas element backing this Layer.
77 var displayContext = display.getContext("2d");
78 displayContext.save();
81 * The queue of all pending Tasks. Tasks will be run in order, with new
82 * tasks added at the end of the queue and old tasks removed from the
83 * front of the queue (FIFO).
86 var tasks = new Array();
89 * Whether a new path should be started with the next path drawing
93 var pathClosed = true;
96 * The number of states on the state stack.
98 * Note that there will ALWAYS be one element on the stack, but that
99 * element is not exposed. It is only used to reset the layer to its
107 * Map of all Guacamole channel masks to HTML5 canvas composite operation
108 * names. Not all channel mask combinations are currently implemented.
111 var compositeOperation = {
112 /* 0x0 NOT IMPLEMENTED */
113 0x1: "destination-in",
114 0x2: "destination-out",
115 /* 0x3 NOT IMPLEMENTED */
117 /* 0x5 NOT IMPLEMENTED */
119 /* 0x7 NOT IMPLEMENTED */
121 0x9: "destination-atop",
123 0xB: "destination-over",
125 /* 0xD NOT IMPLEMENTED */
131 * Resizes the canvas element backing this Layer without testing the
132 * new size. This function should only be used internally.
135 * @param {Number} newWidth The new width to assign to this Layer.
136 * @param {Number} newHeight The new height to assign to this Layer.
138 function resize(newWidth, newHeight) {
140 // Only preserve old data if width/height are both non-zero
142 if (width != 0 && height != 0) {
144 // Create canvas and context for holding old data
145 oldData = document.createElement("canvas");
146 oldData.width = width;
147 oldData.height = height;
149 var oldDataContext = oldData.getContext("2d");
151 // Copy image data from current
152 oldDataContext.drawImage(display,
154 0, 0, width, height);
158 // Preserve composite operation
159 var oldCompositeOperation = displayContext.globalCompositeOperation;
162 display.width = newWidth;
163 display.height = newHeight;
165 // Redraw old data, if any
167 displayContext.drawImage(oldData,
169 0, 0, width, height);
171 // Restore composite operation
172 displayContext.globalCompositeOperation = oldCompositeOperation;
177 // Acknowledge reset of stack (happens on resize of canvas)
179 displayContext.save();
184 * Given the X and Y coordinates of the upper-left corner of a rectangle
185 * and the rectangle's width and height, resize the backing canvas element
186 * as necessary to ensure that the rectangle fits within the canvas
187 * element's coordinate space. This function will only make the canvas
188 * larger. If the rectangle already fits within the canvas element's
189 * coordinate space, the canvas is left unchanged.
192 * @param {Number} x The X coordinate of the upper-left corner of the
194 * @param {Number} y The Y coordinate of the upper-left corner of the
196 * @param {Number} w The width of the the rectangle to fit.
197 * @param {Number} h The height of the the rectangle to fit.
199 function fitRect(x, y, w, h) {
202 var opBoundX = w + x;
203 var opBoundY = h + y;
205 // Determine max width
207 if (opBoundX > width)
208 resizeWidth = opBoundX;
212 // Determine max height
214 if (opBoundY > height)
215 resizeHeight = opBoundY;
217 resizeHeight = height;
219 // Resize if necessary
220 if (resizeWidth != width || resizeHeight != height)
221 resize(resizeWidth, resizeHeight);
226 * A container for an task handler. Each operation which must be ordered
227 * is associated with a Task that goes into a task queue. Tasks in this
228 * queue are executed in order once their handlers are set, while Tasks
229 * without handlers block themselves and any following Tasks from running.
233 * @param {function} taskHandler The function to call when this task
235 * @param {boolean} blocked Whether this task should start blocked.
237 function Task(taskHandler, blocked) {
242 * Whether this Task is blocked.
246 this.blocked = blocked;
249 * The handler this Task is associated with, if any.
253 this.handler = taskHandler;
256 * Unblocks this Task, allowing it to run.
258 this.unblock = function() {
259 task.blocked = false;
260 handlePendingTasks();
266 * If no tasks are pending or running, run the provided handler immediately,
267 * if any. Otherwise, schedule a task to run immediately after all currently
268 * running or pending tasks are complete.
271 * @param {function} handler The function to call when possible, if any.
272 * @param {boolean} blocked Whether the task should start blocked.
273 * @returns {Task} The Task created and added to the queue for future
274 * running, if any, or null if the handler was run
275 * immediately and no Task needed to be created.
277 function scheduleTask(handler, blocked) {
279 // If no pending tasks, just call (if available) and exit
280 if (layer.isReady() && !blocked) {
281 if (handler) handler();
285 // If tasks are pending/executing, schedule a pending task
286 // and return a reference to it.
287 var task = new Task(handler, blocked);
293 var tasksInProgress = false;
296 * Run any Tasks which were pending but are now ready to run and are not
297 * blocked by other Tasks.
300 function handlePendingTasks() {
305 tasksInProgress = true;
307 // Draw all pending tasks.
309 while ((task = tasks[0]) != null && !task.blocked) {
311 if (task.handler) task.handler();
314 tasksInProgress = false;
319 * Schedules a task within the current layer just as scheduleTast() does,
320 * except that another specified layer will be blocked until this task
321 * completes, and this task will not start until the other layer is
324 * Essentially, a task is scheduled in both layers, and the specified task
325 * will only be performed once both layers are ready, and neither layer may
326 * proceed until this task completes.
328 * Note that there is no way to specify whether the task starts blocked,
329 * as whether the task is blocked depends completely on whether the
330 * other layer is currently ready.
333 * @param {Guacamole.Layer} otherLayer The other layer which must be blocked
334 * until this task completes.
335 * @param {function} handler The function to call when possible.
337 function scheduleTaskSynced(otherLayer, handler) {
339 // If we ARE the other layer, no need to sync.
340 // Syncing would result in deadlock.
341 if (layer === otherLayer)
342 scheduleTask(handler);
344 // Otherwise synchronize operation with other layer
347 var drawComplete = false;
348 var layerLock = null;
350 function performTask() {
355 // Unblock the other layer now that draw is complete
356 if (layerLock != null)
359 // Flag operation as done
364 // Currently blocked draw task
365 var task = scheduleTask(performTask, true);
367 // Unblock draw task once source layer is ready
368 otherLayer.sync(task.unblock);
370 // Block other layer until draw completes
371 // Note that the draw MAY have already been performed at this point,
372 // in which case creating a lock on the other layer will lead to
373 // deadlock (the draw task has already run and will thus never
376 layerLock = otherLayer.sync(null, true);
382 * Set to true if this Layer should resize itself to accomodate the
383 * dimensions of any drawing operation, and false (the default) otherwise.
385 * Note that setting this property takes effect immediately, and thus may
386 * take effect on operations that were started in the past but have not
387 * yet completed. If you wish the setting of this flag to only modify
388 * future operations, you will need to make the setting of this flag an
389 * operation with sync().
392 * // Set autosize to true for all future operations
393 * layer.sync(function() {
394 * layer.autosize = true;
400 this.autosize = false;
403 * Returns the canvas element backing this Layer.
404 * @returns {Element} The canvas element backing this Layer.
406 this.getCanvas = function() {
411 * Returns whether this Layer is ready. A Layer is ready if it has no
412 * pending operations and no operations in-progress.
414 * @returns {Boolean} true if this Layer is ready, false otherwise.
416 this.isReady = function() {
417 return tasks.length == 0;
421 * Changes the size of this Layer to the given width and height. Resizing
422 * is only attempted if the new size provided is actually different from
425 * @param {Number} newWidth The new width to assign to this Layer.
426 * @param {Number} newHeight The new height to assign to this Layer.
428 this.resize = function(newWidth, newHeight) {
429 scheduleTask(function() {
430 if (newWidth != width || newHeight != height)
431 resize(newWidth, newHeight);
436 * Draws the specified image at the given coordinates. The image specified
437 * must already be loaded.
439 * @param {Number} x The destination X coordinate.
440 * @param {Number} y The destination Y coordinate.
441 * @param {Image} image The image to draw. Note that this is an Image
442 * object - not a URL.
444 this.drawImage = function(x, y, image) {
445 scheduleTask(function() {
446 if (layer.autosize != 0) fitRect(x, y, image.width, image.height);
447 displayContext.drawImage(image, x, y);
452 * Draws the image at the specified URL at the given coordinates. The image
453 * will be loaded automatically, and this and any future operations will
454 * wait for the image to finish loading.
456 * @param {Number} x The destination X coordinate.
457 * @param {Number} y The destination Y coordinate.
458 * @param {String} url The URL of the image to draw.
460 this.draw = function(x, y, url) {
462 var task = scheduleTask(function() {
463 if (layer.autosize != 0) fitRect(x, y, image.width, image.height);
464 displayContext.drawImage(image, x, y);
467 var image = new Image();
468 image.onload = task.unblock;
474 * Run an arbitrary function as soon as currently pending operations
477 * @param {function} handler The function to call once all currently
478 * pending operations are complete.
479 * @param {boolean} blocked Whether the task should start blocked.
481 this.sync = scheduleTask;
484 * Transfer a rectangle of image data from one Layer to this Layer using the
485 * specified transfer function.
487 * @param {Guacamole.Layer} srcLayer The Layer to copy image data from.
488 * @param {Number} srcx The X coordinate of the upper-left corner of the
489 * rectangle within the source Layer's coordinate
490 * space to copy data from.
491 * @param {Number} srcy The Y coordinate of the upper-left corner of the
492 * rectangle within the source Layer's coordinate
493 * space to copy data from.
494 * @param {Number} srcw The width of the rectangle within the source Layer's
495 * coordinate space to copy data from.
496 * @param {Number} srch The height of the rectangle within the source
497 * Layer's coordinate space to copy data from.
498 * @param {Number} x The destination X coordinate.
499 * @param {Number} y The destination Y coordinate.
500 * @param {Function} transferFunction The transfer function to use to
501 * transfer data from source to
504 this.transfer = function(srcLayer, srcx, srcy, srcw, srch, x, y, transferFunction) {
505 scheduleTaskSynced(srcLayer, function() {
507 if (layer.autosize != 0) fitRect(x, y, srcw, srch);
509 var srcCanvas = srcLayer.getCanvas();
510 if (srcCanvas.width != 0 && srcCanvas.height != 0) {
512 // Get image data from src and dst
513 var src = srcLayer.getCanvas().getContext("2d").getImageData(srcx, srcy, srcw, srch);
514 var dst = displayContext.getImageData(x , y, srcw, srch);
516 // Apply transfer for each pixel
517 for (var i=0; i<srcw*srch*4; i+=4) {
519 // Get source pixel environment
520 var src_pixel = new Guacamole.Layer.Pixel(
527 // Get destination pixel environment
528 var dst_pixel = new Guacamole.Layer.Pixel(
535 // Apply transfer function
536 transferFunction(src_pixel, dst_pixel);
539 dst.data[i ] = dst_pixel.red;
540 dst.data[i+1] = dst_pixel.green;
541 dst.data[i+2] = dst_pixel.blue;
542 dst.data[i+3] = dst_pixel.alpha;
547 displayContext.putImageData(dst, x, y);
555 * Copy a rectangle of image data from one Layer to this Layer. This
556 * operation will copy exactly the image data that will be drawn once all
557 * operations of the source Layer that were pending at the time this
558 * function was called are complete. This operation will not alter the
559 * size of the source Layer even if its autosize property is set to true.
561 * @param {Guacamole.Layer} srcLayer The Layer to copy image data from.
562 * @param {Number} srcx The X coordinate of the upper-left corner of the
563 * rectangle within the source Layer's coordinate
564 * space to copy data from.
565 * @param {Number} srcy The Y coordinate of the upper-left corner of the
566 * rectangle within the source Layer's coordinate
567 * space to copy data from.
568 * @param {Number} srcw The width of the rectangle within the source Layer's
569 * coordinate space to copy data from.
570 * @param {Number} srch The height of the rectangle within the source
571 * Layer's coordinate space to copy data from.
572 * @param {Number} x The destination X coordinate.
573 * @param {Number} y The destination Y coordinate.
575 this.copy = function(srcLayer, srcx, srcy, srcw, srch, x, y) {
576 scheduleTaskSynced(srcLayer, function() {
577 if (layer.autosize != 0) fitRect(x, y, srcw, srch);
579 var srcCanvas = srcLayer.getCanvas();
580 if (srcCanvas.width != 0 && srcCanvas.height != 0)
581 displayContext.drawImage(srcCanvas, srcx, srcy, srcw, srch, x, y, srcw, srch);
587 * Starts a new path at the specified point.
589 * @param {Number} x The X coordinate of the point to draw.
590 * @param {Number} y The Y coordinate of the point to draw.
592 this.moveTo = function(x, y) {
593 scheduleTask(function() {
595 // Start a new path if current path is closed
597 displayContext.beginPath();
601 if (layer.autosize != 0) fitRect(x, y, 0, 0);
602 displayContext.moveTo(x, y);
608 * Add the specified line to the current path.
610 * @param {Number} x The X coordinate of the endpoint of the line to draw.
611 * @param {Number} y The Y coordinate of the endpoint of the line to draw.
613 this.lineTo = function(x, y) {
614 scheduleTask(function() {
616 // Start a new path if current path is closed
618 displayContext.beginPath();
622 if (layer.autosize != 0) fitRect(x, y, 0, 0);
623 displayContext.lineTo(x, y);
629 * Add the specified arc to the current path.
631 * @param {Number} x The X coordinate of the center of the circle which
632 * will contain the arc.
633 * @param {Number} y The Y coordinate of the center of the circle which
634 * will contain the arc.
635 * @param {Number} radius The radius of the circle.
636 * @param {Number} startAngle The starting angle of the arc, in radians.
637 * @param {Number} endAngle The ending angle of the arc, in radians.
638 * @param {Boolean} negative Whether the arc should be drawn in order of
641 this.arc = function(x, y, radius, startAngle, endAngle, negative) {
642 scheduleTask(function() {
644 // Start a new path if current path is closed
646 displayContext.beginPath();
650 if (layer.autosize != 0) fitRect(x, y, 0, 0);
651 displayContext.arc(x, y, radius, startAngle, endAngle, negative);
657 * Starts a new path at the specified point.
659 * @param {Number} cp1x The X coordinate of the first control point.
660 * @param {Number} cp1y The Y coordinate of the first control point.
661 * @param {Number} cp2x The X coordinate of the second control point.
662 * @param {Number} cp2y The Y coordinate of the second control point.
663 * @param {Number} x The X coordinate of the endpoint of the curve.
664 * @param {Number} y The Y coordinate of the endpoint of the curve.
666 this.curveTo = function(cp1x, cp1y, cp2x, cp2y, x, y) {
667 scheduleTask(function() {
669 // Start a new path if current path is closed
671 displayContext.beginPath();
675 if (layer.autosize != 0) fitRect(x, y, 0, 0);
676 displayContext.bezierCurveTo(cp1x, cp1y, cp2x, cp2y, x, y);
682 * Closes the current path by connecting the end point with the start
683 * point (if any) with a straight line.
685 this.close = function() {
686 scheduleTask(function() {
689 displayContext.closePath();
696 * Add the specified rectangle to the current path.
698 * @param {Number} x The X coordinate of the upper-left corner of the
700 * @param {Number} y The Y coordinate of the upper-left corner of the
702 * @param {Number} w The width of the rectangle to draw.
703 * @param {Number} h The height of the rectangle to draw.
705 this.rect = function(x, y, w, h) {
706 scheduleTask(function() {
708 // Start a new path if current path is closed
710 displayContext.beginPath();
714 if (layer.autosize != 0) fitRect(x, y, w, h);
715 displayContext.rect(x, y, w, h);
721 * Clip all future drawing operations by the current path. The current path
722 * is implicitly closed. The current path can continue to be reused
723 * for other operations (such as fillColor()) but a new path will be started
724 * once a path drawing operation (path() or rect()) is used.
726 this.clip = function() {
727 scheduleTask(function() {
729 // Set new clipping region
730 displayContext.clip();
732 // Path now implicitly closed
739 * Stroke the current path with the specified color. The current path
740 * is implicitly closed. The current path can continue to be reused
741 * for other operations (such as clip()) but a new path will be started
742 * once a path drawing operation (path() or rect()) is used.
744 * @param {String} cap The line cap style. Can be "round", "square",
746 * @param {String} join The line join style. Can be "round", "bevel",
748 * @param {Number} thickness The line thickness in pixels.
749 * @param {Number} r The red component of the color to fill.
750 * @param {Number} g The green component of the color to fill.
751 * @param {Number} b The blue component of the color to fill.
752 * @param {Number} a The alpha component of the color to fill.
754 this.strokeColor = function(cap, join, thickness, r, g, b, a) {
755 scheduleTask(function() {
758 displayContext.lineCap = cap;
759 displayContext.lineJoin = join;
760 displayContext.lineWidth = thickness;
761 displayContext.strokeStyle = "rgba(" + r + "," + g + "," + b + "," + a/255.0 + ")";
762 displayContext.stroke();
764 // Path now implicitly closed
771 * Fills the current path with the specified color. The current path
772 * is implicitly closed. The current path can continue to be reused
773 * for other operations (such as clip()) but a new path will be started
774 * once a path drawing operation (path() or rect()) is used.
776 * @param {Number} r The red component of the color to fill.
777 * @param {Number} g The green component of the color to fill.
778 * @param {Number} b The blue component of the color to fill.
779 * @param {Number} a The alpha component of the color to fill.
781 this.fillColor = function(r, g, b, a) {
782 scheduleTask(function() {
785 displayContext.fillStyle = "rgba(" + r + "," + g + "," + b + "," + a/255.0 + ")";
786 displayContext.fill();
788 // Path now implicitly closed
795 * Stroke the current path with the image within the specified layer. The
796 * image data will be tiled infinitely within the stroke. The current path
797 * is implicitly closed. The current path can continue to be reused
798 * for other operations (such as clip()) but a new path will be started
799 * once a path drawing operation (path() or rect()) is used.
801 * @param {String} cap The line cap style. Can be "round", "square",
803 * @param {String} join The line join style. Can be "round", "bevel",
805 * @param {Number} thickness The line thickness in pixels.
806 * @param {Guacamole.Layer} srcLayer The layer to use as a repeating pattern
809 this.strokeLayer = function(cap, join, thickness, srcLayer) {
810 scheduleTaskSynced(srcLayer, function() {
812 // Stroke with image data
813 displayContext.lineCap = cap;
814 displayContext.lineJoin = join;
815 displayContext.lineWidth = thickness;
816 displayContext.strokeStyle = displayContext.createPattern(
817 srcLayer.getCanvas(),
820 displayContext.stroke();
822 // Path now implicitly closed
829 * Fills the current path with the image within the specified layer. The
830 * image data will be tiled infinitely within the stroke. The current path
831 * is implicitly closed. The current path can continue to be reused
832 * for other operations (such as clip()) but a new path will be started
833 * once a path drawing operation (path() or rect()) is used.
835 * @param {Guacamole.Layer} srcLayer The layer to use as a repeating pattern
838 this.fillLayer = function(srcLayer) {
839 scheduleTask(function() {
841 // Fill with image data
842 displayContext.fillStyle = displayContext.createPattern(
843 srcLayer.getCanvas(),
846 displayContext.fill();
848 // Path now implicitly closed
855 * Push current layer state onto stack.
857 this.push = function() {
858 scheduleTask(function() {
860 // Save current state onto stack
861 displayContext.save();
868 * Pop layer state off stack.
870 this.pop = function() {
871 scheduleTask(function() {
873 // Restore current state from stack
875 displayContext.restore();
883 * Reset the layer, clearing the stack, the current path, and any transform
886 this.reset = function() {
887 scheduleTask(function() {
890 while (stackSize > 0) {
891 displayContext.restore();
895 // Restore to initial state
896 displayContext.restore();
897 displayContext.save();
900 displayContext.beginPath();
907 * Sets the given affine transform (defined with six values from the
908 * transform's matrix).
910 * @param {Number} a The first value in the affine transform's matrix.
911 * @param {Number} b The second value in the affine transform's matrix.
912 * @param {Number} c The third value in the affine transform's matrix.
913 * @param {Number} d The fourth value in the affine transform's matrix.
914 * @param {Number} e The fifth value in the affine transform's matrix.
915 * @param {Number} f The sixth value in the affine transform's matrix.
917 this.setTransform = function(a, b, c, d, e, f) {
918 scheduleTask(function() {
921 displayContext.setTransform(
932 * Applies the given affine transform (defined with six values from the
933 * transform's matrix).
935 * @param {Number} a The first value in the affine transform's matrix.
936 * @param {Number} b The second value in the affine transform's matrix.
937 * @param {Number} c The third value in the affine transform's matrix.
938 * @param {Number} d The fourth value in the affine transform's matrix.
939 * @param {Number} e The fifth value in the affine transform's matrix.
940 * @param {Number} f The sixth value in the affine transform's matrix.
942 this.transform = function(a, b, c, d, e, f) {
943 scheduleTask(function() {
946 displayContext.transform(
957 * Sets the channel mask for future operations on this Layer.
959 * The channel mask is a Guacamole-specific compositing operation identifier
960 * with a single bit representing each of four channels (in order): source
961 * image where destination transparent, source where destination opaque,
962 * destination where source transparent, and destination where source
965 * @param {Number} mask The channel mask for future operations on this
968 this.setChannelMask = function(mask) {
969 scheduleTask(function() {
970 displayContext.globalCompositeOperation = compositeOperation[mask];
975 * Sets the miter limit for stroke operations using the miter join. This
976 * limit is the maximum ratio of the size of the miter join to the stroke
977 * width. If this ratio is exceeded, the miter will not be drawn for that
980 * @param {Number} limit The miter limit for stroke operations using the
983 this.setMiterLimit = function(limit) {
984 scheduleTask(function() {
985 displayContext.miterLimit = limit;
989 // Initialize canvas dimensions
990 display.width = width;
991 display.height = height;
996 * Channel mask for the composite operation "rout".
998 Guacamole.Layer.ROUT = 0x2;
1001 * Channel mask for the composite operation "atop".
1003 Guacamole.Layer.ATOP = 0x6;
1006 * Channel mask for the composite operation "xor".
1008 Guacamole.Layer.XOR = 0xA;
1011 * Channel mask for the composite operation "rover".
1013 Guacamole.Layer.ROVER = 0xB;
1016 * Channel mask for the composite operation "over".
1018 Guacamole.Layer.OVER = 0xE;
1021 * Channel mask for the composite operation "plus".
1023 Guacamole.Layer.PLUS = 0xF;
1026 * Channel mask for the composite operation "rin".
1027 * Beware that WebKit-based browsers may leave the contents of the destionation
1028 * layer where the source layer is transparent, despite the definition of this
1031 Guacamole.Layer.RIN = 0x1;
1034 * Channel mask for the composite operation "in".
1035 * Beware that WebKit-based browsers may leave the contents of the destionation
1036 * layer where the source layer is transparent, despite the definition of this
1039 Guacamole.Layer.IN = 0x4;
1042 * Channel mask for the composite operation "out".
1043 * Beware that WebKit-based browsers may leave the contents of the destionation
1044 * layer where the source layer is transparent, despite the definition of this
1047 Guacamole.Layer.OUT = 0x8;
1050 * Channel mask for the composite operation "ratop".
1051 * Beware that WebKit-based browsers may leave the contents of the destionation
1052 * layer where the source layer is transparent, despite the definition of this
1055 Guacamole.Layer.RATOP = 0x9;
1058 * Channel mask for the composite operation "src".
1059 * Beware that WebKit-based browsers may leave the contents of the destionation
1060 * layer where the source layer is transparent, despite the definition of this
1063 Guacamole.Layer.SRC = 0xC;
1067 * Represents a single pixel of image data. All components have a minimum value
1068 * of 0 and a maximum value of 255.
1072 * @param {Number} r The red component of this pixel.
1073 * @param {Number} g The green component of this pixel.
1074 * @param {Number} b The blue component of this pixel.
1075 * @param {Number} a The alpha component of this pixel.
1077 Guacamole.Layer.Pixel = function(r, g, b, a) {
1080 * The red component of this pixel, where 0 is the minimum value,
1081 * and 255 is the maximum.
1086 * The green component of this pixel, where 0 is the minimum value,
1087 * and 255 is the maximum.
1092 * The blue component of this pixel, where 0 is the minimum value,
1093 * and 255 is the maximum.
1098 * The alpha component of this pixel, where 0 is the minimum value,
1099 * and 255 is the maximum.