cairo_status_t _cairo_polygon_intersect_with_boxes (cairo_polygon_t *polygon, cairo_fill_rule_t *winding, cairo_box_t *boxes, int num_boxes) { cairo_polygon_t b; cairo_status_t status; int n; if (num_boxes == 0) { polygon->num_edges = 0; return CAIRO_STATUS_SUCCESS; } for (n = 0; n < num_boxes; n++) { if (polygon->extents.p1.x >= boxes[n].p1.x && polygon->extents.p2.x <= boxes[n].p2.x && polygon->extents.p1.y >= boxes[n].p1.y && polygon->extents.p2.y <= boxes[n].p2.y) { return CAIRO_STATUS_SUCCESS; } } _cairo_polygon_init (&b, NULL, 0); for (n = 0; n < num_boxes; n++) { if (boxes[n].p2.x > polygon->extents.p1.x && boxes[n].p1.x < polygon->extents.p2.x && boxes[n].p2.y > polygon->extents.p1.y && boxes[n].p1.y < polygon->extents.p2.y) { cairo_point_t p1, p2; p1.y = boxes[n].p1.y; p2.y = boxes[n].p2.y; p2.x = p1.x = boxes[n].p1.x; _cairo_polygon_add_external_edge (&b, &p1, &p2); p2.x = p1.x = boxes[n].p2.x; _cairo_polygon_add_external_edge (&b, &p2, &p1); } } status = _cairo_polygon_intersect (polygon, *winding, &b, CAIRO_FILL_RULE_WINDING); _cairo_polygon_fini (&b); *winding = CAIRO_FILL_RULE_WINDING; return status; }
static cairo_status_t _cairo_filler_line_to (void *closure, const cairo_point_t *point, const cairo_slope_t *tangent) { cairo_filler_t *filler = closure; cairo_status_t status; status = _cairo_polygon_add_external_edge (filler->polygon, &filler->current_point, point); filler->current_point = *point; return status; }
static cairo_status_t _cairo_filler_ra_line_to (void *closure, const cairo_point_t *point) { cairo_filler_ra_t *filler = closure; cairo_status_t status; cairo_point_t p; p.x = _cairo_fixed_round_down (point->x); p.y = _cairo_fixed_round_down (point->y); status = _cairo_polygon_add_external_edge (filler->polygon, &filler->current_point, &p); filler->current_point = p; return status; }