[cairo-commit] src/cairo-analysis-surface.c src/cairo-composite-rectangles.c src/cairo-pattern.c src/cairo-pattern-private.h

Adrian Johnson ajohnson at kemper.freedesktop.org
Sat Jul 16 06:29:48 UTC 2016


 src/cairo-analysis-surface.c     |    4 ++--
 src/cairo-composite-rectangles.c |    7 ++++---
 src/cairo-pattern-private.h      |    3 ++-
 src/cairo-pattern.c              |   14 +++++++++++---
 4 files changed, 19 insertions(+), 9 deletions(-)

New commits:
commit 190678f6444ad879847d603c3c9eaf8e9ab6887a
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Sat Jul 16 14:59:43 2016 +0930

    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

diff --git a/src/cairo-analysis-surface.c b/src/cairo-analysis-surface.c
index 80f92d7..58b02e7 100644
--- a/src/cairo-analysis-surface.c
+++ b/src/cairo-analysis-surface.c
@@ -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);
     }
 
diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c
index bc6e1f3..f102edd 100644
--- a/src/cairo-composite-rectangles.c
+++ b/src/cairo-composite-rectangles.c
@@ -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);
 }
diff --git a/src/cairo-pattern-private.h b/src/cairo-pattern-private.h
index be8ab9f..ad7e2e7 100644
--- a/src/cairo-pattern-private.h
+++ b/src/cairo-pattern-private.h
@@ -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,
diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 3aafcb2..aa78c32 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -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;
 }
 


More information about the cairo-commit mailing list