Revision 3023f332 console.c
b/console.c | ||
---|---|---|
1190 | 1190 |
} |
1191 | 1191 |
} |
1192 | 1192 |
|
1193 |
static TextConsole *get_graphic_console() { |
|
1194 |
int i; |
|
1195 |
TextConsole *s; |
|
1196 |
for (i = 0; i < nb_consoles; i++) { |
|
1197 |
s = consoles[i]; |
|
1198 |
if (s->console_type == GRAPHIC_CONSOLE) |
|
1199 |
return s; |
|
1200 |
} |
|
1201 |
return NULL; |
|
1202 |
} |
|
1203 |
|
|
1193 | 1204 |
static TextConsole *new_console(DisplayState *ds, console_type_t console_type) |
1194 | 1205 |
{ |
1195 | 1206 |
TextConsole *s; |
... | ... | |
1217 | 1228 |
consoles[i] = consoles[i - 1]; |
1218 | 1229 |
} |
1219 | 1230 |
consoles[i] = s; |
1231 |
nb_consoles++; |
|
1220 | 1232 |
} |
1221 | 1233 |
return s; |
1222 | 1234 |
} |
1223 | 1235 |
|
1224 |
TextConsole *graphic_console_init(DisplayState *ds, vga_hw_update_ptr update,
|
|
1225 |
vga_hw_invalidate_ptr invalidate, |
|
1226 |
vga_hw_screen_dump_ptr screen_dump, |
|
1227 |
vga_hw_text_update_ptr text_update, |
|
1228 |
void *opaque) |
|
1236 |
DisplayState *graphic_console_init(vga_hw_update_ptr update,
|
|
1237 |
vga_hw_invalidate_ptr invalidate,
|
|
1238 |
vga_hw_screen_dump_ptr screen_dump,
|
|
1239 |
vga_hw_text_update_ptr text_update,
|
|
1240 |
void *opaque)
|
|
1229 | 1241 |
{ |
1230 | 1242 |
TextConsole *s; |
1243 |
DisplayState *ds; |
|
1244 |
|
|
1245 |
ds = (DisplayState *) qemu_mallocz(sizeof(DisplayState)); |
|
1246 |
if (ds == NULL) |
|
1247 |
return NULL; |
|
1248 |
ds->surface = qemu_create_displaysurface(640, 480, 32, 640 * 4); |
|
1231 | 1249 |
|
1232 | 1250 |
s = new_console(ds, GRAPHIC_CONSOLE); |
1233 |
if (!s) |
|
1234 |
return NULL; |
|
1251 |
if (s == NULL) { |
|
1252 |
qemu_free_displaysurface(ds->surface); |
|
1253 |
qemu_free(ds); |
|
1254 |
return NULL; |
|
1255 |
} |
|
1235 | 1256 |
s->hw_update = update; |
1236 | 1257 |
s->hw_invalidate = invalidate; |
1237 | 1258 |
s->hw_screen_dump = screen_dump; |
1238 | 1259 |
s->hw_text_update = text_update; |
1239 | 1260 |
s->hw = opaque; |
1240 |
return s; |
|
1261 |
|
|
1262 |
register_displaystate(ds); |
|
1263 |
return ds; |
|
1241 | 1264 |
} |
1242 | 1265 |
|
1243 | 1266 |
int is_graphic_console(void) |
... | ... | |
1285 | 1308 |
s->out_fifo.buf = s->out_fifo_buf; |
1286 | 1309 |
s->out_fifo.buf_size = sizeof(s->out_fifo_buf); |
1287 | 1310 |
s->kbd_timer = qemu_new_timer(rt_clock, kbd_send_chars, s); |
1311 |
s->ds = ds; |
|
1288 | 1312 |
|
1289 | 1313 |
if (!color_inited) { |
1290 | 1314 |
color_inited = 1; |
... | ... | |
1337 | 1361 |
return chr; |
1338 | 1362 |
} |
1339 | 1363 |
|
1340 |
void qemu_console_resize(QEMUConsole *console, int width, int height)
|
|
1364 |
void qemu_console_resize(DisplayState *ds, int width, int height)
|
|
1341 | 1365 |
{ |
1342 |
console->g_width = width;
|
|
1343 |
console->g_height = height;
|
|
1344 |
if (active_console == console) {
|
|
1345 |
DisplayState *ds = console->ds;
|
|
1366 |
TextConsole *s = get_graphic_console();
|
|
1367 |
s->g_width = width;
|
|
1368 |
s->g_height = height;
|
|
1369 |
if (is_graphic_console()) {
|
|
1346 | 1370 |
ds->surface = qemu_resize_displaysurface(ds->surface, width, height, 32, 4 * width); |
1347 |
dpy_resize(console->ds);
|
|
1371 |
dpy_resize(ds); |
|
1348 | 1372 |
} |
1349 | 1373 |
} |
1350 | 1374 |
|
1351 |
void qemu_console_copy(QEMUConsole *console, int src_x, int src_y,
|
|
1352 |
int dst_x, int dst_y, int w, int h) |
|
1375 |
void qemu_console_copy(DisplayState *ds, int src_x, int src_y,
|
|
1376 |
int dst_x, int dst_y, int w, int h)
|
|
1353 | 1377 |
{ |
1354 |
if (active_console == console) {
|
|
1355 |
dpy_copy(console->ds, src_x, src_y, dst_x, dst_y, w, h);
|
|
1378 |
if (is_graphic_console()) {
|
|
1379 |
dpy_copy(ds, src_x, src_y, dst_x, dst_y, w, h);
|
|
1356 | 1380 |
} |
1357 | 1381 |
} |
1358 | 1382 |
|
Also available in: Unified diff