Revision d3079cd2 hw/vga.c

b/hw/vga.c
808 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 816
#define DEPTH 8
812 817
#include "vga_template.h"
813 818

  
......
820 825
#define DEPTH 32
821 826
#include "vga_template.h"
822 827

  
828
#define BGR_FORMAT
829
#define DEPTH 32
830
#include "vga_template.h"
831

  
823 832
static unsigned int rgb_to_pixel8_dup(unsigned int r, unsigned int g, unsigned b)
824 833
{
825 834
    unsigned int col;
......
852 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 871
/* return true if the palette was modified */
856 872
static int update_palette16(VGAState *s)
857 873
{
......
948 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 972
    default:
955 973
    case 8:
956 974
        return 0;
......
959 977
    case 16:
960 978
        return 2;
961 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 988
    vga_draw_glyph8_8,
968 989
    vga_draw_glyph8_16,
969 990
    vga_draw_glyph8_16,
970 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 996
    vga_draw_glyph16_8,
975 997
    vga_draw_glyph16_16,
976 998
    vga_draw_glyph16_16,
977 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 1004
    vga_draw_glyph9_8,
982 1005
    vga_draw_glyph9_16,
983 1006
    vga_draw_glyph9_16,
984 1007
    vga_draw_glyph9_32,
1008
    vga_draw_glyph9_32,
985 1009
};
986 1010
    
987 1011
static const uint8_t cursor_glyph[32 * 4] = {
......
1103 1127
    }
1104 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 1131
    if (cw == 16)
1108 1132
        vga_draw_glyph8 = vga_draw_glyph16_table[depth_index];
1109 1133
    else
......
1196 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 1224
    vga_draw_line2_8,
1201 1225
    vga_draw_line2_16,
1202 1226
    vga_draw_line2_16,
1203 1227
    vga_draw_line2_32,
1228
    vga_draw_line2_32,
1204 1229

  
1205 1230
    vga_draw_line2d2_8,
1206 1231
    vga_draw_line2d2_16,
1207 1232
    vga_draw_line2d2_16,
1208 1233
    vga_draw_line2d2_32,
1234
    vga_draw_line2d2_32,
1209 1235

  
1210 1236
    vga_draw_line4_8,
1211 1237
    vga_draw_line4_16,
1212 1238
    vga_draw_line4_16,
1213 1239
    vga_draw_line4_32,
1240
    vga_draw_line4_32,
1214 1241

  
1215 1242
    vga_draw_line4d2_8,
1216 1243
    vga_draw_line4d2_16,
1217 1244
    vga_draw_line4d2_16,
1218 1245
    vga_draw_line4d2_32,
1246
    vga_draw_line4d2_32,
1219 1247

  
1220 1248
    vga_draw_line8d2_8,
1221 1249
    vga_draw_line8d2_16,
1222 1250
    vga_draw_line8d2_16,
1223 1251
    vga_draw_line8d2_32,
1252
    vga_draw_line8d2_32,
1224 1253

  
1225 1254
    vga_draw_line8_8,
1226 1255
    vga_draw_line8_16,
1227 1256
    vga_draw_line8_16,
1228 1257
    vga_draw_line8_32,
1258
    vga_draw_line8_32,
1229 1259

  
1230 1260
    vga_draw_line15_8,
1231 1261
    vga_draw_line15_15,
1232 1262
    vga_draw_line15_16,
1233 1263
    vga_draw_line15_32,
1264
    vga_draw_line15_32bgr,
1234 1265

  
1235 1266
    vga_draw_line16_8,
1236 1267
    vga_draw_line16_15,
1237 1268
    vga_draw_line16_16,
1238 1269
    vga_draw_line16_32,
1270
    vga_draw_line16_32bgr,
1239 1271

  
1240 1272
    vga_draw_line24_8,
1241 1273
    vga_draw_line24_15,
1242 1274
    vga_draw_line24_16,
1243 1275
    vga_draw_line24_32,
1276
    vga_draw_line24_32bgr,
1244 1277

  
1245 1278
    vga_draw_line32_8,
1246 1279
    vga_draw_line32_15,
1247 1280
    vga_draw_line32_16,
1248 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 1295
static int vga_get_bpp(VGAState *s)
......
1362 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 1411
    if (disp_width != s->last_width ||
1368 1412
        height != s->last_height) {
......
1492 1536
    if (s->ds->depth == 0) {
1493 1537
        /* nothing to do */
1494 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 1542
        full_update = 0;
1512 1543
        if (!(s->ar_index & 0x20)) {

Also available in: Unified diff