From 75cff26ebad33aca7ade7aa5a650235a7d42e47c Mon Sep 17 00:00:00 2001 From: Chris Wilson Date: Sat, 22 Feb 2014 10:05:41 +0000 Subject: [PATCH] sna: Apply the dst offset for pixman fills Along one of the sw blt paths we failed to apply the offset for Composite redirection. Reported-by: Jiri Slaby Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=73811 Signed-off-by: Chris Wilson --- src/sna/sna_blt.c | 75 +++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 63 insertions(+), 12 deletions(-) diff --git a/src/sna/sna_blt.c b/src/sna/sna_blt.c index c02f8c7d..4bbcdbcc 100644 --- a/src/sna/sna_blt.c +++ b/src/sna/sna_blt.c @@ -940,9 +940,9 @@ static void blt_composite_fill__cpu(struct sna *sna, } fastcall static void -blt_composite_fill_box__cpu(struct sna *sna, - const struct sna_composite_op *op, - const BoxRec *box) +blt_composite_fill_box_no_offset__cpu(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) { assert(box->x1 >= 0); assert(box->y1 >= 0); @@ -957,9 +957,9 @@ blt_composite_fill_box__cpu(struct sna *sna, } static void -blt_composite_fill_boxes__cpu(struct sna *sna, - const struct sna_composite_op *op, - const BoxRec *box, int n) +blt_composite_fill_boxes_no_offset__cpu(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box, int n) { do { assert(box->x1 >= 0); @@ -976,6 +976,45 @@ blt_composite_fill_boxes__cpu(struct sna *sna, } while (--n); } +fastcall static void +blt_composite_fill_box__cpu(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box) +{ + assert(box->x1 + op->dst.x >= 0); + assert(box->y1 + op->dst.y >= 0); + assert(box->x2 + op->dst.x <= op->dst.pixmap->drawable.width); + assert(box->y2 + op->dst.y <= op->dst.pixmap->drawable.height); + + pixman_fill(op->dst.pixmap->devPrivate.ptr, + op->dst.pixmap->devKind / sizeof(uint32_t), + op->dst.pixmap->drawable.bitsPerPixel, + box->x1 + op->dst.x, box->y1 + op->dst.y, + box->x2 - box->x1, box->y2 - box->y1, + op->u.blt.pixel); +} + +static void +blt_composite_fill_boxes__cpu(struct sna *sna, + const struct sna_composite_op *op, + const BoxRec *box, int n) +{ + do { + assert(box->x1 + op->dst.x >= 0); + assert(box->y1 + op->dst.y >= 0); + assert(box->x2 + op->dst.x <= op->dst.pixmap->drawable.width); + assert(box->y2 + op->dst.y <= op->dst.pixmap->drawable.height); + + pixman_fill(op->dst.pixmap->devPrivate.ptr, + op->dst.pixmap->devKind / sizeof(uint32_t), + op->dst.pixmap->drawable.bitsPerPixel, + box->x1 + op->dst.x, box->y1 + op->dst.y, + box->x2 - box->x1, box->y2 - box->y1, + op->u.blt.pixel); + box++; + } while (--n); +} + inline static void _sna_blt_fill_box(struct sna *sna, const struct sna_blt_state *blt, const BoxRec *box) @@ -1316,9 +1355,15 @@ prepare_blt_clear(struct sna *sna, if (op->dst.bo == NULL) { op->blt = blt_composite_fill__cpu; - op->box = blt_composite_fill_box__cpu; - op->boxes = blt_composite_fill_boxes__cpu; - op->thread_boxes = blt_composite_fill_boxes__cpu; + if (op->dst.x|op->dst.y) { + op->box = blt_composite_fill_box__cpu; + op->boxes = blt_composite_fill_boxes__cpu; + op->thread_boxes = blt_composite_fill_boxes__cpu; + } else { + op->box = blt_composite_fill_box_no_offset__cpu; + op->boxes = blt_composite_fill_boxes_no_offset__cpu; + op->thread_boxes = blt_composite_fill_boxes_no_offset__cpu; + } op->done = nop_done; op->u.blt.pixel = 0; return true; @@ -1355,9 +1400,15 @@ prepare_blt_fill(struct sna *sna, if (op->dst.bo == NULL) { op->u.blt.pixel = pixel; op->blt = blt_composite_fill__cpu; - op->box = blt_composite_fill_box__cpu; - op->boxes = blt_composite_fill_boxes__cpu; - op->thread_boxes = blt_composite_fill_boxes__cpu; + if (op->dst.x|op->dst.y) { + op->box = blt_composite_fill_box__cpu; + op->boxes = blt_composite_fill_boxes__cpu; + op->thread_boxes = blt_composite_fill_boxes__cpu; + } else { + op->box = blt_composite_fill_box_no_offset__cpu; + op->boxes = blt_composite_fill_boxes_no_offset__cpu; + op->thread_boxes = blt_composite_fill_boxes_no_offset__cpu; + } op->done = nop_done; return true; }