diff --git a/src/cairo-spans-compositor.c b/src/cairo-spans-compositor.c index efbae25..2e9915c 100644 --- a/src/cairo-spans-compositor.c +++ b/src/cairo-spans-compositor.c @@ -88,12 +88,12 @@ get_clip_surface (const cairo_spans_compositor_t *compositor, cairo_surface_t *surface; cairo_box_t box; cairo_polygon_t polygon; - const cairo_clip_path_t *clip_path; + const cairo_clip_path_t *clip_path = NULL; cairo_antialias_t antialias; cairo_fill_rule_t fill_rule; cairo_int_status_t status; - assert (clip->path); + assert (clip && (clip->path || clip->num_boxes)); surface = _cairo_surface_create_scratch (dst, CAIRO_CONTENT_ALPHA, @@ -104,17 +104,19 @@ get_clip_surface (const cairo_spans_compositor_t *compositor, _cairo_box_from_rectangle (&box, extents); _cairo_polygon_init (&polygon, &box, 1); - clip_path = clip->path; - status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, - clip_path->tolerance, - &polygon); - if (unlikely (status)) - goto cleanup_polygon; + if (clip->path) { + clip_path = clip->path; + status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, + clip_path->tolerance, + &polygon); + if (unlikely (status)) + goto cleanup_polygon; - polygon.num_limits = 0; + polygon.num_limits = 0; - antialias = clip_path->antialias; - fill_rule = clip_path->fill_rule; + antialias = clip_path->antialias; + fill_rule = clip_path->fill_rule; + } if (clip->boxes) { cairo_polygon_t intersect; @@ -138,26 +140,28 @@ get_clip_surface (const cairo_spans_compositor_t *compositor, polygon.limits = NULL; polygon.num_limits = 0; - clip_path = clip_path->prev; - while (clip_path) { - if (clip_path->antialias == antialias) { - cairo_polygon_t next; - - _cairo_polygon_init (&next, NULL, 0); - status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, - clip_path->tolerance, - &next); - if (likely (status == CAIRO_INT_STATUS_SUCCESS)) - status = _cairo_polygon_intersect (&polygon, fill_rule, - &next, clip_path->fill_rule); - _cairo_polygon_fini (&next); - if (unlikely (status)) - goto cleanup_polygon; + if (clip_path) { + clip_path = clip_path->prev; + while (clip_path) { + if (clip_path->antialias == antialias) { + cairo_polygon_t next; - fill_rule = CAIRO_FILL_RULE_WINDING; - } + _cairo_polygon_init (&next, NULL, 0); + status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, + clip_path->tolerance, + &next); + if (likely (status == CAIRO_INT_STATUS_SUCCESS)) + status = _cairo_polygon_intersect (&polygon, fill_rule, + &next, clip_path->fill_rule); + _cairo_polygon_fini (&next); + if (unlikely (status)) + goto cleanup_polygon; - clip_path = clip_path->prev; + fill_rule = CAIRO_FILL_RULE_WINDING; + } + + clip_path = clip_path->prev; + } } _cairo_polygon_translate (&polygon, -extents->x, -extents->y); @@ -178,37 +182,39 @@ get_clip_surface (const cairo_spans_compositor_t *compositor, _cairo_polygon_init (&polygon, &box, 1); - clip_path = clip->path; - antialias = clip_path->antialias == CAIRO_ANTIALIAS_DEFAULT ? CAIRO_ANTIALIAS_NONE : CAIRO_ANTIALIAS_DEFAULT; - clip_path = clip_path->prev; - while (clip_path) { - if (clip_path->antialias == antialias) { - if (polygon.num_edges == 0) { - status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, - clip_path->tolerance, - &polygon); - - fill_rule = clip_path->fill_rule; - polygon.limits = NULL; - polygon.num_limits = 0; - } else { - cairo_polygon_t next; - - _cairo_polygon_init (&next, NULL, 0); - status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, - clip_path->tolerance, - &next); - if (likely (status == CAIRO_INT_STATUS_SUCCESS)) - status = _cairo_polygon_intersect (&polygon, fill_rule, - &next, clip_path->fill_rule); - _cairo_polygon_fini (&next); - fill_rule = CAIRO_FILL_RULE_WINDING; + if (clip->path) { + clip_path = clip->path; + antialias = clip_path->antialias == CAIRO_ANTIALIAS_DEFAULT ? CAIRO_ANTIALIAS_NONE : CAIRO_ANTIALIAS_DEFAULT; + clip_path = clip_path->prev; + while (clip_path) { + if (clip_path->antialias == antialias) { + if (polygon.num_edges == 0) { + status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, + clip_path->tolerance, + &polygon); + + fill_rule = clip_path->fill_rule; + polygon.limits = NULL; + polygon.num_limits = 0; + } else { + cairo_polygon_t next; + + _cairo_polygon_init (&next, NULL, 0); + status = _cairo_path_fixed_fill_to_polygon (&clip_path->path, + clip_path->tolerance, + &next); + if (likely (status == CAIRO_INT_STATUS_SUCCESS)) + status = _cairo_polygon_intersect (&polygon, fill_rule, + &next, clip_path->fill_rule); + _cairo_polygon_fini (&next); + fill_rule = CAIRO_FILL_RULE_WINDING; + } + if (unlikely (status)) + goto error; } - if (unlikely (status)) - goto error; - } - clip_path = clip_path->prev; + clip_path = clip_path->prev; + } } if (polygon.num_edges) {