pattern: don't round extents to 0 on vector surfaces

In this bug a Type 3 font contains a dash glyph. The dash glyph
consists of an 82x2 image. The image height, when scaled to user space,
is < 1 resuling in the drawing operation for the image being culled.

https://bugs.freedesktop.org/show_bug.cgi?id=94615
This commit is contained in:
Adrian Johnson 2016-07-16 14:59:43 +09:30
parent 1a380ef5f3
commit 190678f644
4 changed files with 19 additions and 9 deletions

View file

@ -372,7 +372,7 @@ _cairo_analysis_surface_operation_extents (cairo_analysis_surface_t *surface,
if (_cairo_operator_bounded_by_source (op)) {
cairo_rectangle_int_t source_extents;
_cairo_pattern_get_extents (source, &source_extents);
_cairo_pattern_get_extents (source, &source_extents, surface->target->is_vector);
_cairo_rectangle_intersect (extents, &source_extents);
}
@ -474,7 +474,7 @@ _cairo_analysis_surface_mask (void *abstract_surface,
if (_cairo_operator_bounded_by_mask (op)) {
cairo_rectangle_int_t mask_extents;
_cairo_pattern_get_extents (mask, &mask_extents);
_cairo_pattern_get_extents (mask, &mask_extents, surface->target->is_vector);
_cairo_rectangle_intersect (&extents, &mask_extents);
}

View file

@ -97,7 +97,8 @@ _cairo_composite_rectangles_init (cairo_composite_rectangles_t *extents,
_cairo_composite_reduce_pattern (source, &extents->source_pattern);
_cairo_pattern_get_extents (&extents->source_pattern.base,
&extents->source);
&extents->source,
surface->is_vector);
if (extents->is_bounded & CAIRO_OPERATOR_BOUND_BY_SOURCE) {
if (! _cairo_rectangle_intersect (&extents->bounded, &extents->source))
return FALSE;
@ -316,7 +317,7 @@ _cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t
cairo_int_status_t
_cairo_composite_rectangles_init_for_mask (cairo_composite_rectangles_t *extents,
cairo_surface_t*surface,
cairo_surface_t *surface,
cairo_operator_t op,
const cairo_pattern_t *source,
const cairo_pattern_t *mask,
@ -330,7 +331,7 @@ _cairo_composite_rectangles_init_for_mask (cairo_composite_rectangles_t *extents
extents->original_mask_pattern = mask;
_cairo_composite_reduce_pattern (mask, &extents->mask_pattern);
_cairo_pattern_get_extents (&extents->mask_pattern.base, &extents->mask);
_cairo_pattern_get_extents (&extents->mask_pattern.base, &extents->mask, surface->is_vector);
return _cairo_composite_rectangles_intersect (extents, clip);
}

View file

@ -296,7 +296,8 @@ _cairo_pattern_sampled_area (const cairo_pattern_t *pattern,
cairo_private void
_cairo_pattern_get_extents (const cairo_pattern_t *pattern,
cairo_rectangle_int_t *extents);
cairo_rectangle_int_t *extents,
cairo_bool_t is_vector);
cairo_private cairo_int_status_t
_cairo_pattern_get_ink_extents (const cairo_pattern_t *pattern,

View file

@ -3524,13 +3524,17 @@ _cairo_pattern_sampled_area (const cairo_pattern_t *pattern,
* For unbounded patterns, the @extents will be initialized with
* "infinite" extents, (minimum and maximum fixed-point values).
*
* When is_vector is TRUE, avoid rounding to zero widths or heights that
* are less than 1 unit.
*
* XXX: Currently, bounded gradient patterns will also return
* "infinite" extents, though it would be possible to optimize these
* with a little more work.
**/
void
_cairo_pattern_get_extents (const cairo_pattern_t *pattern,
cairo_rectangle_int_t *extents)
cairo_rectangle_int_t *extents,
cairo_bool_t is_vector)
{
double x1, y1, x2, y2;
int ix1, ix2, iy1, iy2;
@ -3733,6 +3737,8 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern,
else
ix2 = _cairo_lround (x2);
extents->x = ix1; extents->width = ix2 - ix1;
if (is_vector && extents->width == 0 && x1 != x2)
extents->width += 1;
if (!round_y) {
y1 -= 0.5;
@ -3746,7 +3752,9 @@ _cairo_pattern_get_extents (const cairo_pattern_t *pattern,
iy2 = CAIRO_RECT_INT_MAX;
else
iy2 = _cairo_lround (y2);
extents->y = iy1; extents->height = iy2 - iy1;
extents->y = iy1; extents->height = iy2 - iy1 + 1;
if (is_vector && extents->height == 0 && y1 != y2)
extents->height += 1;
return;
@ -3798,7 +3806,7 @@ _cairo_pattern_get_ink_extents (const cairo_pattern_t *pattern,
}
}
_cairo_pattern_get_extents (pattern, extents);
_cairo_pattern_get_extents (pattern, extents, TRUE);
return CAIRO_STATUS_SUCCESS;
}