From 4a51cc0440c8d026fd8c82b40cfb188c6ea4a9f0 Mon Sep 17 00:00:00 2001 From: Eric Anholt Date: Mon, 24 Aug 2009 09:14:20 -0700 Subject: [PATCH] glamor: Add clipping to setspans. --- glamor/glamor_setspans.c | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/glamor/glamor_setspans.c b/glamor/glamor_setspans.c index 65471e916..66ec3dafd 100644 --- a/glamor/glamor_setspans.c +++ b/glamor/glamor_setspans.c @@ -40,6 +40,8 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src, uint8_t *temp_src = NULL, *drawpixels_src = (uint8_t *)src; int i, j; int wmax = 0; + RegionPtr clip = fbGetCompositeClip(gc); + BoxRec *pbox; for (i = 0 ; i < n; i++) { if (wmax < widths[i]) @@ -87,12 +89,23 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src, } } - glRasterPos2i(points[i].x - dest_pixmap->screen_x, - points[i].y - dest_pixmap->screen_y); - glDrawPixels(widths[i], - 1, - format, type, - drawpixels_src); + n = REGION_NUM_RECTS(clip); + pbox = REGION_RECTS(clip); + while (n--) { + if (pbox->y1 > points[i].y) + break; + glScissor(pbox->x1, + points[i].y - dest_pixmap->screen_y, + pbox->x2 - pbox->x1, + 1); + glEnable(GL_SCISSOR_TEST); + glRasterPos2i(points[i].x - dest_pixmap->screen_x, + points[i].y - dest_pixmap->screen_y); + glDrawPixels(widths[i], + 1, + format, type, + drawpixels_src); + } if (temp_src) { src += PixmapBytePad(widths[i], drawable->depth); } else { @@ -100,6 +113,7 @@ glamor_set_spans(DrawablePtr drawable, GCPtr gc, char *src, } } fail: + glDisable(GL_SCISSOR_TEST); glamor_set_planemask(dest_pixmap, ~0); glamor_set_alu(GXcopy); xfree(temp_src);