[cairo-commit] 2 commits - src/cairo-composite-rectangles.c src/cairo-composite-rectangles-private.h src/cairo-pdf-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Sun Sep 18 00:29:09 PDT 2011


 src/cairo-composite-rectangles-private.h |    4 ++
 src/cairo-composite-rectangles.c         |   57 +++++++++++++++++++++++++++++--
 src/cairo-pdf-surface.c                  |   17 +++++++--
 3 files changed, 71 insertions(+), 7 deletions(-)

New commits:
commit e4ebee1cf47f5c211abb79b8e3a3bc5ff7a5cc4b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Sep 18 08:25:11 2011 +0100

    pdf: Use the helper functions to update the composite rectangles
    
    These functions also know to update the clip and recompute the sample
    areas and other derived information.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-pdf-surface.c b/src/cairo-pdf-surface.c
index 8da4f7b..988a215 100644
--- a/src/cairo-pdf-surface.c
+++ b/src/cairo-pdf-surface.c
@@ -6104,6 +6104,8 @@ _cairo_pdf_surface_mask (void			*abstract_surface,
     cairo_pdf_smask_group_t *group;
     cairo_composite_rectangles_t extents;
     cairo_int_status_t status;
+    cairo_rectangle_int_t r;
+    cairo_box_t box;
 
     status = _cairo_composite_rectangles_init_for_mask (&extents,
 							&surface->base,
@@ -6141,18 +6143,25 @@ _cairo_pdf_surface_mask (void			*abstract_surface,
     assert (_cairo_pdf_surface_operation_supported (surface, op, mask, &extents.bounded));
 
     /* get the accurate extents */
-    status = _cairo_pattern_get_ink_extents (source, &extents.source);
+    status = _cairo_pattern_get_ink_extents (source, &r);
     if (unlikely (status))
 	goto cleanup;
 
-    if (! _cairo_rectangle_intersect (&extents.bounded, &extents.source))
+    /* XXX slight impedance mismatch */
+    _cairo_box_from_rectangle (&box, &r);
+    status = _cairo_composite_rectangles_intersect_source_extents (&extents,
+								   &box);
+    if (unlikely (status))
 	goto cleanup;
 
-    status = _cairo_pattern_get_ink_extents (mask, &extents.mask);
+    status = _cairo_pattern_get_ink_extents (mask, &r);
     if (unlikely (status))
 	goto cleanup;
 
-    if (! _cairo_rectangle_intersect (&extents.bounded, &extents.mask))
+    _cairo_box_from_rectangle (&box, &r);
+    status = _cairo_composite_rectangles_intersect_mask_extents (&extents,
+								 &box);
+    if (unlikely (status))
 	goto cleanup;
 
     status = _cairo_pdf_surface_set_clip (surface, &extents);
commit 6c6bd6fb292c7168b60f1cc0580c52292f99ae86
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Sep 18 08:26:42 2011 +0100

    composite-rectangle: Add a helper to refine source extents
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-composite-rectangles-private.h b/src/cairo-composite-rectangles-private.h
index 8a06bf9..8603108 100644
--- a/src/cairo-composite-rectangles-private.h
+++ b/src/cairo-composite-rectangles-private.h
@@ -136,6 +136,10 @@ _cairo_composite_rectangles_init_for_glyphs (cairo_composite_rectangles_t *exten
 					     cairo_bool_t		*overlap);
 
 cairo_private cairo_int_status_t
+_cairo_composite_rectangles_intersect_source_extents (cairo_composite_rectangles_t *extents,
+						      const cairo_box_t *box);
+
+cairo_private cairo_int_status_t
 _cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t *extents,
 						    const cairo_box_t *box);
 
diff --git a/src/cairo-composite-rectangles.c b/src/cairo-composite-rectangles.c
index a6f3768..c66d3d6 100644
--- a/src/cairo-composite-rectangles.c
+++ b/src/cairo-composite-rectangles.c
@@ -172,6 +172,60 @@ _cairo_composite_rectangles_intersect (cairo_composite_rectangles_t *extents,
 }
 
 cairo_int_status_t
+_cairo_composite_rectangles_intersect_source_extents (cairo_composite_rectangles_t *extents,
+						      const cairo_box_t *box)
+{
+    cairo_rectangle_int_t rect;
+    cairo_clip_t *clip;
+
+    _cairo_box_round_to_rectangle (box, &rect);
+    if (rect.x == extents->source.x &&
+	rect.y == extents->source.y &&
+	rect.width  == extents->source.width &&
+	rect.height == extents->source.height)
+    {
+	return CAIRO_INT_STATUS_SUCCESS;
+    }
+
+    _cairo_rectangle_intersect (&extents->source, &rect);
+
+    rect = extents->bounded;
+    if (! _cairo_rectangle_intersect (&extents->bounded, &extents->source) &&
+	extents->is_bounded & CAIRO_OPERATOR_BOUND_BY_SOURCE)
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
+    if (rect.width  == extents->bounded.width &&
+	rect.height == extents->bounded.height)
+	return CAIRO_INT_STATUS_SUCCESS;
+
+    if (extents->is_bounded == (CAIRO_OPERATOR_BOUND_BY_MASK | CAIRO_OPERATOR_BOUND_BY_SOURCE))
+	extents->unbounded = extents->bounded;
+
+    clip = extents->clip;
+    extents->clip = _cairo_clip_reduce_for_composite (clip, extents);
+    if (clip != extents->clip)
+	_cairo_clip_destroy (clip);
+
+    if (_cairo_clip_is_all_clipped (extents->clip))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
+    if (extents->source_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID)
+	_cairo_pattern_sampled_area (&extents->source_pattern.base,
+				     &extents->bounded,
+				     &extents->source_sample_area);
+    if (extents->mask_pattern.base.type != CAIRO_PATTERN_TYPE_SOLID) {
+	_cairo_pattern_sampled_area (&extents->mask_pattern.base,
+				     &extents->bounded,
+				     &extents->mask_sample_area);
+	if (extents->mask_sample_area.width == 0 ||
+	    extents->mask_sample_area.height == 0)
+	    return CAIRO_INT_STATUS_NOTHING_TO_DO;
+    }
+
+    return CAIRO_INT_STATUS_SUCCESS;
+}
+
+cairo_int_status_t
 _cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t *extents,
 						    const cairo_box_t *box)
 {
@@ -201,11 +255,8 @@ _cairo_composite_rectangles_intersect_mask_extents (cairo_composite_rectangles_t
     if (extents->is_bounded == (CAIRO_OPERATOR_BOUND_BY_MASK | CAIRO_OPERATOR_BOUND_BY_SOURCE))
 	extents->unbounded = extents->bounded;
 
-    extents->mask = mask;
     clip = extents->clip;
-
     extents->clip = _cairo_clip_reduce_for_composite (clip, extents);
-
     if (clip != extents->clip)
 	_cairo_clip_destroy (clip);
 


More information about the cairo-commit mailing list