Commit d3079cd241329456462e5b9d1bce7ddcf658fe35

Authored by bellard
1 parent 38f3e7c2

bgr32 pixel format support


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1912 c046a42c-6fe2-441c-8c8c-71466251a162
hw/vga.c
@@ -808,6 +808,11 @@ static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsign @@ -808,6 +808,11 @@ static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsign
808 return (r << 16) | (g << 8) | b; 808 return (r << 16) | (g << 8) | b;
809 } 809 }
810 810
  811 +static inline unsigned int rgb_to_pixel32bgr(unsigned int r, unsigned int g, unsigned b)
  812 +{
  813 + return (b << 16) | (g << 8) | r;
  814 +}
  815 +
811 #define DEPTH 8 816 #define DEPTH 8
812 #include "vga_template.h" 817 #include "vga_template.h"
813 818
@@ -820,6 +825,10 @@ static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsign @@ -820,6 +825,10 @@ static inline unsigned int rgb_to_pixel32(unsigned int r, unsigned int g, unsign
820 #define DEPTH 32 825 #define DEPTH 32
821 #include "vga_template.h" 826 #include "vga_template.h"
822 827
  828 +#define BGR_FORMAT
  829 +#define DEPTH 32
  830 +#include "vga_template.h"
  831 +
823 static unsigned int rgb_to_pixel8_dup(unsigned int r, unsigned int g, unsigned b) 832 static unsigned int rgb_to_pixel8_dup(unsigned int r, unsigned int g, unsigned b)
824 { 833 {
825 unsigned int col; 834 unsigned int col;
@@ -852,6 +861,13 @@ static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned @@ -852,6 +861,13 @@ static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned
852 return col; 861 return col;
853 } 862 }
854 863
  864 +static unsigned int rgb_to_pixel32bgr_dup(unsigned int r, unsigned int g, unsigned b)
  865 +{
  866 + unsigned int col;
  867 + col = rgb_to_pixel32bgr(r, g, b);
  868 + return col;
  869 +}
  870 +
855 /* return true if the palette was modified */ 871 /* return true if the palette was modified */
856 static int update_palette16(VGAState *s) 872 static int update_palette16(VGAState *s)
857 { 873 {
@@ -948,9 +964,11 @@ static int update_basic_params(VGAState *s) @@ -948,9 +964,11 @@ static int update_basic_params(VGAState *s)
948 return full_update; 964 return full_update;
949 } 965 }
950 966
951 -static inline int get_depth_index(int depth) 967 +#define NB_DEPTHS 5
  968 +
  969 +static inline int get_depth_index(DisplayState *s)
952 { 970 {
953 - switch(depth) { 971 + switch(s->depth) {
954 default: 972 default:
955 case 8: 973 case 8:
956 return 0; 974 return 0;
@@ -959,29 +977,35 @@ static inline int get_depth_index(int depth) @@ -959,29 +977,35 @@ static inline int get_depth_index(int depth)
959 case 16: 977 case 16:
960 return 2; 978 return 2;
961 case 32: 979 case 32:
962 - return 3; 980 + if (s->bgr)
  981 + return 4;
  982 + else
  983 + return 3;
963 } 984 }
964 } 985 }
965 986
966 -static vga_draw_glyph8_func *vga_draw_glyph8_table[4] = { 987 +static vga_draw_glyph8_func *vga_draw_glyph8_table[NB_DEPTHS] = {
967 vga_draw_glyph8_8, 988 vga_draw_glyph8_8,
968 vga_draw_glyph8_16, 989 vga_draw_glyph8_16,
969 vga_draw_glyph8_16, 990 vga_draw_glyph8_16,
970 vga_draw_glyph8_32, 991 vga_draw_glyph8_32,
  992 + vga_draw_glyph8_32,
971 }; 993 };
972 994
973 -static vga_draw_glyph8_func *vga_draw_glyph16_table[4] = { 995 +static vga_draw_glyph8_func *vga_draw_glyph16_table[NB_DEPTHS] = {
974 vga_draw_glyph16_8, 996 vga_draw_glyph16_8,
975 vga_draw_glyph16_16, 997 vga_draw_glyph16_16,
976 vga_draw_glyph16_16, 998 vga_draw_glyph16_16,
977 vga_draw_glyph16_32, 999 vga_draw_glyph16_32,
  1000 + vga_draw_glyph16_32,
978 }; 1001 };
979 1002
980 -static vga_draw_glyph9_func *vga_draw_glyph9_table[4] = { 1003 +static vga_draw_glyph9_func *vga_draw_glyph9_table[NB_DEPTHS] = {
981 vga_draw_glyph9_8, 1004 vga_draw_glyph9_8,
982 vga_draw_glyph9_16, 1005 vga_draw_glyph9_16,
983 vga_draw_glyph9_16, 1006 vga_draw_glyph9_16,
984 vga_draw_glyph9_32, 1007 vga_draw_glyph9_32,
  1008 + vga_draw_glyph9_32,
985 }; 1009 };
986 1010
987 static const uint8_t cursor_glyph[32 * 4] = { 1011 static const uint8_t cursor_glyph[32 * 4] = {
@@ -1103,7 +1127,7 @@ static void vga_draw_text(VGAState *s, int full_update) @@ -1103,7 +1127,7 @@ static void vga_draw_text(VGAState *s, int full_update)
1103 } 1127 }
1104 cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4; 1128 cursor_ptr = s->vram_ptr + (s->start_addr + cursor_offset) * 4;
1105 1129
1106 - depth_index = get_depth_index(s->ds->depth); 1130 + depth_index = get_depth_index(s->ds);
1107 if (cw == 16) 1131 if (cw == 16)
1108 vga_draw_glyph8 = vga_draw_glyph16_table[depth_index]; 1132 vga_draw_glyph8 = vga_draw_glyph16_table[depth_index];
1109 else 1133 else
@@ -1196,56 +1220,76 @@ enum { @@ -1196,56 +1220,76 @@ enum {
1196 VGA_DRAW_LINE_NB, 1220 VGA_DRAW_LINE_NB,
1197 }; 1221 };
1198 1222
1199 -static vga_draw_line_func *vga_draw_line_table[4 * VGA_DRAW_LINE_NB] = { 1223 +static vga_draw_line_func *vga_draw_line_table[NB_DEPTHS * VGA_DRAW_LINE_NB] = {
1200 vga_draw_line2_8, 1224 vga_draw_line2_8,
1201 vga_draw_line2_16, 1225 vga_draw_line2_16,
1202 vga_draw_line2_16, 1226 vga_draw_line2_16,
1203 vga_draw_line2_32, 1227 vga_draw_line2_32,
  1228 + vga_draw_line2_32,
1204 1229
1205 vga_draw_line2d2_8, 1230 vga_draw_line2d2_8,
1206 vga_draw_line2d2_16, 1231 vga_draw_line2d2_16,
1207 vga_draw_line2d2_16, 1232 vga_draw_line2d2_16,
1208 vga_draw_line2d2_32, 1233 vga_draw_line2d2_32,
  1234 + vga_draw_line2d2_32,
1209 1235
1210 vga_draw_line4_8, 1236 vga_draw_line4_8,
1211 vga_draw_line4_16, 1237 vga_draw_line4_16,
1212 vga_draw_line4_16, 1238 vga_draw_line4_16,
1213 vga_draw_line4_32, 1239 vga_draw_line4_32,
  1240 + vga_draw_line4_32,
1214 1241
1215 vga_draw_line4d2_8, 1242 vga_draw_line4d2_8,
1216 vga_draw_line4d2_16, 1243 vga_draw_line4d2_16,
1217 vga_draw_line4d2_16, 1244 vga_draw_line4d2_16,
1218 vga_draw_line4d2_32, 1245 vga_draw_line4d2_32,
  1246 + vga_draw_line4d2_32,
1219 1247
1220 vga_draw_line8d2_8, 1248 vga_draw_line8d2_8,
1221 vga_draw_line8d2_16, 1249 vga_draw_line8d2_16,
1222 vga_draw_line8d2_16, 1250 vga_draw_line8d2_16,
1223 vga_draw_line8d2_32, 1251 vga_draw_line8d2_32,
  1252 + vga_draw_line8d2_32,
1224 1253
1225 vga_draw_line8_8, 1254 vga_draw_line8_8,
1226 vga_draw_line8_16, 1255 vga_draw_line8_16,
1227 vga_draw_line8_16, 1256 vga_draw_line8_16,
1228 vga_draw_line8_32, 1257 vga_draw_line8_32,
  1258 + vga_draw_line8_32,
1229 1259
1230 vga_draw_line15_8, 1260 vga_draw_line15_8,
1231 vga_draw_line15_15, 1261 vga_draw_line15_15,
1232 vga_draw_line15_16, 1262 vga_draw_line15_16,
1233 vga_draw_line15_32, 1263 vga_draw_line15_32,
  1264 + vga_draw_line15_32bgr,
1234 1265
1235 vga_draw_line16_8, 1266 vga_draw_line16_8,
1236 vga_draw_line16_15, 1267 vga_draw_line16_15,
1237 vga_draw_line16_16, 1268 vga_draw_line16_16,
1238 vga_draw_line16_32, 1269 vga_draw_line16_32,
  1270 + vga_draw_line16_32bgr,
1239 1271
1240 vga_draw_line24_8, 1272 vga_draw_line24_8,
1241 vga_draw_line24_15, 1273 vga_draw_line24_15,
1242 vga_draw_line24_16, 1274 vga_draw_line24_16,
1243 vga_draw_line24_32, 1275 vga_draw_line24_32,
  1276 + vga_draw_line24_32bgr,
1244 1277
1245 vga_draw_line32_8, 1278 vga_draw_line32_8,
1246 vga_draw_line32_15, 1279 vga_draw_line32_15,
1247 vga_draw_line32_16, 1280 vga_draw_line32_16,
1248 vga_draw_line32_32, 1281 vga_draw_line32_32,
  1282 + vga_draw_line32_32bgr,
  1283 +};
  1284 +
  1285 +typedef unsigned int rgb_to_pixel_dup_func(unsigned int r, unsigned int g, unsigned b);
  1286 +
  1287 +static rgb_to_pixel_dup_func *rgb_to_pixel_dup_table[NB_DEPTHS] = {
  1288 + rgb_to_pixel8_dup,
  1289 + rgb_to_pixel15_dup,
  1290 + rgb_to_pixel16_dup,
  1291 + rgb_to_pixel32_dup,
  1292 + rgb_to_pixel32bgr_dup,
1249 }; 1293 };
1250 1294
1251 static int vga_get_bpp(VGAState *s) 1295 static int vga_get_bpp(VGAState *s)
@@ -1362,7 +1406,7 @@ static void vga_draw_graphic(VGAState *s, int full_update) @@ -1362,7 +1406,7 @@ static void vga_draw_graphic(VGAState *s, int full_update)
1362 break; 1406 break;
1363 } 1407 }
1364 } 1408 }
1365 - vga_draw_line = vga_draw_line_table[v * 4 + get_depth_index(s->ds->depth)]; 1409 + vga_draw_line = vga_draw_line_table[v * NB_DEPTHS + get_depth_index(s->ds)];
1366 1410
1367 if (disp_width != s->last_width || 1411 if (disp_width != s->last_width ||
1368 height != s->last_height) { 1412 height != s->last_height) {
@@ -1492,21 +1536,8 @@ static void vga_update_display(void *opaque) @@ -1492,21 +1536,8 @@ static void vga_update_display(void *opaque)
1492 if (s->ds->depth == 0) { 1536 if (s->ds->depth == 0) {
1493 /* nothing to do */ 1537 /* nothing to do */
1494 } else { 1538 } else {
1495 - switch(s->ds->depth) {  
1496 - case 8:  
1497 - s->rgb_to_pixel = rgb_to_pixel8_dup;  
1498 - break;  
1499 - case 15:  
1500 - s->rgb_to_pixel = rgb_to_pixel15_dup;  
1501 - break;  
1502 - default:  
1503 - case 16:  
1504 - s->rgb_to_pixel = rgb_to_pixel16_dup;  
1505 - break;  
1506 - case 32:  
1507 - s->rgb_to_pixel = rgb_to_pixel32_dup;  
1508 - break;  
1509 - } 1539 + s->rgb_to_pixel =
  1540 + rgb_to_pixel_dup_table[get_depth_index(s->ds)];
1510 1541
1511 full_update = 0; 1542 full_update = 0;
1512 if (!(s->ar_index & 0x20)) { 1543 if (!(s->ar_index & 0x20)) {
hw/vga_template.h
@@ -35,7 +35,13 @@ @@ -35,7 +35,13 @@
35 #error unsupport depth 35 #error unsupport depth
36 #endif 36 #endif
37 37
38 -#if DEPTH != 15 38 +#ifdef BGR_FORMAT
  39 +#define PIXEL_NAME glue(DEPTH, bgr)
  40 +#else
  41 +#define PIXEL_NAME DEPTH
  42 +#endif /* BGR_FORMAT */
  43 +
  44 +#if DEPTH != 15 && !defined(BGR_FORMAT)
39 45
40 static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d, 46 static inline void glue(vga_draw_glyph_line_, DEPTH)(uint8_t *d,
41 uint32_t font_data, 47 uint32_t font_data,
@@ -334,6 +340,72 @@ static void glue(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d, @@ -334,6 +340,72 @@ static void glue(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d,
334 } 340 }
335 } 341 }
336 342
  343 +void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1,
  344 + const uint8_t *src1,
  345 + int poffset, int w,
  346 + unsigned int color0,
  347 + unsigned int color1,
  348 + unsigned int color_xor)
  349 +{
  350 + const uint8_t *plane0, *plane1;
  351 + int x, b0, b1;
  352 + uint8_t *d;
  353 +
  354 + d = d1;
  355 + plane0 = src1;
  356 + plane1 = src1 + poffset;
  357 + for(x = 0; x < w; x++) {
  358 + b0 = (plane0[x >> 3] >> (7 - (x & 7))) & 1;
  359 + b1 = (plane1[x >> 3] >> (7 - (x & 7))) & 1;
  360 +#if DEPTH == 8
  361 + switch(b0 | (b1 << 1)) {
  362 + case 0:
  363 + break;
  364 + case 1:
  365 + d[0] ^= color_xor;
  366 + break;
  367 + case 2:
  368 + d[0] = color0;
  369 + break;
  370 + case 3:
  371 + d[0] = color1;
  372 + break;
  373 + }
  374 +#elif DEPTH == 16
  375 + switch(b0 | (b1 << 1)) {
  376 + case 0:
  377 + break;
  378 + case 1:
  379 + ((uint16_t *)d)[0] ^= color_xor;
  380 + break;
  381 + case 2:
  382 + ((uint16_t *)d)[0] = color0;
  383 + break;
  384 + case 3:
  385 + ((uint16_t *)d)[0] = color1;
  386 + break;
  387 + }
  388 +#elif DEPTH == 32
  389 + switch(b0 | (b1 << 1)) {
  390 + case 0:
  391 + break;
  392 + case 1:
  393 + ((uint32_t *)d)[0] ^= color_xor;
  394 + break;
  395 + case 2:
  396 + ((uint32_t *)d)[0] = color0;
  397 + break;
  398 + case 3:
  399 + ((uint32_t *)d)[0] = color1;
  400 + break;
  401 + }
  402 +#else
  403 +#error unsupported depth
  404 +#endif
  405 + d += BPP;
  406 + }
  407 +}
  408 +
337 #endif /* DEPTH != 15 */ 409 #endif /* DEPTH != 15 */
338 410
339 411
@@ -342,7 +414,7 @@ static void glue(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d, @@ -342,7 +414,7 @@ static void glue(vga_draw_line8_, DEPTH)(VGAState *s1, uint8_t *d,
342 /* 414 /*
343 * 15 bit color 415 * 15 bit color
344 */ 416 */
345 -static void glue(vga_draw_line15_, DEPTH)(VGAState *s1, uint8_t *d, 417 +static void glue(vga_draw_line15_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
346 const uint8_t *s, int width) 418 const uint8_t *s, int width)
347 { 419 {
348 #if DEPTH == 15 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) 420 #if DEPTH == 15 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
@@ -357,7 +429,7 @@ static void glue(vga_draw_line15_, DEPTH)(VGAState *s1, uint8_t *d, @@ -357,7 +429,7 @@ static void glue(vga_draw_line15_, DEPTH)(VGAState *s1, uint8_t *d,
357 r = (v >> 7) & 0xf8; 429 r = (v >> 7) & 0xf8;
358 g = (v >> 2) & 0xf8; 430 g = (v >> 2) & 0xf8;
359 b = (v << 3) & 0xf8; 431 b = (v << 3) & 0xf8;
360 - ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); 432 + ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
361 s += 2; 433 s += 2;
362 d += BPP; 434 d += BPP;
363 } while (--w != 0); 435 } while (--w != 0);
@@ -367,7 +439,7 @@ static void glue(vga_draw_line15_, DEPTH)(VGAState *s1, uint8_t *d, @@ -367,7 +439,7 @@ static void glue(vga_draw_line15_, DEPTH)(VGAState *s1, uint8_t *d,
367 /* 439 /*
368 * 16 bit color 440 * 16 bit color
369 */ 441 */
370 -static void glue(vga_draw_line16_, DEPTH)(VGAState *s1, uint8_t *d, 442 +static void glue(vga_draw_line16_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
371 const uint8_t *s, int width) 443 const uint8_t *s, int width)
372 { 444 {
373 #if DEPTH == 16 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) 445 #if DEPTH == 16 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
@@ -382,7 +454,7 @@ static void glue(vga_draw_line16_, DEPTH)(VGAState *s1, uint8_t *d, @@ -382,7 +454,7 @@ static void glue(vga_draw_line16_, DEPTH)(VGAState *s1, uint8_t *d,
382 r = (v >> 8) & 0xf8; 454 r = (v >> 8) & 0xf8;
383 g = (v >> 3) & 0xfc; 455 g = (v >> 3) & 0xfc;
384 b = (v << 3) & 0xf8; 456 b = (v << 3) & 0xf8;
385 - ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); 457 + ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
386 s += 2; 458 s += 2;
387 d += BPP; 459 d += BPP;
388 } while (--w != 0); 460 } while (--w != 0);
@@ -392,7 +464,7 @@ static void glue(vga_draw_line16_, DEPTH)(VGAState *s1, uint8_t *d, @@ -392,7 +464,7 @@ static void glue(vga_draw_line16_, DEPTH)(VGAState *s1, uint8_t *d,
392 /* 464 /*
393 * 24 bit color 465 * 24 bit color
394 */ 466 */
395 -static void glue(vga_draw_line24_, DEPTH)(VGAState *s1, uint8_t *d, 467 +static void glue(vga_draw_line24_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
396 const uint8_t *s, int width) 468 const uint8_t *s, int width)
397 { 469 {
398 int w; 470 int w;
@@ -409,7 +481,7 @@ static void glue(vga_draw_line24_, DEPTH)(VGAState *s1, uint8_t *d, @@ -409,7 +481,7 @@ static void glue(vga_draw_line24_, DEPTH)(VGAState *s1, uint8_t *d,
409 g = s[1]; 481 g = s[1];
410 r = s[2]; 482 r = s[2];
411 #endif 483 #endif
412 - ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); 484 + ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
413 s += 3; 485 s += 3;
414 d += BPP; 486 d += BPP;
415 } while (--w != 0); 487 } while (--w != 0);
@@ -418,7 +490,7 @@ static void glue(vga_draw_line24_, DEPTH)(VGAState *s1, uint8_t *d, @@ -418,7 +490,7 @@ static void glue(vga_draw_line24_, DEPTH)(VGAState *s1, uint8_t *d,
418 /* 490 /*
419 * 32 bit color 491 * 32 bit color
420 */ 492 */
421 -static void glue(vga_draw_line32_, DEPTH)(VGAState *s1, uint8_t *d, 493 +static void glue(vga_draw_line32_, PIXEL_NAME)(VGAState *s1, uint8_t *d,
422 const uint8_t *s, int width) 494 const uint8_t *s, int width)
423 { 495 {
424 #if DEPTH == 32 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN) 496 #if DEPTH == 32 && defined(WORDS_BIGENDIAN) == defined(TARGET_WORDS_BIGENDIAN)
@@ -438,82 +510,16 @@ static void glue(vga_draw_line32_, DEPTH)(VGAState *s1, uint8_t *d, @@ -438,82 +510,16 @@ static void glue(vga_draw_line32_, DEPTH)(VGAState *s1, uint8_t *d,
438 g = s[1]; 510 g = s[1];
439 r = s[2]; 511 r = s[2];
440 #endif 512 #endif
441 - ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, DEPTH)(r, g, b); 513 + ((PIXEL_TYPE *)d)[0] = glue(rgb_to_pixel, PIXEL_NAME)(r, g, b);
442 s += 4; 514 s += 4;
443 d += BPP; 515 d += BPP;
444 } while (--w != 0); 516 } while (--w != 0);
445 #endif 517 #endif
446 } 518 }
447 519
448 -#if DEPTH != 15  
449 -void glue(vga_draw_cursor_line_, DEPTH)(uint8_t *d1,  
450 - const uint8_t *src1,  
451 - int poffset, int w,  
452 - unsigned int color0,  
453 - unsigned int color1,  
454 - unsigned int color_xor)  
455 -{  
456 - const uint8_t *plane0, *plane1;  
457 - int x, b0, b1;  
458 - uint8_t *d;  
459 -  
460 - d = d1;  
461 - plane0 = src1;  
462 - plane1 = src1 + poffset;  
463 - for(x = 0; x < w; x++) {  
464 - b0 = (plane0[x >> 3] >> (7 - (x & 7))) & 1;  
465 - b1 = (plane1[x >> 3] >> (7 - (x & 7))) & 1;  
466 -#if DEPTH == 8  
467 - switch(b0 | (b1 << 1)) {  
468 - case 0:  
469 - break;  
470 - case 1:  
471 - d[0] ^= color_xor;  
472 - break;  
473 - case 2:  
474 - d[0] = color0;  
475 - break;  
476 - case 3:  
477 - d[0] = color1;  
478 - break;  
479 - }  
480 -#elif DEPTH == 16  
481 - switch(b0 | (b1 << 1)) {  
482 - case 0:  
483 - break;  
484 - case 1:  
485 - ((uint16_t *)d)[0] ^= color_xor;  
486 - break;  
487 - case 2:  
488 - ((uint16_t *)d)[0] = color0;  
489 - break;  
490 - case 3:  
491 - ((uint16_t *)d)[0] = color1;  
492 - break;  
493 - }  
494 -#elif DEPTH == 32  
495 - switch(b0 | (b1 << 1)) {  
496 - case 0:  
497 - break;  
498 - case 1:  
499 - ((uint32_t *)d)[0] ^= color_xor;  
500 - break;  
501 - case 2:  
502 - ((uint32_t *)d)[0] = color0;  
503 - break;  
504 - case 3:  
505 - ((uint32_t *)d)[0] = color1;  
506 - break;  
507 - }  
508 -#else  
509 -#error unsupported depth  
510 -#endif  
511 - d += BPP;  
512 - }  
513 -}  
514 -#endif  
515 -  
516 #undef PUT_PIXEL2 520 #undef PUT_PIXEL2
517 #undef DEPTH 521 #undef DEPTH
518 #undef BPP 522 #undef BPP
519 #undef PIXEL_TYPE 523 #undef PIXEL_TYPE
  524 +#undef PIXEL_NAME
  525 +#undef BGR_FORMAT
@@ -81,6 +81,11 @@ static void sdl_resize(DisplayState *ds, int w, int h) @@ -81,6 +81,11 @@ static void sdl_resize(DisplayState *ds, int w, int h)
81 ds->data = screen->pixels; 81 ds->data = screen->pixels;
82 ds->linesize = screen->pitch; 82 ds->linesize = screen->pitch;
83 ds->depth = screen->format->BitsPerPixel; 83 ds->depth = screen->format->BitsPerPixel;
  84 + if (ds->depth == 32 && screen->format->Rshift == 0) {
  85 + ds->bgr = 1;
  86 + } else {
  87 + ds->bgr = 0;
  88 + }
84 ds->width = w; 89 ds->width = w;
85 ds->height = h; 90 ds->height = h;
86 } 91 }
@@ -677,6 +677,7 @@ struct DisplayState { @@ -677,6 +677,7 @@ struct DisplayState {
677 uint8_t *data; 677 uint8_t *data;
678 int linesize; 678 int linesize;
679 int depth; 679 int depth;
  680 + int bgr; /* BGR color order instead of RGB. Only valid for depth == 32 */
680 int width; 681 int width;
681 int height; 682 int height;
682 void *opaque; 683 void *opaque;