Source-Changes-HG archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
[src/trunk]: src/sys/arch/usermode Implement VNC's copyrect sending and let t...
details: https://anonhg.NetBSD.org/src/rev/78a981c2ad16
branches: trunk
changeset: 772343:78a981c2ad16
user: reinoud <reinoud%NetBSD.org@localhost>
date: Fri Dec 30 13:08:30 2011 +0000
description:
Implement VNC's copyrect sending and let the copyrows use the new
vncfb_copyrecs()
diffstat:
sys/arch/usermode/dev/vncfb.c | 31 ++++++++++++++++++---------
sys/arch/usermode/usermode/thunk.c | 42 +++++++++++++++++++++++++------------
2 files changed, 48 insertions(+), 25 deletions(-)
diffs (178 lines):
diff -r 9478a94322ec -r 78a981c2ad16 sys/arch/usermode/dev/vncfb.c
--- a/sys/arch/usermode/dev/vncfb.c Fri Dec 30 12:54:41 2011 +0000
+++ b/sys/arch/usermode/dev/vncfb.c Fri Dec 30 13:08:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: vncfb.c,v 1.5 2011/12/30 12:54:41 jmcneill Exp $ */
+/* $NetBSD: vncfb.c,v 1.6 2011/12/30 13:08:30 reinoud Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -35,7 +35,7 @@
#include "opt_wsemul.h"
#include <sys/cdefs.h>
-__KERNEL_RCSID(0, "$NetBSD: vncfb.c,v 1.5 2011/12/30 12:54:41 jmcneill Exp $");
+__KERNEL_RCSID(0, "$NetBSD: vncfb.c,v 1.6 2011/12/30 13:08:30 reinoud Exp $");
#include <sys/param.h>
#include <sys/systm.h>
@@ -103,6 +103,7 @@
static void vncfb_init_screen(void *, struct vcons_screen *, int, long *);
static void vncfb_update(struct vncfb_softc *, int, int, int, int);
+static void vncfb_copyrect(struct vncfb_softc *sc, int, int, int, int, int, int);
static int vncfb_intr(void *);
static void vncfb_softintr(void *);
@@ -349,21 +350,21 @@
struct vcons_screen *scr = ri->ri_hw;
struct vncfb_softc *sc = scr->scr_cookie;
struct vncfb_fbops *ops = &sc->sc_ops;
- int x, y, w, h;
+ int x, y, w, h, srcx, srcy;
+ int fontheight;
ops->copyrows(ri, srcrow, dstrow, nrows);
+ fontheight = ri->ri_font->fontheight;
x = ri->ri_xorigin;
+ y = ri->ri_yorigin + dstrow * fontheight;
w = ri->ri_width;
- if (srcrow < dstrow) {
- y = ri->ri_yorigin + (srcrow * ri->ri_font->fontheight);
- h = (nrows + (dstrow - srcrow)) * ri->ri_font->fontheight;
- } else {
- y = ri->ri_yorigin + (dstrow * ri->ri_font->fontheight);
- h = (nrows + (srcrow - dstrow)) * ri->ri_font->fontheight;
- }
+ h = nrows * fontheight;
- vncfb_update(sc, x, y, w, h);
+ srcx = ri->ri_xorigin;
+ srcy = ri->ri_yorigin + srcrow * fontheight;
+
+ vncfb_copyrect(sc, x, y, w, h, srcx, srcy);
}
static void
@@ -456,6 +457,14 @@
softint_schedule(sc->sc_sih);
}
+static void
+vncfb_copyrect(struct vncfb_softc *sc, int x, int y, int w, int h,
+ int srcx, int srcy)
+{
+ thunk_rfb_copyrect(&sc->sc_rfb, x, y, w, h, srcx, srcy);
+ softint_schedule(sc->sc_sih);
+}
+
static int
vncfb_intr(void *priv)
{
diff -r 9478a94322ec -r 78a981c2ad16 sys/arch/usermode/usermode/thunk.c
--- a/sys/arch/usermode/usermode/thunk.c Fri Dec 30 12:54:41 2011 +0000
+++ b/sys/arch/usermode/usermode/thunk.c Fri Dec 30 13:08:30 2011 +0000
@@ -1,4 +1,4 @@
-/* $NetBSD: thunk.c,v 1.64 2011/12/30 12:54:42 jmcneill Exp $ */
+/* $NetBSD: thunk.c,v 1.65 2011/12/30 13:08:30 reinoud Exp $ */
/*-
* Copyright (c) 2011 Jared D. McNeill <jmcneill%invisible.ca@localhost>
@@ -28,7 +28,7 @@
#include <sys/cdefs.h>
#ifdef __NetBSD__
-__RCSID("$NetBSD: thunk.c,v 1.64 2011/12/30 12:54:42 jmcneill Exp $");
+__RCSID("$NetBSD: thunk.c,v 1.65 2011/12/30 13:08:30 reinoud Exp $");
#endif
#include <sys/types.h>
@@ -76,6 +76,8 @@
#define MAP_ANON MAP_ANONYMOUS
#endif
+//#define RFB_DEBUG
+
extern int boothowto;
void
@@ -989,7 +991,7 @@
thunk_rfb_send_pending(thunk_rfb_t *rfb)
{
thunk_rfb_update_t *update;
- uint8_t rfb_update[16];
+ uint8_t buf[32];
uint8_t *p;
unsigned int n;
unsigned int bytes_per_pixel;
@@ -1011,28 +1013,28 @@
fprintf(stdout, "rfb: sending %d updates\n", rfb->nupdates);
#endif
- p = rfb_update;
+ p = buf;
*(uint8_t *)p = 0; p += 1; /* FramebufferUpdate */
*(uint8_t *)p = 0; p += 1; /* padding */
*(uint16_t *)p = htons(rfb->nupdates); p += 2; /* # rects */
- len = safe_send(rfb->clientfd, rfb_update, 4);
+ len = safe_send(rfb->clientfd, buf, 4);
if (len < 0)
goto disco;
bytes_per_pixel = rfb->depth / 8;
stride = rfb->width * bytes_per_pixel;
for (n = 0; n < rfb->nupdates; n++) {
- p = rfb_update;
+ p = buf;
update = &rfb->update[n];
*(uint16_t *)p = htons(update->x); p += 2;
*(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(update->enc); p += 4; /* Raw enc */
+ *(uint32_t *)p = htonl(update->enc); p += 4; /* encoding */
#ifdef RFB_DEBUG
- fprintf(stdout, "rfb: [%u] enc %d, [%d, %d] - [%d, %d)",
+ 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]",
@@ -1040,17 +1042,29 @@
fprintf(stdout, "\n");
#endif
- len = safe_send(rfb->clientfd, rfb_update, 12);
+ len = safe_send(rfb->clientfd, buf, 12);
if (len < 0)
goto disco;
- p = rfb->framebuf + (update->y * stride) + (update->x * bytes_per_pixel);
- line_len = update->w * bytes_per_pixel;
- while (update->h-- > 0) {
- len = safe_send(rfb->clientfd, p, line_len);
+ if (update->enc == THUNK_RFB_TYPE_COPYRECT) {
+ p = buf;
+ *(uint16_t *)p = htons(update->srcx); p += 2;
+ *(uint16_t *)p = htons(update->srcy); p += 2;
+ len = safe_send(rfb->clientfd, buf, 4);
if (len < 0)
goto disco;
- p += stride;
+ }
+
+ if (update->enc == THUNK_RFB_TYPE_RAW) {
+ p = rfb->framebuf + (update->y * stride)
+ + (update->x * bytes_per_pixel);
+ line_len = update->w * bytes_per_pixel;
+ while (update->h-- > 0) {
+ len = safe_send(rfb->clientfd, p, line_len);
+ if (len < 0)
+ goto disco;
+ p += stride;
+ }
}
}
Home |
Main Index |
Thread Index |
Old Index