aboutsummaryrefslogtreecommitdiff
path: root/render.c
diff options
context:
space:
mode:
authorDaniel Eklöf <daniel@ekloef.se>2019-08-02 16:19:07 +0000
committerDaniel Eklöf <daniel@ekloef.se>2019-08-02 16:19:07 +0000
commit4d7993b36fa3f97e26c527c37b36eb9321b79791 (patch)
tree391b9125d821de5010b5f383813135882d54293d /render.c
parentterm: implement reset (diff)
cell: pack more efficiently and store glyph as a wchar
The 'attributes' struct is now 8 bytes and naturally packed (used to be 9 bytes, artificially packed). 'cell' struct is now 12 bytes, naturally packed (used to be 13 bytes, artificially packed). Furthermore, the glyph is stored as a wchar instead of a char*. This makes it easier (faster) to do glyph lookup when rendering.
Diffstat (limited to 'render.c')
-rw-r--r--render.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/render.c b/render.c
index 67a1703f..c0e959e3 100644
--- a/render.c
+++ b/render.c
@@ -154,11 +154,11 @@ render_cell(struct terminal *term, cairo_t *cr,
bool block_cursor = has_cursor && term->cursor_style == CURSOR_BLOCK;
bool is_selected = coord_is_selected(term, col, row);
- uint32_t _fg = cell->attrs.foreground >> 30
- ? cell->attrs.foreground
+ uint32_t _fg = cell->attrs.have_fg
+ ? cell->attrs.fg
: !term->reverse ? term->colors.fg : term->colors.bg;
- uint32_t _bg = cell->attrs.background >> 30
- ? cell->attrs.background
+ uint32_t _bg = cell->attrs.have_bg
+ ? cell->attrs.bg
: !term->reverse ? term->colors.bg : term->colors.fg;
/* If *one* is set, we reverse */
@@ -185,7 +185,7 @@ render_cell(struct terminal *term, cairo_t *cr,
}
struct font *font = attrs_to_font(term, &cell->attrs);
- const struct glyph *glyph = font_glyph_for_utf8(font, cell->c);
+ const struct glyph *glyph = font_glyph_for_wc(font, cell->wc);
int cell_cols = glyph != NULL ? max(1, glyph->width) : 1;
@@ -210,7 +210,7 @@ render_cell(struct terminal *term, cairo_t *cr,
arm_blink_timer(term);
}
- if (cell->c[0] == '\0' || cell->attrs.conceal)
+ if (cell->wc == 0 || cell->attrs.conceal)
return cell_cols;
if (glyph != NULL) {