aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJesse Luehrs <doy@tozt.net>2017-02-11 08:15:51 -0500
committerJesse Luehrs <doy@tozt.net>2017-02-11 08:51:09 -0500
commit6fe0eaf08492e5c99d6b1a457b41db6667c933c5 (patch)
treecc2cbb75869b19af66d65881ce96a35a3e1874b5
parent981d3ec01c7774609193ec2e3106b7856f7f7933 (diff)
downloadrunes-6fe0eaf08492e5c99d6b1a457b41db6667c933c5.tar.gz
runes-6fe0eaf08492e5c99d6b1a457b41db6667c933c5.zip
optimize drawing of runs of empty cells
-rw-r--r--src/display.c107
1 files changed, 64 insertions, 43 deletions
diff --git a/src/display.c b/src/display.c
index 7cee2a9..f3b14de 100644
--- a/src/display.c
+++ b/src/display.c
@@ -94,6 +94,16 @@ void runes_display_draw_screen(RunesTerm *t)
(struct vt100_cell **)cells->pdata, cells->len);
g_ptr_array_set_size(cells, 0);
start = c;
+ while (c < cols && cell->len == 0) {
+ cell = &t->scr->grid->rows[vr].cells[++c];
+ }
+ if (c > start) {
+ runes_display_draw_string(
+ t, r, start, c - start,
+ (struct vt100_cell **)cells->pdata, cells->len);
+ start = c;
+ }
+ prev_cell = NULL;
}
g_ptr_array_add(cells, cell);
@@ -280,8 +290,6 @@ static void runes_display_draw_string(
return;
}
- attrs = &cells[0]->attrs;
-
if (len > 1
&& display->has_selection
&& (display->selection_start.row != display->selection_end.row
@@ -304,50 +312,63 @@ static void runes_display_draw_string(
selected = runes_display_loc_is_selected(t, loc);
- switch (attrs->bgcolor.type) {
- case VT100_COLOR_DEFAULT:
- bg = t->config->bgdefault;
- break;
- case VT100_COLOR_IDX:
- bg = t->config->colors[attrs->bgcolor.idx];
- break;
- case VT100_COLOR_RGB:
- bg = cairo_pattern_create_rgb(
- attrs->bgcolor.r / 255.0,
- attrs->bgcolor.g / 255.0,
- attrs->bgcolor.b / 255.0);
- bg_is_custom = 1;
- break;
- }
-
- switch (attrs->fgcolor.type) {
- case VT100_COLOR_DEFAULT:
- fg = t->config->fgdefault;
- break;
- case VT100_COLOR_IDX: {
- unsigned char idx = attrs->fgcolor.idx;
+ if (len) {
+ attrs = &cells[0]->attrs;
+
+ switch (attrs->bgcolor.type) {
+ case VT100_COLOR_DEFAULT:
+ bg = t->config->bgdefault;
+ break;
+ case VT100_COLOR_IDX:
+ bg = t->config->colors[attrs->bgcolor.idx];
+ break;
+ case VT100_COLOR_RGB:
+ bg = cairo_pattern_create_rgb(
+ attrs->bgcolor.r / 255.0,
+ attrs->bgcolor.g / 255.0,
+ attrs->bgcolor.b / 255.0);
+ bg_is_custom = 1;
+ break;
+ }
+
+ switch (attrs->fgcolor.type) {
+ case VT100_COLOR_DEFAULT:
+ fg = t->config->fgdefault;
+ break;
+ case VT100_COLOR_IDX: {
+ unsigned char idx = attrs->fgcolor.idx;
- if (t->config->bold_is_bright && attrs->bold && idx < 8) {
- idx += 8;
+ if (t->config->bold_is_bright && attrs->bold && idx < 8) {
+ idx += 8;
+ }
+ fg = t->config->colors[idx];
+ break;
}
- fg = t->config->colors[idx];
- break;
- }
- case VT100_COLOR_RGB:
- fg = cairo_pattern_create_rgb(
- attrs->fgcolor.r / 255.0,
- attrs->fgcolor.g / 255.0,
- attrs->fgcolor.b / 255.0);
- fg_is_custom = 1;
- break;
- }
-
- if (attrs->inverse ^ selected) {
- if (attrs->fgcolor.id == attrs->bgcolor.id) {
- fg = t->config->bgdefault;
- bg = t->config->fgdefault;
+ case VT100_COLOR_RGB:
+ fg = cairo_pattern_create_rgb(
+ attrs->fgcolor.r / 255.0,
+ attrs->fgcolor.g / 255.0,
+ attrs->fgcolor.b / 255.0);
+ fg_is_custom = 1;
+ break;
}
- else {
+
+ if (attrs->inverse ^ selected) {
+ if (attrs->fgcolor.id == attrs->bgcolor.id) {
+ fg = t->config->bgdefault;
+ bg = t->config->fgdefault;
+ }
+ else {
+ cairo_pattern_t *tmp = fg;
+ fg = bg;
+ bg = tmp;
+ }
+ }
+ }
+ else {
+ bg = t->config->bgdefault;
+ fg = t->config->fgdefault;
+ if (selected) {
cairo_pattern_t *tmp = fg;
fg = bg;
bg = tmp;