From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KcjJ6-0001kV-Di for qemu-devel@nongnu.org; Mon, 08 Sep 2008 12:09:40 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KcjJ4-0001js-S3 for qemu-devel@nongnu.org; Mon, 08 Sep 2008 12:09:40 -0400 Received: from [199.232.76.173] (port=35054 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KcjJ4-0001jn-O4 for qemu-devel@nongnu.org; Mon, 08 Sep 2008 12:09:38 -0400 Received: from smtp.eu.citrix.com ([62.200.22.115]:13347) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KcjJ3-0006Uy-UA for qemu-devel@nongnu.org; Mon, 08 Sep 2008 12:09:38 -0400 Message-ID: <48C54EA5.7010408@eu.citrix.com> Date: Mon, 08 Sep 2008 17:11:17 +0100 From: Stefano Stabellini MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit Subject: [Qemu-devel] [PATCH 4 of 6] [UPDATE] vnc shared buffer support Reply-To: qemu-devel@nongnu.org List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Shared buffer support implementation in vnc.c Signed-off-by: Stefano Stabellini --- diff --git a/vnc.c b/vnc.c index 89b1194..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,9 +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_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