ia64/xen-unstable

changeset 17188:e1898e917373

ioemu: support shared framebuffer and linesize != width * depth.

When sharing the buffer between e.g. xenfb and SDL, SDL must follow
the line size.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Mar 05 10:54:08 2008 +0000 (2008-03-05)
parents 21532468020b
children 86e64b684fb2
files tools/ioemu/cocoa.m tools/ioemu/hw/pl110.c tools/ioemu/hw/tcx.c tools/ioemu/hw/vga.c tools/ioemu/hw/xenfb.c tools/ioemu/sdl.c tools/ioemu/vl.c tools/ioemu/vl.h tools/ioemu/vnc.c
line diff
     1.1 --- a/tools/ioemu/cocoa.m	Wed Mar 05 10:52:51 2008 +0000
     1.2 +++ b/tools/ioemu/cocoa.m	Wed Mar 05 10:54:08 2008 +0000
     1.3 @@ -96,7 +96,7 @@ static void cocoa_update(DisplayState *d
     1.4      cocoa_resize
     1.5   ------------------------------------------------------
     1.6  */
     1.7 -static void cocoa_resize(DisplayState *ds, int w, int h)
     1.8 +static void cocoa_resize(DisplayState *ds, int w, int h, int linesize)
     1.9  {
    1.10      const int device_bpp = 32;
    1.11      static void *screen_pixels;
     2.1 --- a/tools/ioemu/hw/pl110.c	Wed Mar 05 10:52:51 2008 +0000
     2.2 +++ b/tools/ioemu/hw/pl110.c	Wed Mar 05 10:54:08 2008 +0000
     2.3 @@ -262,7 +262,7 @@ static void pl110_resize(pl110_state *s,
     2.4  {
     2.5      if (width != s->cols || height != s->rows) {
     2.6          if (pl110_enabled(s)) {
     2.7 -            dpy_resize(s->ds, width, height);
     2.8 +            dpy_resize(s->ds, width, height, width * 4);
     2.9          }
    2.10      }
    2.11      s->cols = width;
    2.12 @@ -375,7 +375,7 @@ static void pl110_write(void *opaque, ta
    2.13          s->cr = val;
    2.14          s->bpp = (val >> 1) & 7;
    2.15          if (pl110_enabled(s)) {
    2.16 -            dpy_resize(s->ds, s->cols, s->rows);
    2.17 +            dpy_resize(s->ds, s->cols, s->rows, s->cols * 4);
    2.18          }
    2.19          break;
    2.20      case 10: /* LCDICR */
     3.1 --- a/tools/ioemu/hw/tcx.c	Wed Mar 05 10:52:51 2008 +0000
     3.2 +++ b/tools/ioemu/hw/tcx.c	Wed Mar 05 10:54:08 2008 +0000
     3.3 @@ -342,7 +342,7 @@ void tcx_init(DisplayState *ds, uint32_t
     3.4      register_savevm("tcx", addr, 1, tcx_save, tcx_load, s);
     3.5      qemu_register_reset(tcx_reset, s);
     3.6      tcx_reset(s);
     3.7 -    dpy_resize(s->ds, width, height);
     3.8 +    dpy_resize(s->ds, width, height, width * 1);
     3.9  }
    3.10  
    3.11  static void tcx_screen_dump(void *opaque, const char *filename)
     4.1 --- a/tools/ioemu/hw/vga.c	Wed Mar 05 10:52:51 2008 +0000
     4.2 +++ b/tools/ioemu/hw/vga.c	Wed Mar 05 10:54:08 2008 +0000
     4.3 @@ -1148,7 +1148,7 @@ static void vga_draw_text(VGAState *s, i
     4.4          cw != s->last_cw || cheight != s->last_ch) {
     4.5          s->last_scr_width = width * cw;
     4.6          s->last_scr_height = height * cheight;
     4.7 -        dpy_resize(s->ds, s->last_scr_width, s->last_scr_height);
     4.8 +        dpy_resize(s->ds, s->last_scr_width, s->last_scr_height, s->last_scr_width * (depth / 8));
     4.9          s->last_width = width;
    4.10          s->last_height = height;
    4.11          s->last_ch = cheight;
    4.12 @@ -1571,7 +1571,7 @@ static void vga_draw_graphic(VGAState *s
    4.13      vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
    4.14      if (disp_width != s->last_width ||
    4.15          height != s->last_height) {
    4.16 -        dpy_resize(s->ds, disp_width, height);
    4.17 +        dpy_resize(s->ds, disp_width, height, disp_width * (depth / 8));
    4.18          s->last_scr_width = disp_width;
    4.19          s->last_scr_height = height;
    4.20          s->last_width = disp_width;
    4.21 @@ -2235,7 +2235,7 @@ static void vga_save_dpy_update(DisplayS
    4.22  {
    4.23  }
    4.24  
    4.25 -static void vga_save_dpy_resize(DisplayState *s, int w, int h)
    4.26 +static void vga_save_dpy_resize(DisplayState *s, int w, int h, int linesize)
    4.27  {
    4.28      s->linesize = w * 4;
    4.29      s->data = qemu_malloc(h * s->linesize);
     5.1 --- a/tools/ioemu/hw/xenfb.c	Wed Mar 05 10:52:51 2008 +0000
     5.2 +++ b/tools/ioemu/hw/xenfb.c	Wed Mar 05 10:54:08 2008 +0000
     5.3 @@ -1183,7 +1183,7 @@ static int xenfb_register_console(struct
     5.4  			     xenfb_screen_dump,
     5.5  			     xenfb);
     5.6  	dpy_colourdepth(xenfb->ds, xenfb->depth);
     5.7 -	dpy_resize(xenfb->ds, xenfb->width, xenfb->height);
     5.8 +        dpy_resize(xenfb->ds, xenfb->width, xenfb->height, xenfb->row_stride);
     5.9  	if (xenfb->ds->shared_buf)
    5.10  	    dpy_setdata(xenfb->ds, xenfb->pixels);
    5.11  
    5.12 @@ -1227,7 +1227,7 @@ static void xenfb_pv_update(DisplayState
    5.13      fbfront_update(fb_dev, x, y, w, h);
    5.14  }
    5.15  
    5.16 -static void xenfb_pv_resize(DisplayState *s, int w, int h)
    5.17 +static void xenfb_pv_resize(DisplayState *s, int w, int h, int linesize)
    5.18  {
    5.19      struct fbfront_dev *fb_dev = s->opaque;
    5.20      fprintf(stderr,"resize to %dx%d required\n", w, h);
     6.1 --- a/tools/ioemu/sdl.c	Wed Mar 05 10:52:51 2008 +0000
     6.2 +++ b/tools/ioemu/sdl.c	Wed Mar 05 10:54:08 2008 +0000
     6.3 @@ -90,7 +90,7 @@ static void sdl_setdata(DisplayState *ds
     6.4      ds->data = pixels;
     6.5  }
     6.6  
     6.7 -static void sdl_resize(DisplayState *ds, int w, int h)
     6.8 +static void sdl_resize(DisplayState *ds, int w, int h, int linesize)
     6.9  {
    6.10      int flags;
    6.11  
    6.12 @@ -130,7 +130,7 @@ static void sdl_resize(DisplayState *ds,
    6.13          ds->data = screen->pixels;
    6.14          ds->linesize = screen->pitch;
    6.15      } else {
    6.16 -        ds->linesize = (ds->depth / 8) * w;
    6.17 +        ds->linesize = linesize;
    6.18      }
    6.19  }
    6.20  
    6.21 @@ -344,7 +344,7 @@ static void sdl_send_mouse_event(int dx,
    6.22  static void toggle_full_screen(DisplayState *ds)
    6.23  {
    6.24      gui_fullscreen = !gui_fullscreen;
    6.25 -    sdl_resize(ds, screen->w, screen->h);
    6.26 +    sdl_resize(ds, screen->w, screen->h, ds->linesize);
    6.27      if (gui_fullscreen) {
    6.28          gui_saved_grab = gui_grab;
    6.29          sdl_grab_start();
    6.30 @@ -572,7 +572,7 @@ void sdl_display_init(DisplayState *ds, 
    6.31      ds->dpy_colourdepth = sdl_colourdepth;
    6.32      ds->dpy_setdata = sdl_setdata;
    6.33  
    6.34 -    sdl_resize(ds, 640, 400);
    6.35 +    sdl_resize(ds, 640, 400, 640 * 4);
    6.36      sdl_update_caption();
    6.37      SDL_EnableKeyRepeat(250, 50);
    6.38      SDL_EnableUNICODE(1);
     7.1 --- a/tools/ioemu/vl.c	Wed Mar 05 10:52:51 2008 +0000
     7.2 +++ b/tools/ioemu/vl.c	Wed Mar 05 10:54:08 2008 +0000
     7.3 @@ -4446,7 +4446,7 @@ static void dumb_update(DisplayState *ds
     7.4  {
     7.5  }
     7.6  
     7.7 -static void dumb_resize(DisplayState *ds, int w, int h)
     7.8 +static void dumb_resize(DisplayState *ds, int w, int h, int linesize)
     7.9  {
    7.10  }
    7.11  
     8.1 --- a/tools/ioemu/vl.h	Wed Mar 05 10:52:51 2008 +0000
     8.2 +++ b/tools/ioemu/vl.h	Wed Mar 05 10:54:08 2008 +0000
     8.3 @@ -941,7 +941,7 @@ struct DisplayState {
     8.4      int shared_buf;
     8.5      
     8.6      void (*dpy_update)(struct DisplayState *s, int x, int y, int w, int h);
     8.7 -    void (*dpy_resize)(struct DisplayState *s, int w, int h);
     8.8 +    void (*dpy_resize)(struct DisplayState *s, int w, int h, int linesize);
     8.9      void (*dpy_colourdepth)(struct DisplayState *s, int depth);
    8.10      void (*dpy_setdata)(DisplayState *s, void *pixels);
    8.11      void (*dpy_refresh)(struct DisplayState *s);
    8.12 @@ -953,9 +953,9 @@ static inline void dpy_update(DisplaySta
    8.13      s->dpy_update(s, x, y, w, h);
    8.14  }
    8.15  
    8.16 -static inline void dpy_resize(DisplayState *s, int w, int h)
    8.17 +static inline void dpy_resize(DisplayState *s, int w, int h, int linesize)
    8.18  {
    8.19 -    s->dpy_resize(s, w, h);
    8.20 +    s->dpy_resize(s, w, h, linesize);
    8.21  }
    8.22  
    8.23  static inline void dpy_colourdepth(struct DisplayState *s, int depth)
     9.1 --- a/tools/ioemu/vnc.c	Wed Mar 05 10:52:51 2008 +0000
     9.2 +++ b/tools/ioemu/vnc.c	Wed Mar 05 10:54:08 2008 +0000
     9.3 @@ -362,13 +362,16 @@ static void vnc_framebuffer_update(VncSt
     9.4      vnc_write_s32(vs, encoding);
     9.5  }
     9.6  
     9.7 -static void vnc_dpy_resize(DisplayState *ds, int w, int h)
     9.8 +static void vnc_dpy_resize(DisplayState *ds, int w, int h, int linesize)
     9.9  {
    9.10      static int allocated;
    9.11      int size_changed;
    9.12      VncState *vs = ds->opaque;
    9.13      int o;
    9.14  
    9.15 +    if (linesize != w * vs->depth)
    9.16 +        ds->shared_buf = 0;
    9.17 +
    9.18      if (!ds->shared_buf) {
    9.19          if (allocated)
    9.20              ds->data = realloc(ds->data, w * h * vs->depth);
    9.21 @@ -1728,7 +1731,7 @@ static void vnc_dpy_colourdepth(DisplayS
    9.22          }
    9.23      }
    9.24  
    9.25 -    vnc_dpy_resize(ds, ds->width, ds->height);
    9.26 +    vnc_dpy_resize(ds, ds->width, ds->height, ds->linesize);
    9.27  }
    9.28  
    9.29  static int protocol_client_msg(VncState *vs, uint8_t *data, size_t len)