From fbe43e917e6bb6f470cedf8a5e1659a722212f82 Mon Sep 17 00:00:00 2001 From: Michael Jumper Date: Sun, 11 Mar 2012 21:05:34 -0700 Subject: [PATCH] Refactored rstroke/rfill to lstroke/lfill. --- libguac/include/protocol.h | 80 +++++++++++++++----------------- libguac/src/protocol.c | 93 ++++++++++++++++---------------------- 2 files changed, 74 insertions(+), 99 deletions(-) diff --git a/libguac/include/protocol.h b/libguac/include/protocol.h index fd64b773..32416a7b 100644 --- a/libguac/include/protocol.h +++ b/libguac/include/protocol.h @@ -475,6 +475,42 @@ int guac_protocol_send_cstroke(guac_socket* socket, int guac_protocol_send_cursor(guac_socket* socket, int x, int y, const guac_layer* srcl, int srcx, int srcy, int w, int h); +/** + * Sends an lfill 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 mode The composite mode to use. + * @param layer The destination layer. + * @param srcl The source layer. + * @return Zero on success, non-zero on error. + */ +int guac_protocol_send_lfill(guac_socket* socket, + guac_composite_mode mode, const guac_layer* layer, + const guac_layer* srcl); + +/** + * Sends an lstroke 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 mode The composite mode to use. + * @param layer The destination layer. + * @param cap The style of line cap to use when drawing the stroke. + * @param join The style of line join to use when drawing the stroke. + * @param thickness The thickness of the stroke in pixels. + * @param srcl The source layer. + * @return Zero on success, non-zero on error. + */ +int guac_protocol_send_lstroke(guac_socket* socket, + guac_composite_mode mode, const guac_layer* layer, + guac_line_cap_style cap, guac_line_join_style join, int thickness, + const guac_layer* srcl); + /** * Sends a path instruction over the given guac_socket connection. * @@ -565,50 +601,6 @@ int guac_protocol_send_rect(guac_socket* socket, const guac_layer* layer, */ int guac_protocol_send_reset(guac_socket* socket, const guac_layer* layer); -/** - * Sends an rfill 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 mode The composite mode to use. - * @param layer The destination layer. - * @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. - * @return Zero on success, non-zero on error. - */ -int guac_protocol_send_rfill(guac_socket* socket, - guac_composite_mode mode, const guac_layer* layer, - const guac_layer* srcl, int srcx, int srcy, int w, int h); - -/** - * Sends an rstroke 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 mode The composite mode to use. - * @param layer The destination layer. - * @param cap The style of line cap to use when drawing the stroke. - * @param join The style of line join to use when drawing the stroke. - * @param thickness The thickness of the stroke in pixels. - * @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. - * @return Zero on success, non-zero on error. - */ -int guac_protocol_send_rstroke(guac_socket* socket, - guac_composite_mode mode, const guac_layer* layer, - guac_line_cap_style cap, guac_line_join_style join, int thickness, - const guac_layer* srcl, int srcx, int srcy, int w, int h); - /** * Sends a transfer instruction over the given guac_socket connection. * diff --git a/libguac/src/protocol.c b/libguac/src/protocol.c index 0ccc8018..59f8cf7e 100644 --- a/libguac/src/protocol.c +++ b/libguac/src/protocol.c @@ -673,6 +673,44 @@ int guac_protocol_send_error(guac_socket* socket, const char* error) { } +int guac_protocol_send_lfill(guac_socket* socket, + guac_composite_mode mode, const guac_layer* layer, + const guac_layer* srcl) { + + return + guac_socket_write_string(socket, "5.lfill,") + || __guac_socket_write_length_int(socket, mode) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_int(socket, layer->index) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_int(socket, srcl->index) + || guac_socket_write_string(socket, ";"); + +} + + +int guac_protocol_send_lstroke(guac_socket* socket, + guac_composite_mode mode, const guac_layer* layer, + guac_line_cap_style cap, guac_line_join_style join, int thickness, + const guac_layer* srcl) { + + return + guac_socket_write_string(socket, "7.lstroke,") + || __guac_socket_write_length_int(socket, mode) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_int(socket, layer->index) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_int(socket, cap) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_int(socket, join) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_int(socket, thickness) + || guac_socket_write_string(socket, ",") + || __guac_socket_write_length_int(socket, srcl->index) + || guac_socket_write_string(socket, ";"); + +} + int guac_protocol_send_move(guac_socket* socket, const guac_layer* layer, const guac_layer* parent, int x, int y, int z) { @@ -794,61 +832,6 @@ int guac_protocol_send_reset(guac_socket* socket, const guac_layer* layer) { } -int guac_protocol_send_rfill(guac_socket* socket, - guac_composite_mode mode, const guac_layer* layer, - const guac_layer* srcl, int srcx, int srcy, int w, int h) { - - return - guac_socket_write_string(socket, "5.rfill,") - || __guac_socket_write_length_int(socket, mode) - || guac_socket_write_string(socket, ",") - || __guac_socket_write_length_int(socket, layer->index) - || guac_socket_write_string(socket, ",") - || __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, ";"); - -} - - -int guac_protocol_send_rstroke(guac_socket* socket, - guac_composite_mode mode, const guac_layer* layer, - guac_line_cap_style cap, guac_line_join_style join, int thickness, - const guac_layer* srcl, int srcx, int srcy, int w, int h) { - - return - guac_socket_write_string(socket, "7.rstroke,") - || __guac_socket_write_length_int(socket, mode) - || guac_socket_write_string(socket, ",") - || __guac_socket_write_length_int(socket, layer->index) - || guac_socket_write_string(socket, ",") - || __guac_socket_write_length_int(socket, cap) - || guac_socket_write_string(socket, ",") - || __guac_socket_write_length_int(socket, join) - || guac_socket_write_string(socket, ",") - || __guac_socket_write_length_int(socket, thickness) - || guac_socket_write_string(socket, ",") - || __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, ";"); - -} - - int guac_protocol_send_set(guac_socket* socket, const char* name, const char* value) {