From 3e6b22b07124d75cad270f2bbd7e5d4c58337a6c Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Fri, 11 Feb 2011 23:16:46 -0800 Subject: [PATCH] Layer/buffer support in png and copy instructions --- libguac/include/protocol.h | 16 +++++++++++----- libguac/src/protocol.c | 10 ++++++++-- 2 files changed, 19 insertions(+), 7 deletions(-) diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index e59167f1..78999b5e 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -145,22 +145,26 @@ void guac_send_size(GUACIO* io, int w, int h); * Sends a copy instruction over the given GUACIO connection. * * @param io The GUACIO connection to use. + * @param srcl The index of 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 dstl The index of 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. */ -void guac_send_copy(GUACIO* io, int srcx, int srcy, int w, int h, int dstx, int dsty); +void guac_send_copy(GUACIO* io, int srcl, int srcx, int srcy, int w, int h, + int dstl, int dstx, int dsty); /** * Sends a png instruction over the given GUACIO connection. The PNG image data * given will be automatically base64-encoded for transmission. * * @param io The GUACIO connection to use. + * @param layer The index of the destination layer. * @param x The destination X coordinate. * @param y The destination Y coordinate. * @param png_rows A libpng-compatible PNG image buffer containing the image @@ -168,21 +172,23 @@ void guac_send_copy(GUACIO* io, int srcx, int srcy, int w, int h, int dstx, int * @param w The width of the image in the image buffer. * @param h The height of the image in the image buffer. */ -void guac_send_png(GUACIO* io, int x, int y, png_byte** png_rows, int w, int h); +void guac_send_png(GUACIO* io, int layer, int x, int y, + png_byte** png_rows, int w, int h); /** * Sends a cursor instruction over the given GUACIO connection. The PNG image * data given will be automatically base64-encoded for transmission. * * @param io The GUACIO connection to use. - * @param x The destination X coordinate. - * @param y The destination Y coordinate. + * @param x The X coordinate of the cursor hotspot. + * @param y The Y coordinate of the cursor hotspot. * @param png_rows A libpng-compatible PNG image buffer containing the image * data to send. * @param w The width of the image in the image buffer. * @param h The height of the image in the image buffer. */ -void guac_send_cursor(GUACIO* io, int x, int y, png_byte** png_rows, int w, int h); +void guac_send_cursor(GUACIO* io, int x, int y, + png_byte** png_rows, int w, int h); /** * Returns whether new instruction data is available on the given GUACIO diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index 4d3110e6..5a37e403 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -199,8 +199,10 @@ void guac_send_error(GUACIO* io, const char* error) { } -void guac_send_copy(GUACIO* io, int srcx, int srcy, int w, int h, int dstx, int dsty) { +void guac_send_copy(GUACIO* io, int srcl, int srcx, int srcy, int w, int h, int dstl, int dstx, int dsty) { guac_write_string(io, "copy:"); + guac_write_int(io, srcl); + guac_write_string(io, ","); guac_write_int(io, srcx); guac_write_string(io, ","); guac_write_int(io, srcy); @@ -209,6 +211,8 @@ void guac_send_copy(GUACIO* io, int srcx, int srcy, int w, int h, int dstx, int guac_write_string(io, ","); guac_write_int(io, h); guac_write_string(io, ","); + guac_write_int(io, dstl); + guac_write_string(io, ","); guac_write_int(io, dstx); guac_write_string(io, ","); guac_write_int(io, dsty); @@ -228,7 +232,7 @@ void __guac_write_png(png_structp png, png_bytep data, png_size_t length) { void __guac_write_flush(png_structp png) { } -void guac_send_png(GUACIO* io, int x, int y, png_byte** png_rows, int w, int h) { +void guac_send_png(GUACIO* io, int layer, int x, int y, png_byte** png_rows, int w, int h) { png_structp png; png_infop png_info; @@ -272,6 +276,8 @@ void guac_send_png(GUACIO* io, int x, int y, png_byte** png_rows, int w, int h) ); guac_write_string(io, "png:"); + guac_write_int(io, layer); + guac_write_string(io, ","); guac_write_int(io, x); guac_write_string(io, ","); guac_write_int(io, y);