Implemented transfer instruction, initial transfer function definitions.

This commit is contained in:
Michael Jumper 2012-02-27 12:28:12 -08:00
parent 54cc87093a
commit 554d6e1ec1
2 changed files with 82 additions and 22 deletions

View File

@ -103,45 +103,54 @@ typedef enum guac_composite_mode {
* 0 = Active, 1 = Inactive * 0 = Active, 1 = Inactive
*/ */
} guac_composite_mode;
/**
* Default transfer functions. There is no current facility in the
* Guacamole protocol to define custom transfer functions.
*/
typedef enum guac_transfer_function {
/* Constant functions */ /* ABCD */ /* Constant functions */ /* ABCD */
GUAC_COMP_BINARY_BLACK = 0x10, /* 0000 */ GUAC_TRANSFER_BINARY_BLACK = 0x10, /* 0000 */
GUAC_COMP_BINARY_WHITE = 0x1F, /* 1111 */ GUAC_TRANSFER_BINARY_WHITE = 0x1F, /* 1111 */
/* Copy functions */ /* Copy functions */
GUAC_COMP_BINARY_SRC = 0x13, /* 0011 */ GUAC_TRANSFER_BINARY_SRC = 0x13, /* 0011 */
GUAC_COMP_BINARY_DEST = 0x15, /* 0101 */ GUAC_TRANSFER_BINARY_DEST = 0x15, /* 0101 */
GUAC_COMP_BINARY_NSRC = 0x1C, /* 1100 */ GUAC_TRANSFER_BINARY_NSRC = 0x1C, /* 1100 */
GUAC_COMP_BINARY_NDEST = 0x1A, /* 1010 */ GUAC_TRANSFER_BINARY_NDEST = 0x1A, /* 1010 */
/* AND / NAND */ /* AND / NAND */
GUAC_COMP_BINARY_AND = 0x11, /* 0001 */ GUAC_TRANSFER_BINARY_AND = 0x11, /* 0001 */
GUAC_COMP_BINARY_NAND = 0x1E, /* 1110 */ GUAC_TRANSFER_BINARY_NAND = 0x1E, /* 1110 */
/* OR / NOR */ /* OR / NOR */
GUAC_COMP_BINARY_OR = 0x17, /* 0111 */ GUAC_TRANSFER_BINARY_OR = 0x17, /* 0111 */
GUAC_COMP_BINARY_NOR = 0x18, /* 1000 */ GUAC_TRANSFER_BINARY_NOR = 0x18, /* 1000 */
/* XOR / XNOR */ /* XOR / XNOR */
GUAC_COMP_BINARY_XOR = 0x16, /* 0110 */ GUAC_TRANSFER_BINARY_XOR = 0x16, /* 0110 */
GUAC_COMP_BINARY_XNOR = 0x19, /* 1001 */ GUAC_TRANSFER_BINARY_XNOR = 0x19, /* 1001 */
/* AND / NAND with inverted source */ /* AND / NAND with inverted source */
GUAC_COMP_BINARY_NSRC_AND = 0x14, /* 0100 */ GUAC_TRANSFER_BINARY_NSRC_AND = 0x14, /* 0100 */
GUAC_COMP_BINARY_NSRC_NAND = 0x1B, /* 1011 */ GUAC_TRANSFER_BINARY_NSRC_NAND = 0x1B, /* 1011 */
/* OR / NOR with inverted source */ /* OR / NOR with inverted source */
GUAC_COMP_BINARY_NSRC_OR = 0x1D, /* 1101 */ GUAC_TRANSFER_BINARY_NSRC_OR = 0x1D, /* 1101 */
GUAC_COMP_BINARY_NSRC_NOR = 0x12, /* 0010 */ GUAC_TRANSFER_BINARY_NSRC_NOR = 0x12, /* 0010 */
/* AND / NAND with inverted destination */ /* AND / NAND with inverted destination */
GUAC_COMP_BINARY_NDEST_AND = 0x12, /* 0010 */ GUAC_TRANSFER_BINARY_NDEST_AND = 0x12, /* 0010 */
GUAC_COMP_BINARY_NDEST_NAND = 0x1D, /* 1101 */ GUAC_TRANSFER_BINARY_NDEST_NAND = 0x1D, /* 1101 */
/* OR / NOR with inverted destination */ /* OR / NOR with inverted destination */
GUAC_COMP_BINARY_NDEST_OR = 0x1B, /* 1011 */ GUAC_TRANSFER_BINARY_NDEST_OR = 0x1B, /* 1011 */
GUAC_COMP_BINARY_NDEST_NOR = 0x14 /* 0100 */ GUAC_TRANSFER_BINARY_NDEST_NOR = 0x14 /* 0100 */
} guac_composite_mode; } guac_transfer_function;
typedef struct guac_layer guac_layer; typedef struct guac_layer guac_layer;
@ -325,6 +334,30 @@ int guac_protocol_send_copy(guac_socket* socket,
const guac_layer* srcl, int srcx, int srcy, int w, int h, const guac_layer* srcl, int srcx, int srcy, int w, int h,
guac_composite_mode mode, const guac_layer* dstl, int dstx, int dsty); guac_composite_mode mode, const guac_layer* dstl, int dstx, int dsty);
/**
* Sends a transfer instruction over the given guac_socket connection.
*
* If an error occurs sending the instruction, a non-zero value is
* returned, and guac_error is set appropriately.
*
* @param socket The guac_socket connection to use.
* @param srcl The source layer.
* @param srcx The X coordinate of the source rectangle.
* @param srcy The Y coordinate of the source rectangle.
* @param w The width of the source rectangle.
* @param h The height of the source rectangle.
* @param fn The transfer function to use.
* @param dstl The destination layer.
* @param dstx The X coordinate of the destination, where the source rectangle
* should be copied.
* @param dsty The Y coordinate of the destination, where the source rectangle
* should be copied.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_transfer(guac_socket* socket,
const guac_layer* srcl, int srcx, int srcy, int w, int h,
guac_transfer_function fn, const guac_layer* dstl, int dstx, int dsty);
/** /**
* Sends a rect instruction over the given guac_socket connection. * Sends a rect instruction over the given guac_socket connection.
* *

View File

@ -204,6 +204,33 @@ int guac_protocol_send_copy(guac_socket* socket,
} }
int guac_protocol_send_transfer(guac_socket* socket,
const guac_layer* srcl, int srcx, int srcy, int w, int h,
guac_transfer_function fn, const guac_layer* dstl, int dstx, int dsty) {
return
guac_socket_write_string(socket, "8.transfer,")
|| __guac_socket_write_length_int(socket, srcl->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, srcx)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, srcy)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, w)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, h)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, fn)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, dstl->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, dstx)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, dsty)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_rect(guac_socket* socket, int guac_protocol_send_rect(guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, guac_composite_mode mode, const guac_layer* layer,
int x, int y, int width, int height, int x, int y, int width, int height,