[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 4 of 6] vnc shared buffer support
From: |
Stefano Stabellini |
Subject: |
[Qemu-devel] [PATCH 4 of 6] vnc shared buffer support |
Date: |
Fri, 12 Sep 2008 12:26:35 +0100 |
User-agent: |
Thunderbird 2.0.0.14 (X11/20080505) |
Signed-off-by: Stefano Stabellini <address@hidden>
---
vnc.c | 52 +++++++++++++++++++++++++++++++++++++++++++---------
1 files changed, 43 insertions(+), 9 deletions(-)
diff --git a/vnc.c b/vnc.c
index b1ff4e8..5809a40 100644
--- a/vnc.c
+++ b/vnc.c
@@ -289,13 +289,28 @@ static void vnc_framebuffer_update(VncState *vs, int x,
int y, int w, int h,
vnc_write_s32(vs, encoding);
}
-static void vnc_dpy_resize(DisplayState *ds, int w, int h)
+static void vnc_dpy_resize_shared(DisplayState *ds, int w, int h, int depth,
int linesize, void *pixels)
{
+ static int allocated;
int size_changed;
VncState *vs = ds->opaque;
- ds->data = qemu_realloc(ds->data, w * h * vs->depth);
- vs->old_data = qemu_realloc(vs->old_data, w * h * vs->depth);
+ vnc_colordepth(ds, depth);
+ if (!ds->shared_buf) {
+ ds->linesize = w * vs->depth;
+ if (allocated)
+ ds->data = realloc(ds->data, h * ds->linesize);
+ else
+ ds->data = malloc(h * ds->linesize);
+ allocated = 1;
+ } else {
+ ds->linesize = linesize;
+ if (allocated) {
+ free(ds->data);
+ allocated = 0;
+ }
+ }
+ vs->old_data = qemu_realloc(vs->old_data, h * ds->linesize);
if (ds->data == NULL || vs->old_data == NULL) {
fprintf(stderr, "vnc: memory allocation failed\n");
@@ -309,7 +324,6 @@ static void vnc_dpy_resize(DisplayState *ds, int w, int h)
size_changed = ds->width != w || ds->height != h;
ds->width = w;
ds->height = h;
- ds->linesize = w * vs->depth;
if (size_changed) {
vs->width = ds->width;
vs->height = ds->height;
@@ -324,6 +338,12 @@ static void vnc_dpy_resize(DisplayState *ds, int w, int h)
memset(vs->dirty_row, 0xFF, sizeof(vs->dirty_row));
memset(vs->old_data, 42, vs->ds->linesize * vs->ds->height);
+ if (ds->shared_buf) ds->data = pixels;
+}
+
+static void vnc_dpy_resize(DisplayState *ds, int w, int h)
+{
+ vnc_dpy_resize_shared(ds, w, h, 0, w * (ds->depth / 8), NULL);
}
/* fastest code */
@@ -500,6 +520,9 @@ static void vnc_copy(DisplayState *ds, int src_x, int
src_y, int dst_x, int dst_
int pitch = ds->linesize;
VncState *vs = ds->opaque;
+ if (ds->shared_buf)
+ return;
+
vnc_update_client(vs);
if (dst_y > src_y) {
@@ -1251,9 +1274,6 @@ static void set_pixel_format(VncState *vs,
vs->client_blue_shift = blue_shift;
vs->client_blue_max = blue_max;
vs->pix_bpp = bits_per_pixel / 8;
-
- vga_hw_invalidate();
- vga_hw_update();
}
static void pixel_format_message (VncState *vs) {
@@ -1307,6 +1327,11 @@ static void pixel_format_message (VncState *vs) {
vnc_write(vs, pad, 3); /* padding */
}
+static void vnc_dpy_setdata(DisplayState *ds, void *pixels)
+{
+ ds->data = pixels;
+}
+
static void vnc_colordepth(DisplayState *ds, int depth)
{
int host_big_endian_flag;
@@ -1314,14 +1339,17 @@ static void vnc_colordepth(DisplayState *ds, int depth)
switch (depth) {
case 24:
+ ds->shared_buf = 0;
if (ds->depth == 32) return;
depth = 32;
break;
case 15:
case 8:
case 0:
+ ds->shared_buf = 0;
return;
default:
+ ds->shared_buf = 1;
break;
}
@@ -2177,10 +2205,16 @@ void vnc_display_init(DisplayState *ds)
vs->ds->data = NULL;
vs->ds->dpy_update = vnc_dpy_update;
vs->ds->dpy_resize = vnc_dpy_resize;
+ vs->ds->dpy_setdata = vnc_dpy_setdata;
+#if defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
+ vs->ds->dpy_resize_shared = vnc_dpy_resize_shared;
+#endif
vs->ds->dpy_refresh = NULL;
- vnc_colordepth(vs->ds, 32);
- vnc_dpy_resize(vs->ds, 640, 400);
+ vs->ds->width = 640;
+ vs->ds->height = 400;
+ vs->ds->linesize = 640 * 4;
+ vnc_dpy_resize_shared(ds, ds->width, ds->height, 24, ds->linesize, NULL);
}
#if CONFIG_VNC_TLS
--
1.5.4.3
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Qemu-devel] [PATCH 4 of 6] vnc shared buffer support,
Stefano Stabellini <=