diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-06 14:45:27 +0000 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2011-12-06 14:49:27 +0000 |
commit | 291efa76de7572720e82b25cc105bb94fd351cd4 (patch) | |
tree | 2ec06a9fbe2fcec4d2629b4fcd4e75d60cb3ce2f | |
parent | 19dd6e7e530275aa1ee37dea922c8396b1077758 (diff) |
polygon: Tweak the y-coordinates of the edge so that it is inside the clip
As we evaluate the line first using y-for-x to find the clipped
vertical range and then rasterise the line using x-for-y, we can incur
severe rounding errors that cause us to draw beyond the clipped region.
The first simple attempt at a fix is to tweak the clipped vertical range
such that the evaluated extents of the line are contained.
Reported-by: Taekyun Kim <tkq.kim@samsung.com>
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r-- | src/cairo-polygon.c | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/src/cairo-polygon.c b/src/cairo-polygon.c index 82fbb884..c714b32a 100644 --- a/src/cairo-polygon.c +++ b/src/cairo-polygon.c @@ -423,6 +423,9 @@ _add_clipped_edge (cairo_polygon_t *polygon, top_left_to_bottom_right = (p1->x < p2->x) == (p1->y < p2->y); if (top_left_to_bottom_right) { + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x) + left_y++; + left_y = MIN (left_y, bot_y); if (top_y < left_y) { _add_edge (polygon, &limits->p1, &bot_left, @@ -431,6 +434,9 @@ _add_clipped_edge (cairo_polygon_t *polygon, top_y = left_y; } + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p1.y) + right_y--; + right_y = MAX (right_y, top_y); if (bot_y > right_y) { _add_edge (polygon, &top_right, &limits->p2, @@ -439,6 +445,9 @@ _add_clipped_edge (cairo_polygon_t *polygon, bot_y = right_y; } } else { + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, right_y) > limits->p2.x) + right_y++; + right_y = MIN (right_y, bot_y); if (top_y < right_y) { _add_edge (polygon, &top_right, &limits->p2, @@ -447,6 +456,9 @@ _add_clipped_edge (cairo_polygon_t *polygon, top_y = right_y; } + if (_cairo_edge_compute_intersection_x_for_y (p1, p2, left_y) < limits->p1.x) + left_y--; + left_y = MAX (left_y, top_y); if (bot_y > left_y) { _add_edge (polygon, &limits->p1, &bot_left, |