Module Name: src Committed By: reinoud Date: Fri Dec 30 12:07:34 UTC 2011
Modified Files: src/sys/arch/usermode/include: thunk.h src/sys/arch/usermode/usermode: thunk.c Log Message: Use the encoding values of the VNC spec and add a copyrect (not used yet) To generate a diff of this commit: cvs rdiff -u -r1.49 -r1.50 src/sys/arch/usermode/include/thunk.h cvs rdiff -u -r1.61 -r1.62 src/sys/arch/usermode/usermode/thunk.c Please note that diffs are not public domain; they are subject to the copyright notices on the relevant files.
Modified files: Index: src/sys/arch/usermode/include/thunk.h diff -u src/sys/arch/usermode/include/thunk.h:1.49 src/sys/arch/usermode/include/thunk.h:1.50 --- src/sys/arch/usermode/include/thunk.h:1.49 Fri Dec 30 11:32:57 2011 +++ src/sys/arch/usermode/include/thunk.h Fri Dec 30 12:07:33 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.h,v 1.49 2011/12/30 11:32:57 reinoud Exp $ */ +/* $NetBSD: thunk.h,v 1.50 2011/12/30 12:07:33 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -192,11 +192,12 @@ typedef struct { typedef struct { - uint8_t type; + uint8_t enc; uint16_t x, y, w, h; + uint16_t srcx, srcy; uint32_t colour; /* for RRE clear */ } thunk_rfb_update_t; -#define THUNK_RFB_TYPE_UPDATE 0 +#define THUNK_RFB_TYPE_RAW 0 #define THUNK_RFB_TYPE_COPYRECT 1 #define THUNK_RFB_TYPE_RRE 2 /* rectangle fill */ @@ -223,5 +224,6 @@ typedef struct { int thunk_rfb_open(thunk_rfb_t *, uint16_t); int thunk_rfb_poll(thunk_rfb_t *, thunk_rfb_event_t *); void thunk_rfb_update(thunk_rfb_t *, int, int, int, int); +void thunk_rfb_copyrect(thunk_rfb_t *, int, int, int, int, int, int); #endif /* !_ARCH_USERMODE_INCLUDE_THUNK_H */ Index: src/sys/arch/usermode/usermode/thunk.c diff -u src/sys/arch/usermode/usermode/thunk.c:1.61 src/sys/arch/usermode/usermode/thunk.c:1.62 --- src/sys/arch/usermode/usermode/thunk.c:1.61 Fri Dec 30 11:32:57 2011 +++ src/sys/arch/usermode/usermode/thunk.c Fri Dec 30 12:07:33 2011 @@ -1,4 +1,4 @@ -/* $NetBSD: thunk.c,v 1.61 2011/12/30 11:32:57 reinoud Exp $ */ +/* $NetBSD: thunk.c,v 1.62 2011/12/30 12:07:33 reinoud Exp $ */ /*- * Copyright (c) 2011 Jared D. McNeill <jmcne...@invisible.ca> @@ -28,7 +28,7 @@ #include <sys/cdefs.h> #ifdef __NetBSD__ -__RCSID("$NetBSD: thunk.c,v 1.61 2011/12/30 11:32:57 reinoud Exp $"); +__RCSID("$NetBSD: thunk.c,v 1.62 2011/12/30 12:07:33 reinoud Exp $"); #endif #include <sys/types.h> @@ -1031,11 +1031,15 @@ thunk_rfb_send_pending(thunk_rfb_t *rfb) *(uint16_t *)p = htons(update->y); p += 2; *(uint16_t *)p = htons(update->w); p += 2; *(uint16_t *)p = htons(update->h); p += 2; - *(uint32_t *)p = htonl(0); p += 4; /* Raw enc */ + *(uint32_t *)p = htonl(update->enc); p += 4; /* Raw enc */ #ifdef RFB_DEBUG - fprintf(stdout, "rfb: [%u] x=%d y=%d w=%d h=%d\n", - n, update->x, update->y, update->w, update->h); + fprintf(stdout, "rfb: [%u] enc %d, [%d, %d] - [%d, %d)", + n, update->enc, update->x, update->y, update->w, update->h); + if (update->enc == THUNK_RFB_TYPE_COPYRECT) + fprintf(stdout, " from [%d, %d]", + update->srcx, update->srcy); + fprintf(stdout, "\n"); #endif len = safe_send(rfb->clientfd, rfb_update, 12); @@ -1202,15 +1206,43 @@ thunk_rfb_update(thunk_rfb_t *rfb, int x } #ifdef RFB_DEBUG - fprintf(stdout, "rfb: queue slot %d, x=%d y=%d w=%d h=%d\n", + fprintf(stdout, "rfb: update queue slot %d, x=%d y=%d w=%d h=%d\n", rfb->nupdates, x, y, w, h); #endif /* add the update request to the queue */ update = &rfb->update[rfb->nupdates++]; - update->type = THUNK_RFB_TYPE_UPDATE; + update->enc = THUNK_RFB_TYPE_RAW; update->x = x; update->y = y; update->w = w; update->h = h; } + +void +thunk_rfb_copyrect(thunk_rfb_t *rfb, int x, int y, int w, int h, + int srcx, int srcy) +{ + thunk_rfb_update_t *update = NULL; + + /* if the queue is full, just return */ + if (rfb->nupdates >= __arraycount(rfb->update)) + return; + +#ifdef RFB_DEBUG + fprintf(stdout, "rfb: copyrect queue slot %d, x=%d y=%d w=%d h=%d\n", + rfb->nupdates, x, y, w, h); +#endif + + /* add the update request to the queue */ + update = &rfb->update[rfb->nupdates++]; + update->enc = THUNK_RFB_TYPE_COPYRECT; + update->x = x; + update->y = y; + update->w = w; + update->h = h; + update->srcx = srcx; + update->srcy = srcy; + + rfb->first_mergable = rfb->nupdates+1; +}