Revision c78f7137 hw/sm501.c

b/hw/sm501.c
454 454

  
455 455
typedef struct SM501State {
456 456
    /* graphic console status */
457
    DisplayState *ds;
457
    QemuConsole *con;
458 458

  
459 459
    /* status & internal resources */
460 460
    hwaddr base;
......
1234 1234
    draw_hwc_line_16bgr,
1235 1235
};
1236 1236

  
1237
static inline int get_depth_index(DisplayState *s)
1237
static inline int get_depth_index(DisplaySurface *surface)
1238 1238
{
1239
    switch(ds_get_bits_per_pixel(s)) {
1239
    switch (surface_bits_per_pixel(surface)) {
1240 1240
    default:
1241 1241
    case 8:
1242 1242
	return 0;
......
1245 1245
    case 16:
1246 1246
        return 2;
1247 1247
    case 32:
1248
	if (is_surface_bgr(s->surface))
1249
	    return 4;
1250
	else
1251
	    return 3;
1248
        if (is_surface_bgr(surface)) {
1249
            return 4;
1250
        } else {
1251
            return 3;
1252
        }
1252 1253
    }
1253 1254
}
1254 1255

  
1255 1256
static void sm501_draw_crt(SM501State * s)
1256 1257
{
1258
    DisplaySurface *surface = qemu_console_surface(s->con);
1257 1259
    int y;
1258 1260
    int width = (s->dc_crt_h_total & 0x00000FFF) + 1;
1259 1261
    int height = (s->dc_crt_v_total & 0x00000FFF) + 1;
1260 1262

  
1261 1263
    uint8_t  * src = s->local_mem;
1262 1264
    int src_bpp = 0;
1263
    int dst_bpp = ds_get_bytes_per_pixel(s->ds) + (ds_get_bits_per_pixel(s->ds) % 8 ? 1 : 0);
1265
    int dst_bpp = surface_bytes_per_pixel(surface);
1264 1266
    uint32_t * palette = (uint32_t *)&s->dc_palette[SM501_DC_CRT_PALETTE
1265 1267
						    - SM501_DC_PANEL_PALETTE];
1266 1268
    uint8_t hwc_palette[3 * 3];
1267
    int ds_depth_index = get_depth_index(s->ds);
1269
    int ds_depth_index = get_depth_index(surface);
1268 1270
    draw_line_func * draw_line = NULL;
1269 1271
    draw_hwc_line_func * draw_hwc_line = NULL;
1270 1272
    int full_update = 0;
......
1312 1314

  
1313 1315
    /* adjust console size */
1314 1316
    if (s->last_width != width || s->last_height != height) {
1315
	qemu_console_resize(s->ds, width, height);
1317
        qemu_console_resize(s->con, width, height);
1318
        surface = qemu_console_surface(s->con);
1316 1319
	s->last_width = width;
1317 1320
	s->last_height = height;
1318 1321
	full_update = 1;
......
1331 1334

  
1332 1335
	/* draw line and change status */
1333 1336
	if (update) {
1334
            uint8_t * d = &(ds_get_data(s->ds)[y * width * dst_bpp]);
1337
            uint8_t *d = surface_data(surface);
1338
            d +=  y * width * dst_bpp;
1335 1339

  
1336 1340
            /* draw graphics layer */
1337 1341
            draw_line(d, src, width, palette);
......
1350 1354
	} else {
1351 1355
	    if (y_start >= 0) {
1352 1356
		/* flush to display */
1353
                dpy_gfx_update(s->ds, 0, y_start, width, y - y_start);
1357
                dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
1354 1358
		y_start = -1;
1355 1359
	    }
1356 1360
	}
......
1361 1365

  
1362 1366
    /* complete flush to display */
1363 1367
    if (y_start >= 0)
1364
        dpy_gfx_update(s->ds, 0, y_start, width, y - y_start);
1368
        dpy_gfx_update(s->con, 0, y_start, width, y - y_start);
1365 1369

  
1366 1370
    /* clear dirty flags */
1367 1371
    if (page_min != ~0l) {
......
1441 1445
    }
1442 1446

  
1443 1447
    /* create qemu graphic console */
1444
    s->ds = graphic_console_init(sm501_update_display, NULL,
1445
				 NULL, NULL, s);
1448
    s->con = graphic_console_init(sm501_update_display, NULL,
1449
                                  NULL, NULL, s);
1446 1450
}

Also available in: Unified diff