ia64/xen-unstable

changeset 10804:060025203f54

[qemu] Re-calculate color_table after color depth reset.
VNC client may reset color depth after connection, so if we don't
re-calculate color_table, monitor/console's background is abnormal.

Signed-off-by: Yang Xiaowei <xiaowei.yang@intel.com>
Signed-off-by: Christian Limpach <Christian.Limpach@xensource.com>
author chris@kneesaa.uk.xensource.com
date Wed Jul 26 14:20:13 2006 +0100 (2006-07-26)
parents 42aa63188a88
children 2b1a49dd1273
files tools/ioemu/console.c tools/ioemu/patches/vnc-fixes tools/ioemu/patches/vnc-start-vncviewer tools/ioemu/vl.h tools/ioemu/vnc.c
line diff
     1.1 --- a/tools/ioemu/console.c	Wed Jul 26 13:41:10 2006 +0100
     1.2 +++ b/tools/ioemu/console.c	Wed Jul 26 14:20:13 2006 +0100
     1.3 @@ -954,11 +954,21 @@ int is_graphic_console(void)
     1.4      return !active_console->text_console;
     1.5  }
     1.6  
     1.7 +void set_color_table(DisplayState *ds) 
     1.8 +{
     1.9 +    int i, j;
    1.10 +    for(j = 0; j < 2; j++) {
    1.11 +	for(i = 0; i < 8; i++) {
    1.12 +	    color_table[j][i] =
    1.13 +		col_expand(ds, vga_get_color(ds, color_table_rgb[j][i]));
    1.14 +	}
    1.15 +    }
    1.16 +}
    1.17 +
    1.18  CharDriverState *text_console_init(DisplayState *ds)
    1.19  {
    1.20      CharDriverState *chr;
    1.21      TextConsole *s;
    1.22 -    int i,j;
    1.23      static int color_inited;
    1.24  
    1.25      chr = qemu_mallocz(sizeof(CharDriverState));
    1.26 @@ -976,12 +986,7 @@ CharDriverState *text_console_init(Displ
    1.27  
    1.28      if (!color_inited) {
    1.29          color_inited = 1;
    1.30 -        for(j = 0; j < 2; j++) {
    1.31 -            for(i = 0; i < 8; i++) {
    1.32 -                color_table[j][i] = col_expand(s->ds, 
    1.33 -                        vga_get_color(s->ds, color_table_rgb[j][i]));
    1.34 -            }
    1.35 -        }
    1.36 +        set_color_table(ds);
    1.37      }
    1.38      s->y_displayed = 0;
    1.39      s->y_base = 0;
     2.1 --- a/tools/ioemu/patches/vnc-fixes	Wed Jul 26 13:41:10 2006 +0100
     2.2 +++ b/tools/ioemu/patches/vnc-fixes	Wed Jul 26 14:20:13 2006 +0100
     2.3 @@ -1,7 +1,7 @@
     2.4  Index: ioemu/vl.c
     2.5  ===================================================================
     2.6  --- ioemu.orig/vl.c	2006-07-26 13:39:18.439320475 +0100
     2.7 -+++ ioemu/vl.c	2006-07-26 13:39:18.499314057 +0100
     2.8 ++++ ioemu/vl.c	2006-07-26 14:13:44.488196651 +0100
     2.9  @@ -6003,8 +6003,10 @@
    2.10                     kernel_filename, kernel_cmdline, initrd_filename,
    2.11                     timeoffset);
    2.12 @@ -18,7 +18,7 @@ Index: ioemu/vl.c
    2.13  Index: ioemu/vnc.c
    2.14  ===================================================================
    2.15  --- ioemu.orig/vnc.c	2006-07-26 13:39:18.437320689 +0100
    2.16 -+++ ioemu/vnc.c	2006-07-26 13:39:18.500313950 +0100
    2.17 ++++ ioemu/vnc.c	2006-07-26 14:16:51.636538318 +0100
    2.18  @@ -3,6 +3,7 @@
    2.19    * 
    2.20    * Copyright (C) 2006 Anthony Liguori <anthony@codemonkey.ws>
    2.21 @@ -112,7 +112,7 @@ Index: ioemu/vnc.c
    2.22   }
    2.23   
    2.24   static void vnc_framebuffer_update(VncState *vs, int x, int y, int w, int h,
    2.25 -@@ -109,11 +142,15 @@
    2.26 +@@ -109,16 +142,23 @@
    2.27   static void vnc_dpy_resize(DisplayState *ds, int w, int h)
    2.28   {
    2.29       VncState *vs = ds->opaque;
    2.30 @@ -129,7 +129,16 @@ Index: ioemu/vnc.c
    2.31   	fprintf(stderr, "vnc: memory allocation failed\n");
    2.32   	exit(1);
    2.33       }
    2.34 -@@ -131,6 +168,10 @@
    2.35 + 
    2.36 +-    ds->depth = vs->depth * 8;
    2.37 ++    if (ds->depth != vs->depth * 8) {
    2.38 ++        ds->depth = vs->depth * 8;
    2.39 ++        set_color_table(ds);
    2.40 ++    }
    2.41 +     ds->width = w;
    2.42 +     ds->height = h;
    2.43 +     ds->linesize = w * vs->depth;
    2.44 +@@ -131,6 +171,10 @@
    2.45   	vs->width = ds->width;
    2.46   	vs->height = ds->height;
    2.47       }
    2.48 @@ -140,7 +149,7 @@ Index: ioemu/vnc.c
    2.49   }
    2.50   
    2.51   static void send_framebuffer_update_raw(VncState *vs, int x, int y, int w, int h)
    2.52 -@@ -215,8 +256,20 @@
    2.53 +@@ -215,8 +259,20 @@
    2.54       int y = 0;
    2.55       int pitch = ds->linesize;
    2.56       VncState *vs = ds->opaque;
    2.57 @@ -162,7 +171,7 @@ Index: ioemu/vnc.c
    2.58   
    2.59       if (dst_y > src_y) {
    2.60   	y = h - 1;
    2.61 -@@ -238,31 +291,34 @@
    2.62 +@@ -238,31 +294,34 @@
    2.63   	old_row += pitch;
    2.64       }
    2.65   
    2.66 @@ -209,16 +218,16 @@ Index: ioemu/vnc.c
    2.67   {
    2.68       VncState *vs = opaque;
    2.69       int64_t now = qemu_get_clock(rt_clock);
    2.70 -@@ -274,11 +330,12 @@
    2.71 +@@ -274,11 +333,12 @@
    2.72   	uint64_t width_mask;
    2.73   	int n_rectangles;
    2.74   	int saved_offset;
    2.75  -	int has_dirty = 0;
    2.76 +-
    2.77 +-	width_mask = (1ULL << (vs->width / 16)) - 1;
    2.78  +	int maxx, maxy;
    2.79  +	int tile_bytes = vs->depth * DP2X(vs, 1);
    2.80   
    2.81 --	width_mask = (1ULL << (vs->width / 16)) - 1;
    2.82 --
    2.83  -	if (vs->width == 1024)
    2.84  +	if (vs->width != DP2X(vs, DIRTY_PIXEL_BITS))
    2.85  +	    width_mask = (1ULL << X2DP_UP(vs, vs->ds->width)) - 1;
    2.86 @@ -226,7 +235,7 @@ Index: ioemu/vnc.c
    2.87   	    width_mask = ~(0ULL);
    2.88   
    2.89   	/* Walk through the dirty map and eliminate tiles that
    2.90 -@@ -294,16 +351,18 @@
    2.91 +@@ -294,16 +354,18 @@
    2.92   		ptr = row;
    2.93   		old_ptr = old_row;
    2.94   
    2.95 @@ -253,7 +262,7 @@ Index: ioemu/vnc.c
    2.96   		}
    2.97   	    }
    2.98   
    2.99 -@@ -311,7 +370,8 @@
   2.100 +@@ -311,7 +373,8 @@
   2.101   	    old_row += vs->ds->linesize;
   2.102   	}
   2.103   
   2.104 @@ -263,7 +272,7 @@ Index: ioemu/vnc.c
   2.105   	    goto out;
   2.106   
   2.107   	/* Count rectangles */
   2.108 -@@ -321,40 +381,61 @@
   2.109 +@@ -321,40 +384,61 @@
   2.110   	saved_offset = vs->output.offset;
   2.111   	vnc_write_u16(vs, 0);
   2.112   
   2.113 @@ -337,7 +346,7 @@ Index: ioemu/vnc.c
   2.114   static void vnc_timer_init(VncState *vs)
   2.115   {
   2.116       if (vs->timer == NULL) {
   2.117 -@@ -365,8 +446,6 @@
   2.118 +@@ -365,8 +449,6 @@
   2.119   
   2.120   static void vnc_dpy_refresh(DisplayState *ds)
   2.121   {
   2.122 @@ -346,7 +355,7 @@ Index: ioemu/vnc.c
   2.123       vga_hw_update();
   2.124   }
   2.125   
   2.126 -@@ -402,7 +481,7 @@
   2.127 +@@ -402,7 +484,7 @@
   2.128   
   2.129   static void buffer_reset(Buffer *buffer)
   2.130   {
   2.131 @@ -355,7 +364,7 @@ Index: ioemu/vnc.c
   2.132   }
   2.133   
   2.134   static void buffer_append(Buffer *buffer, const void *data, size_t len)
   2.135 -@@ -443,12 +522,12 @@
   2.136 +@@ -443,12 +525,12 @@
   2.137       if (!ret)
   2.138   	return;
   2.139   
   2.140 @@ -371,7 +380,7 @@ Index: ioemu/vnc.c
   2.141   }
   2.142   
   2.143   static void vnc_read_when(VncState *vs, VncReadEvent *func, size_t expecting)
   2.144 -@@ -480,11 +559,11 @@
   2.145 +@@ -480,11 +562,11 @@
   2.146   	    return;
   2.147   
   2.148   	if (!ret) {
   2.149 @@ -386,7 +395,7 @@ Index: ioemu/vnc.c
   2.150       }
   2.151   }
   2.152   
   2.153 -@@ -492,9 +571,9 @@
   2.154 +@@ -492,9 +574,9 @@
   2.155   {
   2.156       buffer_reserve(&vs->output, len);
   2.157   
   2.158 @@ -399,7 +408,7 @@ Index: ioemu/vnc.c
   2.159   
   2.160       buffer_append(&vs->output, data, len);
   2.161   }
   2.162 -@@ -616,24 +695,25 @@
   2.163 +@@ -616,24 +698,25 @@
   2.164       do_key_event(vs, down, sym);
   2.165   }
   2.166   
   2.167 @@ -438,7 +447,7 @@ Index: ioemu/vnc.c
   2.168   }
   2.169   
   2.170   static void set_encodings(VncState *vs, int32_t *encodings, size_t n_encodings)
   2.171 -@@ -690,8 +770,6 @@
   2.172 +@@ -690,8 +773,6 @@
   2.173   	vnc_client_error(vs);
   2.174   
   2.175       vnc_dpy_resize(vs->ds, vs->ds->width, vs->ds->height);
   2.176 @@ -447,7 +456,7 @@ Index: ioemu/vnc.c
   2.177   
   2.178       vga_hw_invalidate();
   2.179       vga_hw_update();
   2.180 -@@ -848,11 +926,11 @@
   2.181 +@@ -848,11 +929,11 @@
   2.182   	vnc_write(vs, "RFB 003.003\n", 12);
   2.183   	vnc_flush(vs);
   2.184   	vnc_read_when(vs, protocol_version, 12);
   2.185 @@ -461,7 +470,7 @@ Index: ioemu/vnc.c
   2.186       }
   2.187   }
   2.188   
   2.189 -@@ -909,17 +987,15 @@
   2.190 +@@ -909,17 +990,15 @@
   2.191   	exit(1);
   2.192       }
   2.193   
     3.1 --- a/tools/ioemu/patches/vnc-start-vncviewer	Wed Jul 26 13:41:10 2006 +0100
     3.2 +++ b/tools/ioemu/patches/vnc-start-vncviewer	Wed Jul 26 14:20:13 2006 +0100
     3.3 @@ -1,8 +1,8 @@
     3.4  Index: ioemu/vnc.c
     3.5  ===================================================================
     3.6 ---- ioemu.orig/vnc.c	2006-07-26 13:39:18.500313950 +0100
     3.7 -+++ ioemu/vnc.c	2006-07-26 13:39:18.648298117 +0100
     3.8 -@@ -999,3 +999,25 @@
     3.9 +--- ioemu.orig/vnc.c	2006-07-26 14:16:51.636538318 +0100
    3.10 ++++ ioemu/vnc.c	2006-07-26 14:18:15.612266329 +0100
    3.11 +@@ -1002,3 +1002,25 @@
    3.12   
    3.13       vnc_dpy_resize(vs->ds, 640, 400);
    3.14   }
    3.15 @@ -30,8 +30,8 @@ Index: ioemu/vnc.c
    3.16  +}
    3.17  Index: ioemu/vl.c
    3.18  ===================================================================
    3.19 ---- ioemu.orig/vl.c	2006-07-26 13:39:18.499314057 +0100
    3.20 -+++ ioemu/vl.c	2006-07-26 13:39:18.650297903 +0100
    3.21 +--- ioemu.orig/vl.c	2006-07-26 14:13:44.488196651 +0100
    3.22 ++++ ioemu/vl.c	2006-07-26 14:18:15.615265998 +0100
    3.23  @@ -121,6 +121,7 @@
    3.24   int bios_size;
    3.25   static DisplayState display_state;
    3.26 @@ -93,9 +93,9 @@ Index: ioemu/vl.c
    3.27           sdl_display_init(ds, full_screen);
    3.28  Index: ioemu/vl.h
    3.29  ===================================================================
    3.30 ---- ioemu.orig/vl.h	2006-07-26 13:39:18.030364229 +0100
    3.31 -+++ ioemu/vl.h	2006-07-26 13:39:18.651297796 +0100
    3.32 -@@ -732,6 +732,7 @@
    3.33 +--- ioemu.orig/vl.h	2006-07-26 14:18:05.490383989 +0100
    3.34 ++++ ioemu/vl.h	2006-07-26 14:18:15.616265887 +0100
    3.35 +@@ -733,6 +733,7 @@
    3.36   
    3.37   /* vnc.c */
    3.38   void vnc_display_init(DisplayState *ds, int display);
     4.1 --- a/tools/ioemu/vl.h	Wed Jul 26 13:41:10 2006 +0100
     4.2 +++ b/tools/ioemu/vl.h	Wed Jul 26 14:20:13 2006 +0100
     4.3 @@ -301,6 +301,7 @@ void vga_hw_screen_dump(const char *file
     4.4  int is_graphic_console(void);
     4.5  CharDriverState *text_console_init(DisplayState *ds);
     4.6  void console_select(unsigned int index);
     4.7 +void set_color_table(DisplayState *ds);
     4.8  
     4.9  /* serial ports */
    4.10  
     5.1 --- a/tools/ioemu/vnc.c	Wed Jul 26 13:41:10 2006 +0100
     5.2 +++ b/tools/ioemu/vnc.c	Wed Jul 26 14:20:13 2006 +0100
     5.3 @@ -155,7 +155,10 @@ static void vnc_dpy_resize(DisplayState 
     5.4  	exit(1);
     5.5      }
     5.6  
     5.7 -    ds->depth = vs->depth * 8;
     5.8 +    if (ds->depth != vs->depth * 8) {
     5.9 +        ds->depth = vs->depth * 8;
    5.10 +        set_color_table(ds);
    5.11 +    }
    5.12      ds->width = w;
    5.13      ds->height = h;
    5.14      ds->linesize = w * vs->depth;