summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRich Felker <dalias@aerifal.cx>2006-10-15 19:30:09 +0000
committerRich Felker <dalias@aerifal.cx>2006-10-15 19:30:09 +0000
commita8d313686651110cc62f3383130a064c7a41fd51 (patch)
treec51747291668c71cfa32fa3b0ce7c94651f0919a
parent7674683e6968653ca588d820f72a3b29faad2e61 (diff)
downloaduuterm-a8d313686651110cc62f3383130a064c7a41fd51.tar.gz
large performance increase
-rw-r--r--dblbuf.c4
-rw-r--r--refresh.c1
-rw-r--r--xlib.c49
3 files changed, 35 insertions, 19 deletions
diff --git a/dblbuf.c b/dblbuf.c
index ee15148..6213ced 100644
--- a/dblbuf.c
+++ b/dblbuf.c
@@ -117,6 +117,10 @@ void uudisp_predraw_cell(struct uudisp *d, int idx, int x, int color)
b->slices[idx].colors[2*x+1] = expand_color(d, color>>4) ^ b->slices[idx].colors[2*x];
}
+void uudisp_finalize_cell(struct uudisp *d, int idx, int x)
+{
+}
+
void uudisp_draw_glyph(struct uudisp *d, int idx, int x, const void *glyph)
{
struct dblbuf *b = (void *)&d->priv;
diff --git a/refresh.c b/refresh.c
index 9e3ab57..789f7f9 100644
--- a/refresh.c
+++ b/refresh.c
@@ -59,6 +59,7 @@ void uuterm_refresh_row(struct uudisp *d, struct uurow *row, int x1, int x2)
const void *glyph = lookup_glyph(d->font, i, chp, ch[(x+3)&3], ch[(x+1)&3], width, part);
if (glyph) uudisp_draw_glyph(d, row->idx, x, glyph);
}
+ uudisp_finalize_cell(d, row->idx, x);
}
}
diff --git a/xlib.c b/xlib.c
index 60d86b1..9078b6e 100644
--- a/xlib.c
+++ b/xlib.c
@@ -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);
}