diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-23 14:42:48 +0100 |
---|---|---|
committer | Chris Wilson <chris@chris-wilson.co.uk> | 2009-10-23 14:58:33 +0100 |
commit | c701d7813b6d116c9db53f63f791928a407499c7 (patch) | |
tree | b68693b906dbb0d2b777fff30b690be5d7e42cf4 | |
parent | 43a775f60da57206b194039cd5d8b6a735284c45 (diff) |
[pattern] Compute zero extents for empty patterns
If the pattern is for example a repeating 0x0 image, then treat it as
having zero extents.
This should workaround the bug presented here:
https://bugs.freedesktop.org/show_bug.cgi?id=24693
Attached PDF crashes evince with a Floating point exception
-rw-r--r-- | src/cairo-pattern.c | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c index cf6dab24..a7441185 100644 --- a/src/cairo-pattern.c +++ b/src/cairo-pattern.c @@ -2446,9 +2446,6 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern, double x1, y1, x2, y2; cairo_status_t status; - if (pattern->extend != CAIRO_EXTEND_NONE) - goto UNBOUNDED; - switch (pattern->type) { case CAIRO_PATTERN_TYPE_SOLID: goto UNBOUNDED; @@ -2464,6 +2461,12 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern, if (! _cairo_surface_get_extents (surface, &surface_extents)) goto UNBOUNDED; + if (surface_extents.width == 0 || surface_extents.height == 0) + goto EMPTY; + + if (pattern->extend != CAIRO_EXTEND_NONE) + goto UNBOUNDED; + /* The filter can effectively enlarge the extents of the * pattern, so extend as necessary. */ @@ -2483,6 +2486,9 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern, double cx2, cy2; double r, D; + if (radial->r1 == 0 && radial->r2 == 0) + goto EMPTY; + cx1 = _cairo_fixed_to_double (radial->c1.x); cy1 = _cairo_fixed_to_double (radial->c1.y); r = _cairo_fixed_to_double (radial->r1); @@ -2493,6 +2499,9 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern, cy2 = _cairo_fixed_to_double (radial->c2.y); r = fabs (_cairo_fixed_to_double (radial->r2)); + if (pattern->extend != CAIRO_EXTEND_NONE) + goto UNBOUNDED; + /* We need to be careful, as if the circles are not * self-contained, then the solution is actually unbounded. */ @@ -2517,6 +2526,12 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern, const cairo_linear_pattern_t *linear = (const cairo_linear_pattern_t *) pattern; + if (linear->p1.x == linear->p2.x && linear->p1.y == linear->p2.y) + goto EMPTY; + + if (pattern->extend != CAIRO_EXTEND_NONE) + goto UNBOUNDED; + if (pattern->matrix.xy != 0. || pattern->matrix.yx != 0.) goto UNBOUNDED; @@ -2570,6 +2585,12 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern, UNBOUNDED: /* unbounded patterns -> 'infinite' extents */ _cairo_unbounded_rectangle_init (extents); + return; + + EMPTY: + extents->x = extents->y = 0; + extents->width = extents->height = 0; + return; } |