# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1203529678 0
# Node ID 6e096456b3e15c074f75be5a234706fef9cf0416
# Parent e3c722d483f56e9cdea596e1600cd22b6900c289
ioemu: Share framebuffer between VGA device model and VNC server.
Now that the qemu WMVi patch is applied we can take full advantage of
it sharing the video buffer between the vga driver and the qemu vnc
server. This saves a lot of memcpy. It's worth mentioning again that
when the guest colour depth is 24 bit we cannot share the buffer
because 24 bpp is not supported by the vnc protocol, so we still have
to do the translation 24 bpp -> 32 bpp.
Signed-off-by: Stefano Stabellini <stefano.stabellini@xxxxxxxxxxxxx>
---
tools/ioemu/hw/vga.c | 22 ++++++++++++----------
tools/ioemu/vl.h | 1 +
tools/ioemu/vnc.c | 44 +++++++++++++++++++++++++++++++++-----------
3 files changed, 46 insertions(+), 21 deletions(-)
diff -r e3c722d483f5 -r 6e096456b3e1 tools/ioemu/hw/vga.c
--- a/tools/ioemu/hw/vga.c Wed Feb 20 17:46:10 2008 +0000
+++ b/tools/ioemu/hw/vga.c Wed Feb 20 17:47:58 2008 +0000
@@ -1135,8 +1135,6 @@ static void vga_draw_text(VGAState *s, i
}
depth = s->get_bpp(s);
- if (depth == 24)
- depth = 32;
if (s->ds->dpy_colourdepth != NULL && s->ds->depth != depth)
s->ds->dpy_colourdepth(s->ds, depth);
if (width != s->last_width || height != s->last_height ||
@@ -1557,10 +1555,10 @@ static void vga_draw_graphic(VGAState *s
vga_draw_line = vga_draw_line_table[v * NB_DEPTHS +
get_depth_index(s->ds)];
depth = s->get_bpp(s);
- if (depth == 24)
- depth = 32;
- if (s->ds->dpy_colourdepth != NULL && s->ds->depth != depth)
- s->ds->dpy_colourdepth(s->ds, depth);
+ if (s->ds->dpy_colourdepth != NULL && s->ds->depth != depth) {
+ if (depth != 24 || s->ds->depth != 32)
+ s->ds->dpy_colourdepth(s->ds, depth);
+ }
if (disp_width != s->last_width ||
height != s->last_height) {
dpy_resize(s->ds, disp_width, height);
@@ -1570,7 +1568,9 @@ static void vga_draw_graphic(VGAState *s
s->last_height = height;
full_update = 1;
}
- if (s->cursor_invalidate)
+ if (s->ds->shared_buf && s->ds->data != s->vram_ptr + (s->start_addr * 4))
+ s->ds->data = s->vram_ptr + (s->start_addr * 4);
+ if (!s->ds->shared_buf && s->cursor_invalidate)
s->cursor_invalidate(s);
line_offset = s->line_offset;
@@ -1621,9 +1621,11 @@ static void vga_draw_graphic(VGAState *s
page_min = page0;
if (page_max == 0 || page1 > page_max)
page_max = page1;
- vga_draw_line(s, d, s->vram_ptr + addr, width);
- if (s->cursor_draw_line)
- s->cursor_draw_line(s, d, y);
+ if (!s->ds->shared_buf) {
+ vga_draw_line(s, d, s->vram_ptr + addr, width);
+ if (s->cursor_draw_line)
+ s->cursor_draw_line(s, d, y);
+ }
} else {
if (y_start >= 0) {
/* flush to display */
diff -r e3c722d483f5 -r 6e096456b3e1 tools/ioemu/vl.h
--- a/tools/ioemu/vl.h Wed Feb 20 17:46:10 2008 +0000
+++ b/tools/ioemu/vl.h Wed Feb 20 17:47:58 2008 +0000
@@ -935,6 +935,7 @@ struct DisplayState {
void *opaque;
int switchbpp;
+ int shared_buf;
void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
void (*dpy_resize)(struct DisplayState *s, int w, int h);
diff -r e3c722d483f5 -r 6e096456b3e1 tools/ioemu/vnc.c
--- a/tools/ioemu/vnc.c Wed Feb 20 17:46:10 2008 +0000
+++ b/tools/ioemu/vnc.c Wed Feb 20 17:47:58 2008 +0000
@@ -336,11 +336,21 @@ static void vnc_framebuffer_update(VncSt
static void vnc_dpy_resize(DisplayState *ds, int w, int h)
{
+ static int allocated;
int size_changed;
VncState *vs = ds->opaque;
int o;
- ds->data = realloc(ds->data, w * h * vs->depth);
+ if (!ds->shared_buf) {
+ if (allocated)
+ ds->data = realloc(ds->data, w * h * vs->depth);
+ else
+ ds->data = malloc(w * h * vs->depth);
+ allocated = 1;
+ } else if (allocated) {
+ free(ds->data);
+ allocated = 0;
+ }
vs->old_data = realloc(vs->old_data, w * h * vs->depth);
vs->dirty_row = realloc(vs->dirty_row, h * sizeof(vs->dirty_row[0]));
vs->update_row = realloc(vs->update_row, h * sizeof(vs->dirty_row[0]));
@@ -537,6 +547,11 @@ static void vnc_copy(DisplayState *ds, i
int pitch = ds->linesize;
VncState *vs = ds->opaque;
int updating_client = 1;
+
+ if (ds->shared_buf) {
+ framebuffer_set_updated(vs, dst_x, dst_y, w, h);
+ return;
+ }
if (src_x < vs->visible_x || src_y < vs->visible_y ||
dst_x < vs->visible_x || dst_y < vs->visible_y ||
@@ -1409,9 +1424,6 @@ static void set_pixel_format(VncState *v
vs->blue_shift = blue_shift;
vs->blue_max = blue_max;
vs->pix_bpp = bits_per_pixel / 8;
-
- vga_hw_invalidate();
- vga_hw_update();
}
static void pixel_format_message (VncState *vs) {
@@ -1468,16 +1480,26 @@ static void vnc_dpy_colourdepth(DisplayS
static void vnc_dpy_colourdepth(DisplayState *ds, int depth)
{
int host_big_endian_flag;
- struct VncState *vs;
-
- if (!depth) return;
-
+ struct VncState *vs = ds->opaque;
+
+ switch (depth) {
+ case 24:
+ ds->shared_buf = 0;
+ depth = 32;
+ break;
+ case 0:
+ ds->shared_buf = 0;
+ return;
+ default:
+ ds->shared_buf = 1;
+ break;
+ }
+
#ifdef WORDS_BIGENDIAN
host_big_endian_flag = 1;
#else
host_big_endian_flag = 0;
-#endif
- vs = ds->opaque;
+#endif
switch (depth) {
case 8:
@@ -2312,7 +2334,7 @@ void vnc_display_init(DisplayState *ds)
vs->ds->width = 640;
vs->ds->height = 400;
- vnc_dpy_colourdepth(vs->ds, 32);
+ vnc_dpy_colourdepth(vs->ds, 24);
}
#if CONFIG_VNC_TLS
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|