- guac_protocol_send_copy(socket,
- bitmap->layer,
- memblt->nXSrc, memblt->nYSrc,
- memblt->nWidth, memblt->nHeight,
- GUAC_COMP_OVER,
- current_layer, memblt->nLeftRect, memblt->nTopRect);
+
+ /* If not cached, cache if necessary */
+ if (((guac_rdp_bitmap*) bitmap)->used >= 1)
+ guac_rdp_cache_bitmap(context, memblt->bitmap);
+
+ /* If not cached, send as PNG */
+ if (bitmap->layer == NULL) {
+ if (memblt->bitmap->data != NULL) {
+
+ /* Create surface from image data */
+ cairo_surface_t* surface = cairo_image_surface_create_for_data(
+ memblt->bitmap->data + 4*(memblt->nXSrc + memblt->nYSrc*memblt->bitmap->width),
+ CAIRO_FORMAT_RGB24,
+ memblt->nWidth, memblt->nHeight,
+ 4*memblt->bitmap->width);
+
+ /* Send surface to buffer */
+ guac_protocol_send_png(socket,
+ GUAC_COMP_OVER, current_layer,
+ memblt->nLeftRect, memblt->nTopRect, surface);
+
+ /* Free surface */
+ cairo_surface_destroy(surface);
+
+ }
+ }
+
+ /* Otherwise, copy */
+ else
+ guac_protocol_send_copy(socket,
+ bitmap->layer,
+ memblt->nXSrc, memblt->nYSrc,
+ memblt->nWidth, memblt->nHeight,
+ GUAC_COMP_OVER,
+ current_layer, memblt->nLeftRect, memblt->nTopRect);
+
+ /* Increment usage counter */
+ ((guac_rdp_bitmap*) bitmap)->used++;
+