Refactored path into curve, added line, arc, and start instructions. Added close instruction. Added identity instruction.

This commit is contained in:
Michael Jumper 2012-03-12 17:22:04 -07:00
parent 39c0977b9d
commit e3c3eea764
2 changed files with 185 additions and 43 deletions

View File

@ -378,6 +378,24 @@ int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp);
/* DRAWING INSTRUCTIONS */ /* DRAWING INSTRUCTIONS */
/**
* Sends an arc 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 layer The destination layer.
* @param x The X coordinate of the center of the circle containing the arc.
* @param y The Y coordinate of the center of the circle containing the arc.
* @param radius The radius of the circle containing the arc.
* @param startAngle The starting angle, in radians.
* @param endAngle The ending angle, in radians.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_arc(guac_socket* socket, const guac_layer* layer,
int x, int y, int radius, double startAngle, double endAngle);
/** /**
* Sends a cfill instruction over the given guac_socket connection. * Sends a cfill instruction over the given guac_socket connection.
* *
@ -409,6 +427,18 @@ int guac_protocol_send_cfill(guac_socket* socket,
*/ */
int guac_protocol_send_clip(guac_socket* socket, const guac_layer* layer); int guac_protocol_send_clip(guac_socket* socket, const guac_layer* layer);
/**
* Sends a close 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 layer The destination layer.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_close(guac_socket* socket, const guac_layer* layer);
/** /**
* Sends a copy instruction over the given guac_socket connection. * Sends a copy instruction over the given guac_socket connection.
* *
@ -475,6 +505,37 @@ int guac_protocol_send_cstroke(guac_socket* socket,
int guac_protocol_send_cursor(guac_socket* socket, int x, int y, int guac_protocol_send_cursor(guac_socket* socket, int x, int y,
const guac_layer* srcl, int srcx, int srcy, int w, int h); const guac_layer* srcl, int srcx, int srcy, int w, int h);
/**
* Sends a curve 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 layer The destination layer.
* @param cp1x The X coordinate of the first control point.
* @param cp1y The Y coordinate of the first control point.
* @param cp2x The X coordinate of the second control point.
* @param cp2y The Y coordinate of the second control point.
* @param x The X coordinate of the endpoint of the curve.
* @param y The Y coordinate of the endpoint of the curve.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_curve(guac_socket* socket, const guac_layer* layer,
int cp1x, int cp1y, int cp2x, int cp2y, int x, int y);
/**
* Sends an identity 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 layer The destination layer.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer);
/** /**
* Sends an lfill instruction over the given guac_socket connection. * Sends an lfill instruction over the given guac_socket connection.
* *
@ -491,6 +552,21 @@ int guac_protocol_send_lfill(guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, guac_composite_mode mode, const guac_layer* layer,
const guac_layer* srcl); const guac_layer* srcl);
/**
* Sends a line 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 layer The destination layer.
* @param x The X coordinate of the endpoint of the line.
* @param y The Y coordinate of the endpoint of the line.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_line(guac_socket* socket, const guac_layer* layer,
int x, int y);
/** /**
* Sends an lstroke instruction over the given guac_socket connection. * Sends an lstroke instruction over the given guac_socket connection.
* *
@ -511,25 +587,6 @@ int guac_protocol_send_lstroke(guac_socket* socket,
guac_line_cap_style cap, guac_line_join_style join, int thickness, guac_line_cap_style cap, guac_line_join_style join, int thickness,
const guac_layer* srcl); const guac_layer* srcl);
/**
* Sends a path 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 layer The destination layer.
* @param x The X coordinate of the point to add to the path.
* @param y The Y coordinate of the point to add to the path.
* @param cp1x The X coordinate of the first control point.
* @param cp1y The Y coordinate of the first control point.
* @param cp2x The X coordinate of the second control point.
* @param cp2y The Y coordinate of the second control point.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_path(guac_socket* socket, const guac_layer* layer,
int x, int y, int cp1x, int cp1y, int cp2x, int cp2y);
/** /**
* Sends a png instruction over the given guac_socket connection. The PNG image * Sends a png instruction over the given guac_socket connection. The PNG image
* data given will be automatically base64-encoded for transmission. * data given will be automatically base64-encoded for transmission.
@ -601,6 +658,21 @@ int guac_protocol_send_rect(guac_socket* socket, const guac_layer* layer,
*/ */
int guac_protocol_send_reset(guac_socket* socket, const guac_layer* layer); int guac_protocol_send_reset(guac_socket* socket, const guac_layer* layer);
/**
* Sends a start 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 layer The destination layer.
* @param x The X coordinate of the first point of the subpath.
* @param y The Y coordinate of the first point of the subpath.
* @return Zero on success, non-zero on error.
*/
int guac_protocol_send_start(guac_socket* socket, const guac_layer* layer,
int x, int y);
/** /**
* Sends a transfer instruction over the given guac_socket connection. * Sends a transfer instruction over the given guac_socket connection.
* *

View File

@ -483,6 +483,27 @@ int guac_protocol_send_args(guac_socket* socket, const char** args) {
} }
int guac_protocol_send_arc(guac_socket* socket, const guac_layer* layer,
int x, int y, int radius, double startAngle, double endAngle) {
return
guac_socket_write_string(socket, "3.arc,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, y)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, radius)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_double(socket, startAngle)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_double(socket, endAngle)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_cfill(guac_socket* socket, int guac_protocol_send_cfill(guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, guac_composite_mode mode, const guac_layer* layer,
int r, int g, int b, int a) { int r, int g, int b, int a) {
@ -505,6 +526,16 @@ int guac_protocol_send_cfill(guac_socket* socket,
} }
int guac_protocol_send_close(guac_socket* socket, const guac_layer* layer) {
return
guac_socket_write_string(socket, "5.close,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_connect(guac_socket* socket, const char** args) { int guac_protocol_send_connect(guac_socket* socket, const char** args) {
int i; int i;
@ -625,6 +656,29 @@ int guac_protocol_send_cursor(guac_socket* socket, int x, int y,
} }
int guac_protocol_send_curve(guac_socket* socket, const guac_layer* layer,
int cp1x, int cp1y, int cp2x, int cp2y, int x, int y) {
return
guac_socket_write_string(socket, "5.curve,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp1x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp1y)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp2x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp2y)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, y)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_disconnect(guac_socket* socket) { int guac_protocol_send_disconnect(guac_socket* socket) {
return guac_socket_write_string(socket, "10.disconnect;"); return guac_socket_write_string(socket, "10.disconnect;");
} }
@ -673,6 +727,16 @@ int guac_protocol_send_error(guac_socket* socket, const char* error) {
} }
int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer) {
return
guac_socket_write_string(socket, "8.identity,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_lfill(guac_socket* socket, int guac_protocol_send_lfill(guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, guac_composite_mode mode, const guac_layer* layer,
const guac_layer* srcl) { const guac_layer* srcl) {
@ -689,6 +753,21 @@ int guac_protocol_send_lfill(guac_socket* socket,
} }
int guac_protocol_send_line(guac_socket* socket, const guac_layer* layer,
int x, int y) {
return
guac_socket_write_string(socket, "4.line,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, y)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_lstroke(guac_socket* socket, int guac_protocol_send_lstroke(guac_socket* socket,
guac_composite_mode mode, const guac_layer* layer, guac_composite_mode mode, const guac_layer* layer,
guac_line_cap_style cap, guac_line_join_style join, int thickness, guac_line_cap_style cap, guac_line_join_style join, int thickness,
@ -741,29 +820,6 @@ int guac_protocol_send_name(guac_socket* socket, const char* name) {
} }
int guac_protocol_send_path(guac_socket* socket, const guac_layer* layer,
int x, int y, int cp1x, int cp1y, int cp2x, int cp2y) {
return
guac_socket_write_string(socket, "4.path,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, y)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp1x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp1y)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp2x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, cp2y)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_png(guac_socket* socket, guac_composite_mode mode, int guac_protocol_send_png(guac_socket* socket, guac_composite_mode mode,
const guac_layer* layer, int x, int y, cairo_surface_t* surface) { const guac_layer* layer, int x, int y, cairo_surface_t* surface) {
@ -868,7 +924,6 @@ int guac_protocol_send_shade(guac_socket* socket, const guac_layer* layer,
} }
int guac_protocol_send_size(guac_socket* socket, const guac_layer* layer, int guac_protocol_send_size(guac_socket* socket, const guac_layer* layer,
int w, int h) { int w, int h) {
@ -884,6 +939,21 @@ int guac_protocol_send_size(guac_socket* socket, const guac_layer* layer,
} }
int guac_protocol_send_start(guac_socket* socket, const guac_layer* layer,
int x, int y) {
return
guac_socket_write_string(socket, "5.start,")
|| __guac_socket_write_length_int(socket, layer->index)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, x)
|| guac_socket_write_string(socket, ",")
|| __guac_socket_write_length_int(socket, y)
|| guac_socket_write_string(socket, ";");
}
int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp) { int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp) {
return return