Fix transparent glyphs

This commit is contained in:
Michael Jumper 2012-04-05 22:55:46 -07:00
parent 6781338aaa
commit a0cdb35b3b
3 changed files with 52 additions and 6 deletions

View File

@ -55,12 +55,24 @@ typedef struct rdp_guac_client_data {
int mouse_button_mask;
/**
* Cairo surface which will receive all drawn glyphs.
* Cairo surface which will receive all TRANSPARENT glyphs.
*/
cairo_surface_t* trans_glyph_surface;
/**
* Cairo surface which will receive all OPAQUE glyphs.
*/
cairo_surface_t* opaque_glyph_surface;
/**
* The current Cairo surface which will receive all drawn glyphs,
* depending on whether we are currently drawing transparent or
* opaque glyphs.
*/
cairo_surface_t* glyph_surface;
/**
* Cairo instance for drawing to glyph surface.
* Cairo instance for drawing to the current glyph surface.
*/
cairo_t* glyph_cairo;

View File

@ -393,12 +393,12 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
guac_protocol_send_size(client->socket, GUAC_DEFAULT_LAYER,
settings->width, settings->height);
/* Create glyph surface and cairo instance */
guac_client_data->glyph_surface = cairo_image_surface_create(
/* Create glyph surfaces */
guac_client_data->opaque_glyph_surface = cairo_image_surface_create(
CAIRO_FORMAT_RGB24, settings->width, settings->height);
guac_client_data->glyph_cairo = cairo_create(
guac_client_data->glyph_surface);
guac_client_data->trans_glyph_surface = cairo_image_surface_create(
CAIRO_FORMAT_ARGB32, settings->width, settings->height);
/* Success */
return 0;

View File

@ -139,6 +139,14 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
/* Fill background with color if specified */
if (width != 0 && height != 0) {
/* Prepare for opaque glyphs */
guac_client_data->glyph_surface =
guac_client_data->opaque_glyph_surface;
/* Create cairo instance */
guac_client_data->glyph_cairo = cairo_create(
guac_client_data->glyph_surface);
/* Convert background color */
bgcolor = freerdp_color_convert_var(bgcolor,
context->instance->settings->color_depth, 32,
@ -157,6 +165,29 @@ void guac_rdp_glyph_begindraw(rdpContext* context,
}
/* Otherwise, prepare for transparent glyphs */
else {
/* Select transparent glyph surface */
guac_client_data->glyph_surface =
guac_client_data->trans_glyph_surface;
guac_client_data->glyph_cairo = cairo_create(
guac_client_data->glyph_surface);
/* Clear surface */
cairo_set_operator(guac_client_data->glyph_cairo,
CAIRO_OPERATOR_SOURCE);
cairo_set_source_rgba(guac_client_data->glyph_cairo, 0, 0, 0, 0);
cairo_paint(guac_client_data->glyph_cairo);
/* Restore operator */
cairo_set_operator(guac_client_data->glyph_cairo,
CAIRO_OPERATOR_OVER);
}
/* Prepare for glyph drawing */
cairo_set_source_rgb(guac_client_data->glyph_cairo,
( fgcolor & 0x0000FF ) / 255.0,
@ -193,5 +224,8 @@ void guac_rdp_glyph_enddraw(rdpContext* context,
/* Destroy surface */
cairo_surface_destroy(surface);
/* Destroy cairo instance */
cairo_destroy(guac_client_data->glyph_cairo);
}