From 65d1709c918dc981e389d63059954dc5664c8d33 Mon Sep 17 00:00:00 2001 From: Rich Felker Date: Thu, 12 Oct 2006 07:54:39 +0000 Subject: factoring --- dblbuf.c | 12 +++++++++--- refresh.c | 3 ++- uuterm.h | 3 ++- 3 files changed, 13 insertions(+), 5 deletions(-) diff --git a/dblbuf.c b/dblbuf.c index c202e96..570731d 100644 --- a/dblbuf.c +++ b/dblbuf.c @@ -106,7 +106,15 @@ static unsigned long expand_color(struct uudisp *d, int color) return color * (unsigned long)0x0101010101010101; } -void uudisp_draw_glyph(struct uudisp *d, int idx, int x, const void *glyph, int color) +void uudisp_predraw_cell(struct uudisp *d, int idx, int x, int color) +{ + struct dblbuf *b = (void *)&d->priv; + + b->slices[idx].colors[2*x] = expand_color(d, color&15); + b->slices[idx].colors[2*x+1] = expand_color(d, color>>4) ^ b->slices[idx].colors[2*x]; +} + +void uudisp_draw_glyph(struct uudisp *d, int idx, int x, const void *glyph) { struct dblbuf *b = (void *)&d->priv; int i; @@ -115,8 +123,6 @@ void uudisp_draw_glyph(struct uudisp *d, int idx, int x, const void *glyph, int unsigned char *src = (void *)glyph; unsigned char *dest = b->slices[idx].bitmap + cs * x; - b->slices[idx].colors[2*x] = expand_color(d, color&15); - b->slices[idx].colors[2*x+1] = expand_color(d, color>>4) ^ b->slices[idx].colors[2*x]; for (i=d->cell_h; i; i--, dest += stride) *dest |= *src++; } diff --git a/refresh.c b/refresh.c index 7410866..9b5aef6 100644 --- a/refresh.c +++ b/refresh.c @@ -52,9 +52,10 @@ void uuterm_refresh_row(struct uudisp *d, struct uurow *row, int x1, int x2) } else { width = 1; part = 0; chp = ch[x&3]; } + uudisp_predraw_cell(d, row->idx, x, row->cells[x].a & 0xff); for (i=0; ifont, i, chp, ch[(x+3)&3], ch[(x+1)&3], width, part); - if (glyph) uudisp_draw_glyph(d, row->idx, x, glyph, row->cells[x].a & 0xff); + if (glyph) uudisp_draw_glyph(d, row->idx, x, glyph); } } } diff --git a/uuterm.h b/uuterm.h index 6bda258..3ce390e 100644 --- a/uuterm.h +++ b/uuterm.h @@ -92,7 +92,8 @@ int uudisp_fd_set(struct uudisp *, int, void *); void uudisp_next_event(struct uudisp *, void *); void uudisp_close(struct uudisp *); void uudisp_refresh(struct uudisp *, struct uuterm *); -void uudisp_draw_glyph(struct uudisp *, int, int, const void *, int); +void uudisp_predraw_cell(struct uudisp *, int, int, int); +void uudisp_draw_glyph(struct uudisp *, int, int, const void *); void *uuterm_alloc(size_t); void uuterm_free(void *); -- cgit v1.2.3