diff options
author | Rich Felker <dalias@aerifal.cx> | 2006-10-15 19:30:09 +0000 |
---|---|---|
committer | Rich Felker <dalias@aerifal.cx> | 2006-10-15 19:30:09 +0000 |
commit | a8d313686651110cc62f3383130a064c7a41fd51 (patch) | |
tree | c51747291668c71cfa32fa3b0ce7c94651f0919a /xlib.c | |
parent | 7674683e6968653ca588d820f72a3b29faad2e61 (diff) |
large performance increase
Diffstat (limited to 'xlib.c')
-rw-r--r-- | xlib.c | 49 |
1 files changed, 30 insertions, 19 deletions
@@ -23,8 +23,9 @@ struct priv Window window; XIM im; XIC ic; - GC wingc, cugc, bggc, fggc, maskgc; + GC wingc, cugc, fg, bg, mask_fg, mask_bg; Pixmap pixmap; + Pixmap mask; Pixmap *glyph_cache; int *slices_y; int curs_x, curs_y; @@ -125,19 +126,21 @@ int uudisp_open(struct uudisp *d) resize_window(d, px_w, px_h); + p->mask = XCreatePixmap(p->display, DefaultRootWindow(p->display), + d->cell_w, d->cell_h, 1); + p->wingc = XCreateGC(p->display, p->window, 0, &values); p->cugc = XCreateGC(p->display, p->window, 0, &values); - p->fggc = XCreateGC(p->display, p->pixmap, 0, &values); - p->bggc = XCreateGC(p->display, p->pixmap, 0, &values); - p->maskgc = XCreateGC(p->display, p->pixmap, 0, &values); + p->fg = XCreateGC(p->display, p->pixmap, 0, &values); + p->bg = XCreateGC(p->display, p->pixmap, 0, &values); + p->mask_fg = XCreateGC(p->display, p->mask, 0, &values); + p->mask_bg = XCreateGC(p->display, p->mask, 0, &values); + XSetClipMask(p->display, p->fg, p->mask); XSetFunction(p->display, p->cugc, GXxor); - XSetFunction(p->display, p->fggc, GXor); - XSetFunction(p->display, p->bggc, GXcopy); - XSetFunction(p->display, p->maskgc, GXandInverted); + XSetFunction(p->display, p->mask_fg, GXor); XSetForeground(p->display, p->cugc, WhitePixel(p->display, p->screen)); - XSetBackground(p->display, p->fggc, BlackPixel(p->display, p->screen)); - XSetForeground(p->display, p->maskgc, WhitePixel(p->display, p->screen)); - XSetBackground(p->display, p->maskgc, BlackPixel(p->display, p->screen)); + XSetForeground(p->display, p->mask_fg, WhitePixel(p->display, p->screen)); + XSetForeground(p->display, p->mask_bg, BlackPixel(p->display, p->screen)); npages = (nglyphs+1023) / 1024; // allows up to 64 pixel cell height.. p->glyph_cache = calloc(sizeof(p->glyph_cache[0]), npages); @@ -348,20 +351,28 @@ void uudisp_draw_glyph(struct uudisp *d, int idx, int x, const void *glyph) int gp = g >> 10; g &= 1023; - XCopyPlane(p->display, p->glyph_cache[gp], p->pixmap, p->maskgc, - 0, g*d->cell_h, d->cell_w, d->cell_h, - x * d->cell_w, idx * d->cell_h, 1); - XCopyPlane(p->display, p->glyph_cache[gp], p->pixmap, p->fggc, - 0, g*d->cell_h, d->cell_w, d->cell_h, - x * d->cell_w, idx * d->cell_h, 1); + XCopyArea(p->display, p->glyph_cache[gp], p->mask, p->mask_fg, + 0, g*d->cell_h, d->cell_w, d->cell_h, 0, 0); } void uudisp_predraw_cell(struct uudisp *d, int idx, int x, int color) { struct priv *p = (void *)&d->priv; - XSetForeground(p->display, p->fggc, p->colors[color&15]); - XSetForeground(p->display, p->bggc, p->colors[color>>4]); - XFillRectangle(p->display, p->pixmap, p->bggc, + + XSetClipOrigin(p->display, p->fg, x*d->cell_w, idx*d->cell_h); + XSetForeground(p->display, p->fg, p->colors[color&15]); + XSetForeground(p->display, p->bg, p->colors[color>>4]); + XFillRectangle(p->display, p->pixmap, p->bg, + x*d->cell_w, idx*d->cell_h, d->cell_w, d->cell_h); + XFillRectangle(p->display, p->mask, p->mask_bg, + 0, 0, d->cell_w, d->cell_h); +} + +void uudisp_finalize_cell(struct uudisp *d, int idx, int x) +{ + struct priv *p = (void *)&d->priv; + XSetClipMask(p->display, p->fg, p->mask); + XFillRectangle(p->display, p->pixmap, p->fg, x*d->cell_w, idx*d->cell_h, d->cell_w, d->cell_h); } |