Fix cairo_traps_t status handling

Add a _cairo_traps_status function and use it instead of adding
error checks to callers of _cairo_traps_add_trap and
_cairo_traps_add_trap_from_points, (both of which are now given
a void return type).
This commit is contained in:
Carl Worth 2007-04-10 12:06:09 -07:00
parent 67bc608603
commit 57188b4dcb
3 changed files with 25 additions and 18 deletions

View file

@ -1065,7 +1065,6 @@ _cairo_bo_edge_end_trap (cairo_bo_edge_t *left,
cairo_bo_traps_t *bo_traps)
{
cairo_fixed_t fixed_top, fixed_bot;
cairo_status_t status = CAIRO_STATUS_SUCCESS;
cairo_bo_trap_t *trap = left->deferred_trap;
cairo_bo_edge_t *right;
@ -1107,11 +1106,11 @@ _cairo_bo_edge_end_trap (cairo_bo_edge_t *left,
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);
_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) "
@ -1125,7 +1124,8 @@ _cairo_bo_edge_end_trap (cairo_bo_edge_t *left,
_cairo_freelist_free (&bo_traps->freelist, trap);
left->deferred_trap = NULL;
return status;
return _cairo_traps_status (bo_traps->traps);
}
/* Start a new trapezoid at the given top y coordinate, whose edges

View file

@ -43,7 +43,7 @@
static cairo_status_t
_cairo_traps_grow (cairo_traps_t *traps);
static cairo_status_t
static void
_cairo_traps_add_trap (cairo_traps_t *traps, cairo_fixed_t top, cairo_fixed_t bottom,
cairo_line_t *left, cairo_line_t *right);
@ -109,23 +109,29 @@ _cairo_traps_init_box (cairo_traps_t *traps,
return traps->status;
}
static cairo_status_t
cairo_status_t
_cairo_traps_status (cairo_traps_t *traps)
{
return traps->status;
}
static void
_cairo_traps_add_trap (cairo_traps_t *traps, cairo_fixed_t top, cairo_fixed_t bottom,
cairo_line_t *left, cairo_line_t *right)
{
cairo_trapezoid_t *trap;
if (traps->status)
return traps->status;
return;
if (top == bottom) {
return CAIRO_STATUS_SUCCESS;
return;
}
if (traps->num_traps >= traps->traps_size) {
traps->status = _cairo_traps_grow (traps);
if (traps->status)
return traps->status;
return;
}
trap = &traps->traps[traps->num_traps];
@ -157,11 +163,9 @@ _cairo_traps_add_trap (cairo_traps_t *traps, cairo_fixed_t top, cairo_fixed_t bo
traps->extents.p2.x = right->p2.x;
traps->num_traps++;
return traps->status;
}
cairo_status_t
void
_cairo_traps_add_trap_from_points (cairo_traps_t *traps, cairo_fixed_t top, cairo_fixed_t bottom,
cairo_point_t left_p1, cairo_point_t left_p2,
cairo_point_t right_p1, cairo_point_t right_p2)
@ -170,7 +174,7 @@ _cairo_traps_add_trap_from_points (cairo_traps_t *traps, cairo_fixed_t top, cair
cairo_line_t right;
if (traps->status)
return traps->status;
return;
left.p1 = left_p1;
left.p2 = left_p2;
@ -178,7 +182,7 @@ _cairo_traps_add_trap_from_points (cairo_traps_t *traps, cairo_fixed_t top, cair
right.p1 = right_p1;
right.p2 = right_p2;
return _cairo_traps_add_trap (traps, top, bottom, &left, &right);
_cairo_traps_add_trap (traps, top, bottom, &left, &right);
}
/* make room for at least one more trap */

View file

@ -2297,6 +2297,9 @@ _cairo_traps_init_box (cairo_traps_t *traps,
cairo_private void
_cairo_traps_fini (cairo_traps_t *traps);
cairo_private cairo_status_t
_cairo_traps_status (cairo_traps_t *traps);
cairo_private void
_cairo_traps_translate (cairo_traps_t *traps, int x, int y);
@ -2311,7 +2314,7 @@ _cairo_traps_tessellate_polygon (cairo_traps_t *traps,
cairo_polygon_t *poly,
cairo_fill_rule_t fill_rule);
cairo_private cairo_status_t
cairo_private void
_cairo_traps_add_trap_from_points (cairo_traps_t *traps, cairo_fixed_t top, cairo_fixed_t bottom,
cairo_point_t left_p1, cairo_point_t left_p2,
cairo_point_t right_p1, cairo_point_t right_p2);