Commit 14778c2064166a8d1d07b22f0af9eee4fa490e60
1 parent
6e60065f
Coalesce virtual console screen updates.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6374 c046a42c-6fe2-441c-8c8c-71466251a162
Showing
1 changed file
with
33 additions
and
7 deletions
console.c
... | ... | @@ -139,6 +139,11 @@ struct TextConsole { |
139 | 139 | TextCell *cells; |
140 | 140 | int text_x[2], text_y[2], cursor_invalidate; |
141 | 141 | |
142 | + int update_x0; | |
143 | + int update_y0; | |
144 | + int update_x1; | |
145 | + int update_y1; | |
146 | + | |
142 | 147 | enum TTYState state; |
143 | 148 | int esc_params[MAX_ESC_PARAMS]; |
144 | 149 | int nb_esc_params; |
... | ... | @@ -537,6 +542,18 @@ static inline void text_update_xy(TextConsole *s, int x, int y) |
537 | 542 | s->text_y[1] = MAX(s->text_y[1], y); |
538 | 543 | } |
539 | 544 | |
545 | +static void invalidate_xy(TextConsole *s, int x, int y) | |
546 | +{ | |
547 | + if (s->update_x0 > x * FONT_WIDTH) | |
548 | + s->update_x0 = x * FONT_WIDTH; | |
549 | + if (s->update_y0 > y * FONT_HEIGHT) | |
550 | + s->update_y0 = y * FONT_HEIGHT; | |
551 | + if (s->update_x1 < (x + 1) * FONT_WIDTH) | |
552 | + s->update_x1 = (x + 1) * FONT_WIDTH; | |
553 | + if (s->update_y1 < (y + 1) * FONT_HEIGHT) | |
554 | + s->update_y1 = (y + 1) * FONT_HEIGHT; | |
555 | +} | |
556 | + | |
540 | 557 | static void update_xy(TextConsole *s, int x, int y) |
541 | 558 | { |
542 | 559 | TextCell *c; |
... | ... | @@ -556,8 +573,7 @@ static void update_xy(TextConsole *s, int x, int y) |
556 | 573 | c = &s->cells[y1 * s->width + x]; |
557 | 574 | vga_putcharxy(s->ds, x, y2, c->ch, |
558 | 575 | &(c->t_attrib)); |
559 | - dpy_update(s->ds, x * FONT_WIDTH, y2 * FONT_HEIGHT, | |
560 | - FONT_WIDTH, FONT_HEIGHT); | |
576 | + invalidate_xy(s, x, y2); | |
561 | 577 | } |
562 | 578 | } |
563 | 579 | } |
... | ... | @@ -591,8 +607,7 @@ static void console_show_cursor(TextConsole *s, int show) |
591 | 607 | } else { |
592 | 608 | vga_putcharxy(s->ds, x, y, c->ch, &(c->t_attrib)); |
593 | 609 | } |
594 | - dpy_update(s->ds, x * FONT_WIDTH, y * FONT_HEIGHT, | |
595 | - FONT_WIDTH, FONT_HEIGHT); | |
610 | + invalidate_xy(s, x, y); | |
596 | 611 | } |
597 | 612 | } |
598 | 613 | } |
... | ... | @@ -626,8 +641,8 @@ static void console_refresh(TextConsole *s) |
626 | 641 | if (++y1 == s->total_height) |
627 | 642 | y1 = 0; |
628 | 643 | } |
629 | - dpy_update(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds)); | |
630 | 644 | console_show_cursor(s, 1); |
645 | + dpy_update(s->ds, 0, 0, ds_get_width(s->ds), ds_get_height(s->ds)); | |
631 | 646 | } |
632 | 647 | |
633 | 648 | static void console_scroll(int ydelta) |
... | ... | @@ -703,8 +718,10 @@ static void console_put_lf(TextConsole *s) |
703 | 718 | vga_fill_rect(s->ds, 0, (s->height - 1) * FONT_HEIGHT, |
704 | 719 | s->width * FONT_WIDTH, FONT_HEIGHT, |
705 | 720 | color_table[0][s->t_attrib_default.bgcol]); |
706 | - dpy_update(s->ds, 0, 0, | |
707 | - s->width * FONT_WIDTH, s->height * FONT_HEIGHT); | |
721 | + s->update_x0 = 0; | |
722 | + s->update_y0 = 0; | |
723 | + s->update_x1 = s->width * FONT_WIDTH; | |
724 | + s->update_y1 = s->height * FONT_HEIGHT; | |
708 | 725 | } |
709 | 726 | } |
710 | 727 | } |
... | ... | @@ -1062,11 +1079,20 @@ static int console_puts(CharDriverState *chr, const uint8_t *buf, int len) |
1062 | 1079 | TextConsole *s = chr->opaque; |
1063 | 1080 | int i; |
1064 | 1081 | |
1082 | + s->update_x0 = s->width * FONT_WIDTH; | |
1083 | + s->update_y0 = s->height * FONT_HEIGHT; | |
1084 | + s->update_x1 = 0; | |
1085 | + s->update_y1 = 0; | |
1065 | 1086 | console_show_cursor(s, 0); |
1066 | 1087 | for(i = 0; i < len; i++) { |
1067 | 1088 | console_putchar(s, buf[i]); |
1068 | 1089 | } |
1069 | 1090 | console_show_cursor(s, 1); |
1091 | + if (ds_get_bits_per_pixel(s->ds) && s->update_x0 < s->update_x1) { | |
1092 | + dpy_update(s->ds, s->update_x0, s->update_y0, | |
1093 | + s->update_x1 - s->update_x0, | |
1094 | + s->update_y1 - s->update_y0); | |
1095 | + } | |
1070 | 1096 | return len; |
1071 | 1097 | } |
1072 | 1098 | ... | ... |