diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-17 15:47:04 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2010-06-17 15:47:04 +0100 |
commit | 7ab9ce1b9130dcd63b2b2b2516b77ef1ae531144 (patch) | |
tree | 265f17fc6d6b866b2280e7c2dae6ca6c27df842a | |
parent | f2645fa361003636d1da6ca38c3b61fef1b1ce4d (diff) |
image: Make a local copy of the trap coordinates as the boxes alias.
As we transform the array of trapezoids into an array of boxes in-place,
we must take local copies of the coordinates before writing into the
boxes otherwise we may inadvertently modify the trapezoidal coordinates.
Fixes test/a1-bug.
-rw-r--r-- | src/cairo-image-surface.c | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c index c9f1f13f..a23ef48a 100644 --- a/src/cairo-image-surface.c +++ b/src/cairo-image-surface.c @@ -3066,6 +3066,7 @@ _boxes_for_traps (cairo_boxes_t *boxes, if (antialias != CAIRO_ANTIALIAS_NONE) { for (i = 0; i < traps->num_traps; i++) { + /* Note the traps and boxes alias so we need to take the local copies first. */ cairo_fixed_t x1 = traps->traps[i].left.p1.x; cairo_fixed_t x2 = traps->traps[i].right.p1.x; cairo_fixed_t y1 = traps->traps[i].top; @@ -3086,11 +3087,17 @@ _boxes_for_traps (cairo_boxes_t *boxes, boxes->is_pixel_aligned = TRUE; for (i = 0; i < traps->num_traps; i++) { + /* Note the traps and boxes alias so we need to take the local copies first. */ + cairo_fixed_t x1 = traps->traps[i].left.p1.x; + cairo_fixed_t x2 = traps->traps[i].right.p1.x; + cairo_fixed_t y1 = traps->traps[i].top; + cairo_fixed_t y2 = traps->traps[i].bottom; + /* round down here to match Pixman's behavior when using traps. */ - boxes->chunks.base[i].p1.x = _cairo_fixed_round_down (traps->traps[i].left.p1.x); - boxes->chunks.base[i].p1.y = _cairo_fixed_round_down (traps->traps[i].top); - boxes->chunks.base[i].p2.x = _cairo_fixed_round_down (traps->traps[i].right.p1.x); - boxes->chunks.base[i].p2.y = _cairo_fixed_round_down (traps->traps[i].bottom); + boxes->chunks.base[i].p1.x = _cairo_fixed_round_down (x1); + boxes->chunks.base[i].p1.y = _cairo_fixed_round_down (y1); + boxes->chunks.base[i].p2.x = _cairo_fixed_round_down (x2); + boxes->chunks.base[i].p2.y = _cairo_fixed_round_down (y2); } } } |