ia64/xen-unstable

changeset 17185:2909b03e05de

ioemu: improve colordepth negotiation

By moving the colourdepth callback a bit earlier, we can let the
display decide the actual depth to be used before the draw and whether
sharing is possible or not.

Signed-off-by: Samuel Thibault <samuel.thibault@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Tue Mar 04 13:30:07 2008 +0000 (2008-03-04)
parents 166995f1d588
children 854b0704962b
files tools/ioemu/hw/vga.c tools/ioemu/hw/xenfb.c
line diff
     1.1 --- a/tools/ioemu/hw/vga.c	Tue Mar 04 13:29:36 2008 +0000
     1.2 +++ b/tools/ioemu/hw/vga.c	Tue Mar 04 13:30:07 2008 +0000
     1.3 @@ -1061,6 +1061,10 @@ static const uint8_t cursor_glyph[32 * 4
     1.4      0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
     1.5  };    
     1.6  
     1.7 +typedef unsigned int rgb_to_pixel_dup_func(unsigned int r, unsigned int g, unsigned b);
     1.8 +
     1.9 +static rgb_to_pixel_dup_func *rgb_to_pixel_dup_table[NB_DEPTHS];
    1.10 +
    1.11  /* 
    1.12   * Text mode update 
    1.13   * Missing:
    1.14 @@ -1082,6 +1086,12 @@ static void vga_draw_text(VGAState *s, i
    1.15      vga_draw_glyph8_func *vga_draw_glyph8;
    1.16      vga_draw_glyph9_func *vga_draw_glyph9;
    1.17  
    1.18 +    depth = s->get_bpp(s);
    1.19 +    if (s->ds->dpy_colourdepth != NULL && s->ds->depth != depth)
    1.20 +        s->ds->dpy_colourdepth(s->ds, depth);
    1.21 +    s->rgb_to_pixel = 
    1.22 +        rgb_to_pixel_dup_table[get_depth_index(s->ds)];
    1.23 +
    1.24      full_update |= update_palette16(s);
    1.25      palette = s->last_palette;
    1.26      
    1.27 @@ -1134,9 +1144,6 @@ static void vga_draw_text(VGAState *s, i
    1.28          return;
    1.29      }
    1.30  
    1.31 -    depth = s->get_bpp(s);
    1.32 -    if (s->ds->dpy_colourdepth != NULL && s->ds->depth != depth)
    1.33 -        s->ds->dpy_colourdepth(s->ds, depth);
    1.34      if (width != s->last_width || height != s->last_height ||
    1.35          cw != s->last_cw || cheight != s->last_ch) {
    1.36          s->last_scr_width = width * cw;
    1.37 @@ -1319,8 +1326,6 @@ static vga_draw_line_func *vga_draw_line
    1.38      vga_draw_line32_32bgr,
    1.39  };
    1.40  
    1.41 -typedef unsigned int rgb_to_pixel_dup_func(unsigned int r, unsigned int g, unsigned b);
    1.42 -
    1.43  static rgb_to_pixel_dup_func *rgb_to_pixel_dup_table[NB_DEPTHS] = {
    1.44      rgb_to_pixel8_dup,
    1.45      rgb_to_pixel15_dup,
    1.46 @@ -1494,6 +1499,16 @@ static void vga_draw_graphic(VGAState *s
    1.47      s->get_resolution(s, &width, &height);
    1.48      disp_width = width;
    1.49  
    1.50 +    changed_flag = 0;
    1.51 +    depth = s->get_bpp(s);
    1.52 +    if (s->ds->dpy_colourdepth != NULL && 
    1.53 +            (s->ds->depth != depth || !s->ds->shared_buf)) {
    1.54 +        s->ds->dpy_colourdepth(s->ds, depth);
    1.55 +        changed_flag = 1;
    1.56 +    }
    1.57 +    s->rgb_to_pixel = 
    1.58 +        rgb_to_pixel_dup_table[get_depth_index(s->ds)];
    1.59 +
    1.60      shift_control = (s->gr[0x05] >> 5) & 3;
    1.61      double_scan = (s->cr[0x09] >> 7);
    1.62      if (shift_control != 1) {
    1.63 @@ -1552,15 +1567,8 @@ static void vga_draw_graphic(VGAState *s
    1.64              break;
    1.65          }
    1.66      }
    1.67 -    vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
    1.68  
    1.69 -    changed_flag = 0;
    1.70 -    depth = s->get_bpp(s);
    1.71 -    if (s->ds->dpy_colourdepth != NULL && 
    1.72 -            (s->ds->depth != depth || !s->ds->shared_buf)) {
    1.73 -        s->ds->dpy_colourdepth(s->ds, depth);
    1.74 -        changed_flag = 1;
    1.75 -    }
    1.76 +    vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
    1.77      if (disp_width != s->last_width ||
    1.78          height != s->last_height) {
    1.79          dpy_resize(s->ds, disp_width, height);
    1.80 @@ -1673,6 +1681,8 @@ static void vga_draw_blank(VGAState *s, 
    1.81          return;
    1.82      if (s->last_scr_width <= 0 || s->last_scr_height <= 0)
    1.83          return;
    1.84 +    s->rgb_to_pixel = 
    1.85 +        rgb_to_pixel_dup_table[get_depth_index(s->ds)];
    1.86      if (s->ds->depth == 8) 
    1.87          val = s->rgb_to_pixel(0, 0, 0);
    1.88      else
    1.89 @@ -1699,9 +1709,6 @@ static void vga_update_display(void *opa
    1.90      if (s->ds->depth == 0) {
    1.91          /* nothing to do */
    1.92      } else {
    1.93 -        s->rgb_to_pixel = 
    1.94 -            rgb_to_pixel_dup_table[get_depth_index(s->ds)];
    1.95 -        
    1.96          full_update = 0;
    1.97          if (!(s->ar_index & 0x20)) {
    1.98              graphic_mode = GMODE_BLANK;
     2.1 --- a/tools/ioemu/hw/xenfb.c	Tue Mar 04 13:29:36 2008 +0000
     2.2 +++ b/tools/ioemu/hw/xenfb.c	Tue Mar 04 13:30:07 2008 +0000
     2.3 @@ -1238,10 +1238,16 @@ static void xenfb_pv_resize(DisplayState
     2.4      fbfront_update(fb_dev, 0, 0, WIDTH, HEIGHT);
     2.5  }
     2.6  
     2.7 -static void xenfb_pv_colourdepth(DisplayState *s, int depth)
     2.8 +static void xenfb_pv_colourdepth(DisplayState *ds, int depth)
     2.9  {
    2.10      /* TODO: send redepth event if supported */
    2.11 -    fprintf(stderr,"redepth to %d required\n", depth);
    2.12 +    static int lastdepth = -1;
    2.13 +    if (depth != lastdepth) {
    2.14 +        fprintf(stderr,"redepth to %d required\n", depth);
    2.15 +        lastdepth = depth;
    2.16 +    }
    2.17 +    /* We can't redepth for now */
    2.18 +    ds->depth = DEPTH;
    2.19  }
    2.20  
    2.21  static void xenfb_kbd_handler(void *opaque)
    2.22 @@ -1334,6 +1340,8 @@ static void xenfb_kbd_handler(void *opaq
    2.23  
    2.24  static void xenfb_pv_refresh(DisplayState *ds)
    2.25  {
    2.26 +    /* always request negociation */
    2.27 +    ds->depth = -1;
    2.28      vga_hw_update();
    2.29  }
    2.30  
    2.31 @@ -1387,7 +1395,7 @@ int xenfb_pv_display_init(DisplayState *
    2.32      ds->height = HEIGHT;
    2.33      ds->dpy_update = xenfb_pv_update;
    2.34      ds->dpy_resize = xenfb_pv_resize;
    2.35 -    ds->dpy_colourdepth = NULL; //xenfb_pv_colourdepth;
    2.36 +    ds->dpy_colourdepth = xenfb_pv_colourdepth;
    2.37      ds->dpy_refresh = xenfb_pv_refresh;
    2.38      ds->opaque = fb_dev;
    2.39      return 0;