Skip to content

Commit

Permalink
tessellator bug fix: in-fill-empty-trapezoid
Browse files Browse the repository at this point in the history
The cairo_in_fill() function sometimes gives false positives
when it samples a point on the edge of an empty trapezoid.
This patch alleviates the bug (but doesn't fix it completely),
for the common(?) case where the left and right edges of the
empty trapezoid have equal top and bottom points.
  • Loading branch information
M Joonas Pihlaja committed Dec 6, 2006
1 parent e6c8feb commit 633c51b
Showing 1 changed file with 21 additions and 10 deletions.
31 changes: 21 additions & 10 deletions src/cairo-bentley-ottmann.c
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,7 @@ _cairo_bo_edge_end_trap (cairo_bo_edge_t *left,
fixed_top = trap->top >> CAIRO_BO_GUARD_BITS;
fixed_bot = bot >> CAIRO_BO_GUARD_BITS;

/* Only emit trapezoids with positive height. */
if (fixed_top < fixed_bot) {
cairo_point_t left_top, left_bot, right_top, right_bot;

Expand All @@ -1090,19 +1091,29 @@ _cairo_bo_edge_end_trap (cairo_bo_edge_t *left,
right_bot.x = right->bottom.x >> CAIRO_BO_GUARD_BITS;
right_bot.y = right->bottom.y >> CAIRO_BO_GUARD_BITS;

status = _cairo_traps_add_trap_from_points (bo_traps->traps,
fixed_top,
fixed_bot,
left_top, left_bot,
right_top, right_bot);
/* Avoid emitting the trapezoid if it is obviously degenerate.
* TODO: need a real collinearity test here for the cases
* where the trapezoid is degenerate, yet the top and bottom
* coordinates aren't equal. */
if (left_top.x != right_top.x ||
left_top.y != right_top.y ||
left_bot.x != right_bot.x ||
left_bot.y != right_bot.y)
{
status = _cairo_traps_add_trap_from_points (bo_traps->traps,
fixed_top,
fixed_bot,
left_top, left_bot,
right_top, right_bot);

#if DEBUG_PRINT_STATE
printf ("Deferred trap: left=(%08x, %08x)-(%08x,%08x) "
"right=(%08x,%08x)-(%08x,%08x) top=%08x, bot=%08x\n",
left->top.x, left->top.y, left->bottom.x, left->bottom.y,
right->top.x, right->top.y, right->bottom.x, right->bottom.y,
trap->top, bot);
printf ("Deferred trap: left=(%08x, %08x)-(%08x,%08x) "
"right=(%08x,%08x)-(%08x,%08x) top=%08x, bot=%08x\n",
left->top.x, left->top.y, left->bottom.x, left->bottom.y,
right->top.x, right->top.y, right->bottom.x, right->bottom.y,
trap->top, bot);
#endif
}
}

_cairo_freelist_free (&bo_traps->freelist, trap);
Expand Down

0 comments on commit 633c51b

Please sign in to comment.