Changeset 291c3b3 in libguac-client-rdp
- Timestamp:
- 04/05/12 19:45:04 (14 months ago)
- Branches:
- master, debian, rpm, unstable
- Children:
- 572810e
- Parents:
- 9ebadf7
- git-author:
- Michael Jumper <zhangmaike@…> (04/05/12 19:45:04)
- git-committer:
- Michael Jumper <zhangmaike@…> (04/05/12 19:45:04)
- Files:
-
- 3 edited
-
include/client.h (modified) (1 diff)
-
include/rdp_glyph.h (modified) (1 diff)
-
src/rdp_glyph.c (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
include/client.h
r62521da r291c3b3 64 64 guac_rdp_color background; 65 65 66 /** 67 * Cairo surface which will receive all drawn glyphs. 68 */ 69 cairo_surface_t* glyph_surface; 70 71 /** 72 * Cairo instance for drawing to glyph surface. 73 */ 74 cairo_t* glyph_cairo; 75 66 76 const guac_layer* current_surface; 67 77 -
include/rdp_glyph.h
r4398282 r291c3b3 51 51 52 52 /** 53 * Guacamole layer containing cached image data.53 * Cairo surface layer containing cached image data. 54 54 */ 55 guac_layer* layer;55 cairo_surface_t* surface; 56 56 57 57 } guac_rdp_glyph; -
src/rdp_glyph.c
r69f2919 r291c3b3 46 46 void guac_rdp_glyph_new(rdpContext* context, rdpGlyph* glyph) { 47 47 48 /* Allocate buffer */49 guac_client* client = ((rdp_freerdp_context*) context)->client;50 guac_socket* socket = client->socket;51 guac_layer* layer = guac_client_alloc_buffer(client);52 53 48 int x, y, i; 54 49 int stride; … … 59 54 int width = glyph->cx; 60 55 int height = glyph->cy; 61 62 cairo_surface_t* surface;63 56 64 57 /* Init Cairo buffer */ … … 98 91 } 99 92 100 surface = cairo_image_surface_create_for_data(image_buffer, CAIRO_FORMAT_ARGB32, width, height, stride); 101 guac_protocol_send_png(socket, GUAC_COMP_SRC, layer, 0, 0, surface); 102 103 /* Free surface */ 104 cairo_surface_destroy(surface); 105 free(image_buffer); 106 107 /* Store layer */ 108 ((guac_rdp_glyph*) glyph)->layer = layer; 93 /* Store glyph surface */ 94 ((guac_rdp_glyph*) glyph)->surface = cairo_image_surface_create_for_data( 95 image_buffer, CAIRO_FORMAT_ARGB32, width, height, stride); 109 96 110 97 } … … 114 101 guac_client* client = ((rdp_freerdp_context*) context)->client; 115 102 rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; 116 const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface;117 103 118 /* Colorize glyph */ 119 guac_protocol_send_rect(client->socket, ((guac_rdp_glyph*) glyph)->layer, 120 0, 0, glyph->cx, glyph->cy); 104 /* Use glyph as mask */ 105 cairo_mask_surface( 106 guac_client_data->glyph_cairo, 107 ((guac_rdp_glyph*) glyph)->surface, x, y); 121 108 122 guac_protocol_send_cfill(client->socket, 123 GUAC_COMP_ATOP, ((guac_rdp_glyph*) glyph)->layer, 124 guac_client_data->foreground.red, 125 guac_client_data->foreground.green, 126 guac_client_data->foreground.blue, 127 255); 128 129 /* Draw glyph */ 130 guac_protocol_send_copy(client->socket, 131 ((guac_rdp_glyph*) glyph)->layer, 0, 0, glyph->cx, glyph->cy, 132 GUAC_COMP_OVER, current_layer, x, y); 109 /* Fill rectangle with foreground */ 110 cairo_rectangle(guac_client_data->glyph_cairo, x, y, glyph->cx, glyph->cy); 111 cairo_fill(guac_client_data->glyph_cairo); 133 112 134 113 } 135 114 136 115 void guac_rdp_glyph_free(rdpContext* context, rdpGlyph* glyph) { 137 guac_client* client = ((rdp_freerdp_context*) context)->client; 138 guac_client_free_buffer(client, ((guac_rdp_glyph*) glyph)->layer); 116 117 unsigned char* image_buffer = cairo_image_surface_get_data( 118 ((guac_rdp_glyph*) glyph)->surface); 119 120 /* Free surface */ 121 cairo_surface_destroy(((guac_rdp_glyph*) glyph)->surface); 122 free(image_buffer); 123 139 124 } 140 125 … … 144 129 guac_client* client = ((rdp_freerdp_context*) context)->client; 145 130 rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; 146 const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface;147 131 148 132 bgcolor = freerdp_color_convert_var(bgcolor, … … 162 146 guac_client_data->background.red = (bgcolor & 0xFF0000) >> 16; 163 147 164 /* Paint background on destination*/165 guac_ protocol_send_rect(client->socket, current_layer,166 x, y, width, height);148 /* Create glyph surface and cairo instance */ 149 guac_client_data->glyph_surface = cairo_image_surface_create( 150 CAIRO_FORMAT_RGB24, width, height); 167 151 168 guac_protocol_send_cfill(client->socket, 169 GUAC_COMP_OVER, current_layer, 170 guac_client_data->background.red, 171 guac_client_data->background.green, 172 guac_client_data->background.blue, 173 255); 152 guac_client_data->glyph_cairo = cairo_create( 153 guac_client_data->glyph_surface); 154 155 /* Fill with color */ 156 cairo_set_source_rgb(guac_client_data->glyph_cairo, 157 guac_client_data->background.red / 255.0, 158 guac_client_data->background.green / 255.0, 159 guac_client_data->background.blue / 255.0); 160 161 cairo_rectangle(guac_client_data->glyph_cairo, 162 0, 0, width, height); 163 164 cairo_fill(guac_client_data->glyph_cairo); 165 166 /* Prepare for glyph drawing */ 167 cairo_set_source_rgb(guac_client_data->glyph_cairo, 168 guac_client_data->foreground.red / 255.0, 169 guac_client_data->foreground.green / 255.0, 170 guac_client_data->foreground.blue / 255.0); 174 171 175 172 } … … 177 174 void guac_rdp_glyph_enddraw(rdpContext* context, 178 175 int x, int y, int width, int height, uint32 fgcolor, uint32 bgcolor) { 179 /* UNUSED */ 176 177 guac_client* client = ((rdp_freerdp_context*) context)->client; 178 rdp_guac_client_data* guac_client_data = (rdp_guac_client_data*) client->data; 179 const guac_layer* current_layer = ((rdp_guac_client_data*) client->data)->current_surface; 180 181 /* Send surface with all glyphs to layer */ 182 guac_protocol_send_png(client->socket, 183 GUAC_COMP_OVER, current_layer, x, y, 184 guac_client_data->glyph_surface); 185 186 /* Clean up cairo and glyph surface */ 187 cairo_destroy(guac_client_data->glyph_cairo); 188 cairo_surface_destroy(guac_client_data->glyph_surface); 189 180 190 } 181 191
Note: See TracChangeset
for help on using the changeset viewer.
