summaryrefslogtreecommitdiff
path: root/src/hist.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/hist.h')
-rw-r--r--src/hist.h39
1 files changed, 11 insertions, 28 deletions
diff --git a/src/hist.h b/src/hist.h
index 1aceae7..74ccb09 100644
--- a/src/hist.h
+++ b/src/hist.h
@@ -91,31 +91,14 @@ struct text_row {
#define TEXT_ROW_BYTES(cols) ((size_t)(cols) * 4 + 16)
#define TEXT_ROW_RUNS(cols) (((size_t)(cols) + 2) * 22)
-/* A pen as three words: fg, bg, and flags | link << 16 (the layout of
- * pen_attr.flags and .link). The hot path reads and writes whole words, so
- * a store is never read back through a wider load. */
-static inline uint32_t pen_sl(const struct pen_attr *p)
-{
- uint32_t sl;
- memcpy(&sl, &p->flags, 4);
- return sl;
-}
-
-static inline void pen_set(struct pen_attr *p, uint32_t fg, uint32_t bg, uint32_t sl)
-{
- p->fg = fg;
- p->bg = bg;
- memcpy(&p->flags, &sl, 4);
-}
-
/* Emit the pending run in the general form. */
void term_hist_runs_emit_slow(struct hist_runs *r);
-/* Close the pending run and start one with the pen fg, bg, sl. The caller
+/* Close the pending run and start one with the given pen. The caller
* sized the buffer. A run that changes only colors and covers fewer than
* 128 cells is a header byte (bit 0 fg, bit 1 bg), a count byte, and the
* changed colors. */
-static inline void hist_runs_switch(struct hist_runs *r, uint32_t fg, uint32_t bg, uint32_t sl)
+static inline void hist_runs_switch(struct hist_runs *r, struct text_pen pen)
{
if (r->count) {
uint32_t psl = pen_sl(&r->pen);
@@ -133,21 +116,21 @@ static inline void hist_runs_switch(struct hist_runs *r, uint32_t fg, uint32_t b
}
pen_set(&r->base, r->pen.fg, r->pen.bg, psl);
}
- pen_set(&r->pen, fg, bg, sl);
+ pen_set_text(&r->pen, pen);
r->count = 0;
}
-static inline void hist_runs_add_pen(struct hist_runs *r, uint32_t fg, uint32_t bg, uint32_t sl,
+static inline void hist_runs_add_pen(struct hist_runs *r, struct text_pen pen,
uint32_t n)
{
- if (fg != r->pen.fg || bg != r->pen.bg || sl != pen_sl(&r->pen))
- hist_runs_switch(r, fg, bg, sl);
+ if (pen.fg != r->pen.fg || pen.bg != r->pen.bg || pen.sl != pen_sl(&r->pen))
+ hist_runs_switch(r, pen);
r->count += n;
}
static inline void hist_runs_add(struct hist_runs *r, const struct pen_attr *pen, uint32_t n)
{
- hist_runs_add_pen(r, pen->fg, pen->bg, pen_sl(pen), n);
+ hist_runs_add_pen(r, text_pen_from_attr(pen), n);
}
/* Start a text row. Each field gets its own store of its own width, because
@@ -155,17 +138,17 @@ static inline void hist_runs_add(struct hist_runs *r, const struct pen_attr *pen
static inline void text_row_start(struct text_row *row, const struct pen_attr *start)
{
if (row->storage) row->text = row->storage;
- uint32_t fg = start->fg, bg = start->bg, sl = pen_sl(start);
+ struct text_pen pen = text_pen_from_attr(start);
row->text_len = 0;
row->cells = 0;
row->wide = 0;
row->fill_to = 0;
row->flags = HLINE_NARROW;
- pen_set(&row->start, fg, bg, sl);
+ pen_set_text(&row->start, pen);
row->runs.len = 0;
row->runs.count = 0;
- pen_set(&row->runs.base, fg, bg, sl);
- pen_set(&row->runs.pen, fg, bg, sl);
+ pen_set_text(&row->runs.base, pen);
+ pen_set_text(&row->runs.pen, pen);
}
static inline void text_row_unshare(struct text_row *row)