Commit 8927bcfd339510deedb89ff274ea9cd1d00a2668

Authored by aliguori
1 parent 9fd8d8d7

remove bgr (Stefano Stabellini)

Do not handle bgr host displays in the backends.

Right now a bgr flag exists so that sdl can set it, if the SDL_Surface
is bgr.
Afterwards the graphic device (e.g. vga.c) does the needed conversion.

With this patch series is sdl that is responsible for rendering the format
provided by the graphic device that must provide a DisplaySurface
(ds->surface) in 16 or 32 bpp, rgb.
Afterwards sdl creates a SDL_Surface from the given DisplaySurface and
blits it into the main SDL_Surface using SDL_BlitSurface.

Everything is handled by sdl transparently, because SDL_BlitSurface is
perfectly capable of handling bgr displays by itself.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6335 c046a42c-6fe2-441c-8c8c-71466251a162
console.h
... ... @@ -139,6 +139,11 @@ static inline int ds_get_bits_per_pixel(DisplayState *ds)
139 139 return ds->depth;
140 140 }
141 141  
  142 +static inline int ds_get_bytes_per_pixel(DisplayState *ds)
  143 +{
  144 + return (ds->depth / 8);
  145 +}
  146 +
142 147 typedef unsigned long console_ch_t;
143 148 static inline void console_write_ch(console_ch_t *dest, uint32_t ch)
144 149 {
... ...
hw/musicpal.c
... ... @@ -829,7 +829,7 @@ static void lcd_refresh(void *opaque)
829 829 break;
830 830 LCD_REFRESH(8, rgb_to_pixel8)
831 831 LCD_REFRESH(16, rgb_to_pixel16)
832   - LCD_REFRESH(32, (s->ds->bgr ? rgb_to_pixel32bgr : rgb_to_pixel32))
  832 + LCD_REFRESH(32, rgb_to_pixel32)
833 833 default:
834 834 cpu_abort(cpu_single_env, "unsupported colour depth %i\n",
835 835 ds_get_bits_per_pixel(s->ds));
... ...
hw/sm501.c
... ... @@ -940,25 +940,16 @@ static draw_line_func * draw_line32_funcs[] = {
940 940  
941 941 static inline int get_depth_index(DisplayState *s)
942 942 {
943   - switch(s->depth) {
  943 + switch(ds_get_bits_per_pixel(s)) {
944 944 default:
945 945 case 8:
946 946 return 0;
947 947 case 15:
948   - if (s->bgr)
949   - return 5;
950   - else
951   - return 1;
  948 + return 1;
952 949 case 16:
953   - if (s->bgr)
954   - return 6;
955   - else
956   - return 2;
  950 + return 2;
957 951 case 32:
958   - if (s->bgr)
959   - return 4;
960   - else
961   - return 3;
  952 + return 3;
962 953 }
963 954 }
964 955  
... ... @@ -970,7 +961,7 @@ static void sm501_draw_crt(SM501State * s)
970 961  
971 962 uint8_t * src = s->local_mem;
972 963 int src_bpp = 0;
973   - int dst_bpp = s->ds->depth / 8 + (s->ds->depth % 8 ? 1 : 0);
  964 + int dst_bpp = ds_get_bytes_per_pixel(s->ds) + (ds_get_bits_per_pixel(s->ds) % 8 ? 1 : 0);
974 965 uint32_t * palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE
975 966 - SM501_DC_PANEL_PALETTE];
976 967 int ds_depth_index = get_depth_index(s->ds);
... ... @@ -1024,7 +1015,7 @@ static void sm501_draw_crt(SM501State * s)
1024 1015  
1025 1016 /* draw line and change status */
1026 1017 if (update) {
1027   - draw_line(&s->ds->data[y * width * dst_bpp], src, width, palette);
  1018 + draw_line(&(ds_get_data(s->ds)[y * width * dst_bpp]), src, width, palette);
1028 1019 if (y_start < 0)
1029 1020 y_start = y;
1030 1021 if (page0 < page_min)
... ...
hw/tcx.c
... ... @@ -61,22 +61,13 @@ static void update_palette_entries(TCXState *s, int start, int end)
61 61 s->palette[i] = rgb_to_pixel8(s->r[i], s->g[i], s->b[i]);
62 62 break;
63 63 case 15:
64   - if (s->ds->bgr)
65   - s->palette[i] = rgb_to_pixel15bgr(s->r[i], s->g[i], s->b[i]);
66   - else
67   - s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]);
  64 + s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]);
68 65 break;
69 66 case 16:
70   - if (s->ds->bgr)
71   - s->palette[i] = rgb_to_pixel16bgr(s->r[i], s->g[i], s->b[i]);
72   - else
73   - s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]);
  67 + s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]);
74 68 break;
75 69 case 32:
76   - if (s->ds->bgr)
77   - s->palette[i] = rgb_to_pixel32bgr(s->r[i], s->g[i], s->b[i]);
78   - else
79   - s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]);
  70 + s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]);
80 71 break;
81 72 }
82 73 }
... ... @@ -134,12 +125,11 @@ static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d,
134 125 const uint32_t *cplane,
135 126 const uint32_t *s24)
136 127 {
137   - int x, bgr, r, g, b;
  128 + int x, r, g, b;
138 129 uint8_t val, *p8;
139 130 uint32_t *p = (uint32_t *)d;
140 131 uint32_t dval;
141 132  
142   - bgr = s1->ds->bgr;
143 133 for(x = 0; x < width; x++, s++, s24++) {
144 134 if ((be32_to_cpu(*cplane++) & 0xff000000) == 0x03000000) {
145 135 // 24-bit direct, BGR order
... ... @@ -148,10 +138,7 @@ static inline void tcx24_draw_line32(TCXState *s1, uint8_t *d,
148 138 b = *p8++;
149 139 g = *p8++;
150 140 r = *p8++;
151   - if (bgr)
152   - dval = rgb_to_pixel32bgr(r, g, b);
153   - else
154   - dval = rgb_to_pixel32(r, g, b);
  141 + dval = rgb_to_pixel32(r, g, b);
155 142 } else {
156 143 val = *s;
157 144 dval = s1->palette[val];
... ...
hw/vga.c
... ... @@ -1157,20 +1157,11 @@ static inline int get_depth_index(DisplayState *s)
1157 1157 case 8:
1158 1158 return 0;
1159 1159 case 15:
1160   - if (s->bgr)
1161   - return 5;
1162   - else
1163   - return 1;
  1160 + return 1;
1164 1161 case 16:
1165   - if (s->bgr)
1166   - return 6;
1167   - else
1168   - return 2;
  1162 + return 2;
1169 1163 case 32:
1170   - if (s->bgr)
1171   - return 4;
1172   - else
1173   - return 3;
  1164 + return 3;
1174 1165 }
1175 1166 }
1176 1167  
... ...
... ... @@ -100,11 +100,6 @@ static void sdl_resize(DisplayState *ds, int w, int h)
100 100 if ((mask & 0x8000) == 0)
101 101 ds->depth = 15;
102 102 }
103   - if (ds->depth == 32 && screen->format->Rshift == 0) {
104   - ds->bgr = 1;
105   - } else {
106   - ds->bgr = 0;
107   - }
108 103 ds->width = w;
109 104 ds->height = h;
110 105 }
... ...