Commit b29169d2654776e749de91d65c720003ab4a2e66
1 parent
94470844
Attempt to fix incorrect colours on some BGR displays
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2974 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
4 changed files
with
74 additions
and
8 deletions
cocoa.m
... | ... | @@ -164,7 +164,12 @@ static void cocoa_resize(DisplayState *ds, int w, int h) |
164 | 164 | ds->depth = device_bpp; |
165 | 165 | ds->width = w; |
166 | 166 | ds->height = h; |
167 | - | |
167 | +#ifdef __LITTLE_ENDIAN__ | |
168 | + ds->bgr = 1; | |
169 | +#else | |
170 | + ds->bgr = 0; | |
171 | +#endif | |
172 | + | |
168 | 173 | current_ds = *ds; |
169 | 174 | } |
170 | 175 | ... | ... |
hw/tcx.c
... | ... | @@ -58,13 +58,22 @@ static void update_palette_entries(TCXState *s, int start, int end) |
58 | 58 | s->palette[i] = rgb_to_pixel8(s->r[i], s->g[i], s->b[i]); |
59 | 59 | break; |
60 | 60 | case 15: |
61 | - s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]); | |
61 | + if (s->ds->bgr) | |
62 | + s->palette[i] = rgb_to_pixel15bgr(s->r[i], s->g[i], s->b[i]); | |
63 | + else | |
64 | + s->palette[i] = rgb_to_pixel15(s->r[i], s->g[i], s->b[i]); | |
62 | 65 | break; |
63 | 66 | case 16: |
64 | - s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]); | |
67 | + if (s->ds->bgr) | |
68 | + s->palette[i] = rgb_to_pixel16bgr(s->r[i], s->g[i], s->b[i]); | |
69 | + else | |
70 | + s->palette[i] = rgb_to_pixel16(s->r[i], s->g[i], s->b[i]); | |
65 | 71 | break; |
66 | 72 | case 32: |
67 | - s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]); | |
73 | + if (s->ds->bgr) | |
74 | + s->palette[i] = rgb_to_pixel32bgr(s->r[i], s->g[i], s->b[i]); | |
75 | + else | |
76 | + s->palette[i] = rgb_to_pixel32(s->r[i], s->g[i], s->b[i]); | |
68 | 77 | break; |
69 | 78 | } |
70 | 79 | } | ... | ... |
hw/vga.c
... | ... | @@ -846,6 +846,15 @@ static unsigned int rgb_to_pixel15_dup(unsigned int r, unsigned int g, unsigned |
846 | 846 | return col; |
847 | 847 | } |
848 | 848 | |
849 | +static unsigned int rgb_to_pixel15bgr_dup(unsigned int r, unsigned int g, | |
850 | + unsigned int b) | |
851 | +{ | |
852 | + unsigned int col; | |
853 | + col = rgb_to_pixel15bgr(r, g, b); | |
854 | + col |= col << 16; | |
855 | + return col; | |
856 | +} | |
857 | + | |
849 | 858 | static unsigned int rgb_to_pixel16_dup(unsigned int r, unsigned int g, unsigned b) |
850 | 859 | { |
851 | 860 | unsigned int col; |
... | ... | @@ -854,6 +863,15 @@ static unsigned int rgb_to_pixel16_dup(unsigned int r, unsigned int g, unsigned |
854 | 863 | return col; |
855 | 864 | } |
856 | 865 | |
866 | +static unsigned int rgb_to_pixel16bgr_dup(unsigned int r, unsigned int g, | |
867 | + unsigned int b) | |
868 | +{ | |
869 | + unsigned int col; | |
870 | + col = rgb_to_pixel16bgr(r, g, b); | |
871 | + col |= col << 16; | |
872 | + return col; | |
873 | +} | |
874 | + | |
857 | 875 | static unsigned int rgb_to_pixel32_dup(unsigned int r, unsigned int g, unsigned b) |
858 | 876 | { |
859 | 877 | unsigned int col; |
... | ... | @@ -974,7 +992,7 @@ static int update_basic_params(VGAState *s) |
974 | 992 | return full_update; |
975 | 993 | } |
976 | 994 | |
977 | -#define NB_DEPTHS 5 | |
995 | +#define NB_DEPTHS 7 | |
978 | 996 | |
979 | 997 | static inline int get_depth_index(DisplayState *s) |
980 | 998 | { |
... | ... | @@ -983,9 +1001,15 @@ static inline int get_depth_index(DisplayState *s) |
983 | 1001 | case 8: |
984 | 1002 | return 0; |
985 | 1003 | case 15: |
986 | - return 1; | |
1004 | + if (s->bgr) | |
1005 | + return 5; | |
1006 | + else | |
1007 | + return 1; | |
987 | 1008 | case 16: |
988 | - return 2; | |
1009 | + if (s->bgr) | |
1010 | + return 6; | |
1011 | + else | |
1012 | + return 2; | |
989 | 1013 | case 32: |
990 | 1014 | if (s->bgr) |
991 | 1015 | return 4; |
... | ... | @@ -1000,6 +1024,8 @@ static vga_draw_glyph8_func *vga_draw_glyph8_table[NB_DEPTHS] = { |
1000 | 1024 | vga_draw_glyph8_16, |
1001 | 1025 | vga_draw_glyph8_32, |
1002 | 1026 | vga_draw_glyph8_32, |
1027 | + vga_draw_glyph8_16, | |
1028 | + vga_draw_glyph8_16, | |
1003 | 1029 | }; |
1004 | 1030 | |
1005 | 1031 | static vga_draw_glyph8_func *vga_draw_glyph16_table[NB_DEPTHS] = { |
... | ... | @@ -1008,6 +1034,8 @@ static vga_draw_glyph8_func *vga_draw_glyph16_table[NB_DEPTHS] = { |
1008 | 1034 | vga_draw_glyph16_16, |
1009 | 1035 | vga_draw_glyph16_32, |
1010 | 1036 | vga_draw_glyph16_32, |
1037 | + vga_draw_glyph16_16, | |
1038 | + vga_draw_glyph16_16, | |
1011 | 1039 | }; |
1012 | 1040 | |
1013 | 1041 | static vga_draw_glyph9_func *vga_draw_glyph9_table[NB_DEPTHS] = { |
... | ... | @@ -1016,6 +1044,8 @@ static vga_draw_glyph9_func *vga_draw_glyph9_table[NB_DEPTHS] = { |
1016 | 1044 | vga_draw_glyph9_16, |
1017 | 1045 | vga_draw_glyph9_32, |
1018 | 1046 | vga_draw_glyph9_32, |
1047 | + vga_draw_glyph9_16, | |
1048 | + vga_draw_glyph9_16, | |
1019 | 1049 | }; |
1020 | 1050 | |
1021 | 1051 | static const uint8_t cursor_glyph[32 * 4] = { |
... | ... | @@ -1236,60 +1266,80 @@ static vga_draw_line_func *vga_draw_line_table[NB_DEPTHS * VGA_DRAW_LINE_NB] = { |
1236 | 1266 | vga_draw_line2_16, |
1237 | 1267 | vga_draw_line2_32, |
1238 | 1268 | vga_draw_line2_32, |
1269 | + vga_draw_line2_16, | |
1270 | + vga_draw_line2_16, | |
1239 | 1271 | |
1240 | 1272 | vga_draw_line2d2_8, |
1241 | 1273 | vga_draw_line2d2_16, |
1242 | 1274 | vga_draw_line2d2_16, |
1243 | 1275 | vga_draw_line2d2_32, |
1244 | 1276 | vga_draw_line2d2_32, |
1277 | + vga_draw_line2d2_16, | |
1278 | + vga_draw_line2d2_16, | |
1245 | 1279 | |
1246 | 1280 | vga_draw_line4_8, |
1247 | 1281 | vga_draw_line4_16, |
1248 | 1282 | vga_draw_line4_16, |
1249 | 1283 | vga_draw_line4_32, |
1250 | 1284 | vga_draw_line4_32, |
1285 | + vga_draw_line4_16, | |
1286 | + vga_draw_line4_16, | |
1251 | 1287 | |
1252 | 1288 | vga_draw_line4d2_8, |
1253 | 1289 | vga_draw_line4d2_16, |
1254 | 1290 | vga_draw_line4d2_16, |
1255 | 1291 | vga_draw_line4d2_32, |
1256 | 1292 | vga_draw_line4d2_32, |
1293 | + vga_draw_line4d2_16, | |
1294 | + vga_draw_line4d2_16, | |
1257 | 1295 | |
1258 | 1296 | vga_draw_line8d2_8, |
1259 | 1297 | vga_draw_line8d2_16, |
1260 | 1298 | vga_draw_line8d2_16, |
1261 | 1299 | vga_draw_line8d2_32, |
1262 | 1300 | vga_draw_line8d2_32, |
1301 | + vga_draw_line8d2_16, | |
1302 | + vga_draw_line8d2_16, | |
1263 | 1303 | |
1264 | 1304 | vga_draw_line8_8, |
1265 | 1305 | vga_draw_line8_16, |
1266 | 1306 | vga_draw_line8_16, |
1267 | 1307 | vga_draw_line8_32, |
1268 | 1308 | vga_draw_line8_32, |
1309 | + vga_draw_line8_16, | |
1310 | + vga_draw_line8_16, | |
1269 | 1311 | |
1270 | 1312 | vga_draw_line15_8, |
1271 | 1313 | vga_draw_line15_15, |
1272 | 1314 | vga_draw_line15_16, |
1273 | 1315 | vga_draw_line15_32, |
1274 | 1316 | vga_draw_line15_32bgr, |
1317 | + vga_draw_line15_15bgr, | |
1318 | + vga_draw_line15_16bgr, | |
1275 | 1319 | |
1276 | 1320 | vga_draw_line16_8, |
1277 | 1321 | vga_draw_line16_15, |
1278 | 1322 | vga_draw_line16_16, |
1279 | 1323 | vga_draw_line16_32, |
1280 | 1324 | vga_draw_line16_32bgr, |
1325 | + vga_draw_line16_15bgr, | |
1326 | + vga_draw_line16_16bgr, | |
1281 | 1327 | |
1282 | 1328 | vga_draw_line24_8, |
1283 | 1329 | vga_draw_line24_15, |
1284 | 1330 | vga_draw_line24_16, |
1285 | 1331 | vga_draw_line24_32, |
1286 | 1332 | vga_draw_line24_32bgr, |
1333 | + vga_draw_line24_15bgr, | |
1334 | + vga_draw_line24_16bgr, | |
1287 | 1335 | |
1288 | 1336 | vga_draw_line32_8, |
1289 | 1337 | vga_draw_line32_15, |
1290 | 1338 | vga_draw_line32_16, |
1291 | 1339 | vga_draw_line32_32, |
1292 | 1340 | vga_draw_line32_32bgr, |
1341 | + vga_draw_line32_15bgr, | |
1342 | + vga_draw_line32_16bgr, | |
1293 | 1343 | }; |
1294 | 1344 | |
1295 | 1345 | typedef unsigned int rgb_to_pixel_dup_func(unsigned int r, unsigned int g, unsigned b); |
... | ... | @@ -1300,6 +1350,8 @@ static rgb_to_pixel_dup_func *rgb_to_pixel_dup_table[NB_DEPTHS] = { |
1300 | 1350 | rgb_to_pixel16_dup, |
1301 | 1351 | rgb_to_pixel32_dup, |
1302 | 1352 | rgb_to_pixel32bgr_dup, |
1353 | + rgb_to_pixel15bgr_dup, | |
1354 | + rgb_to_pixel16bgr_dup, | |
1303 | 1355 | }; |
1304 | 1356 | |
1305 | 1357 | static int vga_get_bpp(VGAState *s) | ... | ... |
sdl.c
... | ... | @@ -87,7 +87,7 @@ static void sdl_resize(DisplayState *ds, int w, int h) |
87 | 87 | ds->data = screen->pixels; |
88 | 88 | ds->linesize = screen->pitch; |
89 | 89 | ds->depth = screen->format->BitsPerPixel; |
90 | - if (ds->depth == 32 && screen->format->Rshift == 0) { | |
90 | + if (screen->format->Bshift > screen->format->Rshift) { | |
91 | 91 | ds->bgr = 1; |
92 | 92 | } else { |
93 | 93 | ds->bgr = 0; | ... | ... |