From 554d6e1ec1c86ba75c12187fe693864c9bcb4435 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Mon, 27 Feb 2012 12:28:12 -0800 Subject: [PATCH] Implemented transfer instruction, initial transfer function definitions. --- libguac/include/protocol.h | 77 +++++++++++++++++++++++++++----------- libguac/src/protocol.c | 27 +++++++++++++ 2 files changed, 82 insertions(+), 22 deletions(-) diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index 2b347b1c..1539c323 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -103,45 +103,54 @@ typedef enum guac_composite_mode { * 0 = Active, 1 = Inactive */ - /* Constant functions */ /* ABCD */ - GUAC_COMP_BINARY_BLACK = 0x10, /* 0000 */ - GUAC_COMP_BINARY_WHITE = 0x1F, /* 1111 */ +} 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 */ + GUAC_TRANSFER_BINARY_BLACK = 0x10, /* 0000 */ + GUAC_TRANSFER_BINARY_WHITE = 0x1F, /* 1111 */ /* Copy functions */ - GUAC_COMP_BINARY_SRC = 0x13, /* 0011 */ - GUAC_COMP_BINARY_DEST = 0x15, /* 0101 */ - GUAC_COMP_BINARY_NSRC = 0x1C, /* 1100 */ - GUAC_COMP_BINARY_NDEST = 0x1A, /* 1010 */ + GUAC_TRANSFER_BINARY_SRC = 0x13, /* 0011 */ + GUAC_TRANSFER_BINARY_DEST = 0x15, /* 0101 */ + GUAC_TRANSFER_BINARY_NSRC = 0x1C, /* 1100 */ + GUAC_TRANSFER_BINARY_NDEST = 0x1A, /* 1010 */ /* AND / NAND */ - GUAC_COMP_BINARY_AND = 0x11, /* 0001 */ - GUAC_COMP_BINARY_NAND = 0x1E, /* 1110 */ + GUAC_TRANSFER_BINARY_AND = 0x11, /* 0001 */ + GUAC_TRANSFER_BINARY_NAND = 0x1E, /* 1110 */ /* OR / NOR */ - GUAC_COMP_BINARY_OR = 0x17, /* 0111 */ - GUAC_COMP_BINARY_NOR = 0x18, /* 1000 */ + GUAC_TRANSFER_BINARY_OR = 0x17, /* 0111 */ + GUAC_TRANSFER_BINARY_NOR = 0x18, /* 1000 */ /* XOR / XNOR */ - GUAC_COMP_BINARY_XOR = 0x16, /* 0110 */ - GUAC_COMP_BINARY_XNOR = 0x19, /* 1001 */ + GUAC_TRANSFER_BINARY_XOR = 0x16, /* 0110 */ + GUAC_TRANSFER_BINARY_XNOR = 0x19, /* 1001 */ /* AND / NAND with inverted source */ - GUAC_COMP_BINARY_NSRC_AND = 0x14, /* 0100 */ - GUAC_COMP_BINARY_NSRC_NAND = 0x1B, /* 1011 */ + GUAC_TRANSFER_BINARY_NSRC_AND = 0x14, /* 0100 */ + GUAC_TRANSFER_BINARY_NSRC_NAND = 0x1B, /* 1011 */ /* OR / NOR with inverted source */ - GUAC_COMP_BINARY_NSRC_OR = 0x1D, /* 1101 */ - GUAC_COMP_BINARY_NSRC_NOR = 0x12, /* 0010 */ + GUAC_TRANSFER_BINARY_NSRC_OR = 0x1D, /* 1101 */ + GUAC_TRANSFER_BINARY_NSRC_NOR = 0x12, /* 0010 */ /* AND / NAND with inverted destination */ - GUAC_COMP_BINARY_NDEST_AND = 0x12, /* 0010 */ - GUAC_COMP_BINARY_NDEST_NAND = 0x1D, /* 1101 */ + GUAC_TRANSFER_BINARY_NDEST_AND = 0x12, /* 0010 */ + GUAC_TRANSFER_BINARY_NDEST_NAND = 0x1D, /* 1101 */ /* OR / NOR with inverted destination */ - GUAC_COMP_BINARY_NDEST_OR = 0x1B, /* 1011 */ - GUAC_COMP_BINARY_NDEST_NOR = 0x14 /* 0100 */ + GUAC_TRANSFER_BINARY_NDEST_OR = 0x1B, /* 1011 */ + GUAC_TRANSFER_BINARY_NDEST_NOR = 0x14 /* 0100 */ -} guac_composite_mode; +} guac_transfer_function; 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, 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. * diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index 1075e46c..58e1d7f7 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -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, guac_composite_mode mode, const guac_layer* layer, int x, int y, int width, int height,