GUAC-662: Migrate VNC to guac_common_surface.

This commit is contained in:
Michael Jumper 2014-05-01 11:27:26 -07:00
parent 25ab9a0134
commit 8f1f0907e7
4 changed files with 28 additions and 23 deletions

View File

@ -218,19 +218,14 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
guac_client_data->hostname = strdup(argv[IDX_HOSTNAME]);
guac_client_data->port = atoi(argv[IDX_PORT]);
guac_client_data->password = strdup(argv[IDX_PASSWORD]); /* NOTE: freed by libvncclient */
guac_client_data->default_surface = NULL;
/* Set remote cursor flag */
/* Set flags */
guac_client_data->remote_cursor = (strcmp(argv[IDX_CURSOR], "remote") == 0);
/* Set red/blue swap flag */
guac_client_data->swap_red_blue = (strcmp(argv[IDX_SWAP_RED_BLUE], "true") == 0);
/* Set read-only flag */
guac_client_data->read_only = (strcmp(argv[IDX_READ_ONLY], "true") == 0);
/* Freed after use by libvncclient */
guac_client_data->password = strdup(argv[IDX_PASSWORD]);
/* Parse color depth */
guac_client_data->color_depth = atoi(argv[IDX_COLOR_DEPTH]);
@ -372,10 +367,9 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
/* Send name */
guac_protocol_send_name(client->socket, rfb_client->desktopName);
/* Send size */
guac_protocol_send_size(client->socket,
GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height);
/* Create default surface */
guac_client_data->default_surface = guac_common_surface_alloc(client->socket, GUAC_DEFAULT_LAYER,
rfb_client->width, rfb_client->height);
return 0;
}

View File

@ -26,6 +26,7 @@
#include "config.h"
#include "guac_clipboard.h"
#include "guac_surface.h"
#include <guacamole/audio.h>
#include <guacamole/client.h>
@ -180,6 +181,11 @@ typedef struct vnc_guac_client_data {
*/
guac_common_clipboard* clipboard;
/**
* Default surface.
*/
guac_common_surface* default_surface;
} vnc_guac_client_data;
#endif

View File

@ -25,6 +25,7 @@
#include "client.h"
#include "clipboard.h"
#include "guac_clipboard.h"
#include "guac_surface.h"
#include <stdlib.h>
#include <string.h>
@ -41,7 +42,8 @@
int vnc_guac_client_handle_messages(guac_client* client) {
rfbClient* rfb_client = ((vnc_guac_client_data*) client->data)->rfb_client;
vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) client->data;
rfbClient* rfb_client = guac_client_data->rfb_client;
/* Initially wait for messages */
int wait_result = WaitForMessage(rfb_client, 1000000);
@ -76,6 +78,7 @@ int vnc_guac_client_handle_messages(guac_client* client) {
return 1;
}
guac_common_surface_flush(guac_client_data->default_surface);
return 0;
}
@ -116,6 +119,9 @@ int vnc_guac_client_free_handler(guac_client* client) {
/* Free clipboard */
guac_common_clipboard_free(guac_client_data->clipboard);
/* Free surface */
guac_common_surface_free(guac_client_data->default_surface);
/* Free generic data struct */
free(client->data);

View File

@ -24,6 +24,7 @@
#include "client.h"
#include "guac_iconv.h"
#include "guac_surface.h"
#include <stdlib.h>
#include <syslog.h>
@ -135,7 +136,6 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) {
guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT);
vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data;
guac_socket* socket = gc->socket;
int dx, dy;
@ -216,7 +216,7 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) {
/* For now, only use default layer */
surface = cairo_image_surface_create_for_data(buffer, CAIRO_FORMAT_RGB24, w, h, stride);
guac_protocol_send_png(socket, GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, x, y, surface);
guac_common_surface_draw(guac_client_data->default_surface, x, y, surface);
/* Free surface */
cairo_surface_destroy(surface);
@ -227,12 +227,11 @@ void guac_vnc_update(rfbClient* client, int x, int y, int w, int h) {
void guac_vnc_copyrect(rfbClient* client, int src_x, int src_y, int w, int h, int dest_x, int dest_y) {
guac_client* gc = rfbClientGetClientData(client, __GUAC_CLIENT);
guac_socket* socket = gc->socket;
vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data;
/* For now, only use default layer */
guac_protocol_send_copy(socket,
GUAC_DEFAULT_LAYER, src_x, src_y, w, h,
GUAC_COMP_OVER, GUAC_DEFAULT_LAYER, dest_x, dest_y);
guac_common_surface_copy(guac_client_data->default_surface, src_x, src_y, w, h,
guac_client_data->default_surface, dest_x, dest_y);
((vnc_guac_client_data*) gc->data)->copy_rect_used = 1;
@ -286,9 +285,9 @@ rfbBool guac_vnc_malloc_framebuffer(rfbClient* rfb_client) {
guac_client* gc = rfbClientGetClientData(rfb_client, __GUAC_CLIENT);
vnc_guac_client_data* guac_client_data = (vnc_guac_client_data*) gc->data;
/* Send new size */
guac_protocol_send_size(gc->socket,
GUAC_DEFAULT_LAYER, rfb_client->width, rfb_client->height);
/* Resize surface */
if (guac_client_data->default_surface != NULL)
guac_common_surface_resize(guac_client_data->default_surface, rfb_client->width, rfb_client->height);
/* Use original, wrapped proc */
return guac_client_data->rfb_MallocFrameBuffer(rfb_client);