libguac
0.5.0
|
00001 00002 /* ***** BEGIN LICENSE BLOCK ***** 00003 * Version: MPL 1.1/GPL 2.0/LGPL 2.1 00004 * 00005 * The contents of this file are subject to the Mozilla Public License Version 00006 * 1.1 (the "License"); you may not use this file except in compliance with 00007 * the License. You may obtain a copy of the License at 00008 * http://www.mozilla.org/MPL/ 00009 * 00010 * Software distributed under the License is distributed on an "AS IS" basis, 00011 * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License 00012 * for the specific language governing rights and limitations under the 00013 * License. 00014 * 00015 * The Original Code is libguac. 00016 * 00017 * The Initial Developer of the Original Code is 00018 * Michael Jumper. 00019 * Portions created by the Initial Developer are Copyright (C) 2010 00020 * the Initial Developer. All Rights Reserved. 00021 * 00022 * Contributor(s): 00023 * 00024 * Alternatively, the contents of this file may be used under the terms of 00025 * either the GNU General Public License Version 2 or later (the "GPL"), or 00026 * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), 00027 * in which case the provisions of the GPL or the LGPL are applicable instead 00028 * of those above. If you wish to allow use of your version of this file only 00029 * under the terms of either the GPL or the LGPL, and not to allow others to 00030 * use your version of this file under the terms of the MPL, indicate your 00031 * decision by deleting the provisions above and replace them with the notice 00032 * and other provisions required by the GPL or the LGPL. If you do not delete 00033 * the provisions above, a recipient may use your version of this file under 00034 * the terms of any one of the MPL, the GPL or the LGPL. 00035 * 00036 * ***** END LICENSE BLOCK ***** */ 00037 00038 #ifndef _GUAC_PROTOCOL_H 00039 #define _GUAC_PROTOCOL_H 00040 00041 #include <cairo/cairo.h> 00042 00043 #include "socket.h" 00044 00057 typedef int64_t guac_timestamp; 00058 00063 typedef enum guac_composite_mode { 00064 00065 /* 00066 * A: Source where destination transparent = S n D' 00067 * B: Source where destination opaque = S n D 00068 * C: Destination where source transparent = D n S' 00069 * D: Destination where source opaque = D n S 00070 * 00071 * 0 = Active, 1 = Inactive 00072 */ 00073 /* ABCD */ 00074 GUAC_COMP_ROUT = 0x2, /* 0010 - Clears destination where source opaque */ 00075 GUAC_COMP_ATOP = 0x6, /* 0110 - Fill where destination opaque only */ 00076 GUAC_COMP_XOR = 0xA, /* 1010 - XOR */ 00077 GUAC_COMP_ROVER = 0xB, /* 1011 - Fill where destination transparent only */ 00078 GUAC_COMP_OVER = 0xE, /* 1110 - Draw normally */ 00079 GUAC_COMP_PLUS = 0xF, /* 1111 - Add */ 00080 00081 /* Unimplemented in client: */ 00082 /* NOT IMPLEMENTED: 0000 - Clear */ 00083 /* NOT IMPLEMENTED: 0011 - No operation */ 00084 /* NOT IMPLEMENTED: 0101 - Additive IN */ 00085 /* NOT IMPLEMENTED: 0111 - Additive ATOP */ 00086 /* NOT IMPLEMENTED: 1101 - Additive RATOP */ 00087 00088 /* Buggy in webkit browsers, as they keep channel C on in all cases: */ 00089 GUAC_COMP_RIN = 0x1, /* 0001 */ 00090 GUAC_COMP_IN = 0x4, /* 0100 */ 00091 GUAC_COMP_OUT = 0x8, /* 1000 */ 00092 GUAC_COMP_RATOP = 0x9, /* 1001 */ 00093 GUAC_COMP_SRC = 0xC /* 1100 */ 00094 00095 /* Bitwise composite operations (binary) */ 00096 00097 /* 00098 * A: S' & D' 00099 * B: S' & D 00100 * C: S & D' 00101 * D: S & D 00102 * 00103 * 0 = Active, 1 = Inactive 00104 */ 00105 00106 } guac_composite_mode; 00107 00108 00113 typedef enum guac_transfer_function { 00114 00115 /* Constant functions */ /* ABCD */ 00116 GUAC_TRANSFER_BINARY_BLACK = 0x0, /* 0000 */ 00117 GUAC_TRANSFER_BINARY_WHITE = 0xF, /* 1111 */ 00118 00119 /* Copy functions */ 00120 GUAC_TRANSFER_BINARY_SRC = 0x3, /* 0011 */ 00121 GUAC_TRANSFER_BINARY_DEST = 0x5, /* 0101 */ 00122 GUAC_TRANSFER_BINARY_NSRC = 0xC, /* 1100 */ 00123 GUAC_TRANSFER_BINARY_NDEST = 0xA, /* 1010 */ 00124 00125 /* AND / NAND */ 00126 GUAC_TRANSFER_BINARY_AND = 0x1, /* 0001 */ 00127 GUAC_TRANSFER_BINARY_NAND = 0xE, /* 1110 */ 00128 00129 /* OR / NOR */ 00130 GUAC_TRANSFER_BINARY_OR = 0x7, /* 0111 */ 00131 GUAC_TRANSFER_BINARY_NOR = 0x8, /* 1000 */ 00132 00133 /* XOR / XNOR */ 00134 GUAC_TRANSFER_BINARY_XOR = 0x6, /* 0110 */ 00135 GUAC_TRANSFER_BINARY_XNOR = 0x9, /* 1001 */ 00136 00137 /* AND / NAND with inverted source */ 00138 GUAC_TRANSFER_BINARY_NSRC_AND = 0x4, /* 0100 */ 00139 GUAC_TRANSFER_BINARY_NSRC_NAND = 0xB, /* 1011 */ 00140 00141 /* OR / NOR with inverted source */ 00142 GUAC_TRANSFER_BINARY_NSRC_OR = 0xD, /* 1101 */ 00143 GUAC_TRANSFER_BINARY_NSRC_NOR = 0x2, /* 0010 */ 00144 00145 /* AND / NAND with inverted destination */ 00146 GUAC_TRANSFER_BINARY_NDEST_AND = 0x2, /* 0010 */ 00147 GUAC_TRANSFER_BINARY_NDEST_NAND = 0xD, /* 1101 */ 00148 00149 /* OR / NOR with inverted destination */ 00150 GUAC_TRANSFER_BINARY_NDEST_OR = 0xB, /* 1011 */ 00151 GUAC_TRANSFER_BINARY_NDEST_NOR = 0x4 /* 0100 */ 00152 00153 } guac_transfer_function; 00154 00158 typedef enum guac_line_cap_style { 00159 GUAC_LINE_CAP_BUTT = 0x0, 00160 GUAC_LINE_CAP_ROUND = 0x1, 00161 GUAC_LINE_CAP_SQUARE = 0x2 00162 } guac_line_cap_style; 00163 00167 typedef enum guac_line_join_style { 00168 GUAC_LINE_JOIN_BEVEL = 0x0, 00169 GUAC_LINE_JOIN_MITER = 0x1, 00170 GUAC_LINE_JOIN_ROUND = 0x2 00171 } guac_line_join_style; 00172 00173 typedef struct guac_layer guac_layer; 00174 00178 struct guac_layer { 00179 00183 int index; 00184 00188 guac_layer* __next; 00189 00194 guac_layer* __next_available; 00195 00196 }; 00197 00201 typedef struct guac_instruction { 00202 00206 char* opcode; 00207 00211 int argc; 00212 00216 char** argv; 00217 00218 } guac_instruction; 00219 00220 00226 void guac_instruction_free(guac_instruction* instruction); 00227 00238 int guac_protocol_instructions_waiting(guac_socket* socket, int usec_timeout); 00239 00256 guac_instruction* guac_protocol_read_instruction(guac_socket* socket, 00257 int usec_timeout); 00258 00278 guac_instruction* guac_protocol_expect_instruction(guac_socket* socket, 00279 int usec_timeout, const char* opcode); 00280 00289 guac_timestamp guac_protocol_get_timestamp(); 00290 00291 /* CONTROL INSTRUCTIONS */ 00292 00303 int guac_protocol_send_args(guac_socket* socket, const char** args); 00304 00315 int guac_protocol_send_connect(guac_socket* socket, const char** args); 00316 00326 int guac_protocol_send_disconnect(guac_socket* socket); 00327 00338 int guac_protocol_send_error(guac_socket* socket, const char* error); 00339 00352 int guac_protocol_send_set(guac_socket* socket, const guac_layer* layer, 00353 const char* name, const char* value); 00354 00365 int guac_protocol_send_select(guac_socket* socket, const char* protocol); 00366 00378 int guac_protocol_send_sync(guac_socket* socket, guac_timestamp timestamp); 00379 00380 /* DRAWING INSTRUCTIONS */ 00381 00399 int guac_protocol_send_arc(guac_socket* socket, const guac_layer* layer, 00400 int x, int y, int radius, double startAngle, double endAngle, 00401 int negative); 00402 00418 int guac_protocol_send_cfill(guac_socket* socket, 00419 guac_composite_mode mode, const guac_layer* layer, 00420 int r, int g, int b, int a); 00421 00432 int guac_protocol_send_clip(guac_socket* socket, const guac_layer* layer); 00433 00444 int guac_protocol_send_close(guac_socket* socket, const guac_layer* layer); 00445 00466 int guac_protocol_send_copy(guac_socket* socket, 00467 const guac_layer* srcl, int srcx, int srcy, int w, int h, 00468 guac_composite_mode mode, const guac_layer* dstl, int dstx, int dsty); 00469 00488 int guac_protocol_send_cstroke(guac_socket* socket, 00489 guac_composite_mode mode, const guac_layer* layer, 00490 guac_line_cap_style cap, guac_line_join_style join, int thickness, 00491 int r, int g, int b, int a); 00492 00509 int guac_protocol_send_cursor(guac_socket* socket, int x, int y, 00510 const guac_layer* srcl, int srcx, int srcy, int w, int h); 00511 00528 int guac_protocol_send_curve(guac_socket* socket, const guac_layer* layer, 00529 int cp1x, int cp1y, int cp2x, int cp2y, int x, int y); 00530 00541 int guac_protocol_send_identity(guac_socket* socket, const guac_layer* layer); 00542 00555 int guac_protocol_send_lfill(guac_socket* socket, 00556 guac_composite_mode mode, const guac_layer* layer, 00557 const guac_layer* srcl); 00558 00571 int guac_protocol_send_line(guac_socket* socket, const guac_layer* layer, 00572 int x, int y); 00573 00589 int guac_protocol_send_lstroke(guac_socket* socket, 00590 guac_composite_mode mode, const guac_layer* layer, 00591 guac_line_cap_style cap, guac_line_join_style join, int thickness, 00592 const guac_layer* srcl); 00593 00609 int guac_protocol_send_png(guac_socket* socket, guac_composite_mode mode, 00610 const guac_layer* layer, int x, int y, cairo_surface_t* surface); 00611 00622 int guac_protocol_send_pop(guac_socket* socket, const guac_layer* layer); 00623 00634 int guac_protocol_send_push(guac_socket* socket, const guac_layer* layer); 00635 00650 int guac_protocol_send_rect(guac_socket* socket, const guac_layer* layer, 00651 int x, int y, int width, int height); 00652 00663 int guac_protocol_send_reset(guac_socket* socket, const guac_layer* layer); 00664 00677 int guac_protocol_send_start(guac_socket* socket, const guac_layer* layer, 00678 int x, int y); 00679 00700 int guac_protocol_send_transfer(guac_socket* socket, 00701 const guac_layer* srcl, int srcx, int srcy, int w, int h, 00702 guac_transfer_function fn, const guac_layer* dstl, int dstx, int dsty); 00703 00720 int guac_protocol_send_transform(guac_socket* socket, 00721 const guac_layer* layer, 00722 double a, double b, double c, 00723 double d, double e, double f); 00724 00725 /* LAYER INSTRUCTIONS */ 00726 00737 int guac_protocol_send_dispose(guac_socket* socket, const guac_layer* layer); 00738 00755 int guac_protocol_send_distort(guac_socket* socket, 00756 const guac_layer* layer, 00757 double a, double b, double c, 00758 double d, double e, double f); 00759 00775 int guac_protocol_send_move(guac_socket* socket, const guac_layer* layer, 00776 const guac_layer* parent, int x, int y, int z); 00777 00789 int guac_protocol_send_shade(guac_socket* socket, const guac_layer* layer, 00790 int a); 00791 00804 int guac_protocol_send_size(guac_socket* socket, const guac_layer* layer, 00805 int w, int h); 00806 00807 /* TEXT INSTRUCTIONS */ 00808 00819 int guac_protocol_send_clipboard(guac_socket* socket, const char* data); 00820 00828 int guac_protocol_send_name(guac_socket* socket, const char* name); 00829 00830 #endif 00831