[cairo-commit] 4 commits - src/cairo-clip.c src/cairo-clip-private.h src/cairo-surface-wrapper.c src/cairo-surface-wrapper-private.h

Chris Wilson ickle at kemper.freedesktop.org
Sun Jul 24 09:07:35 PDT 2011


 src/cairo-clip-private.h            |    3 
 src/cairo-clip.c                    |   36 +++++
 src/cairo-surface-wrapper-private.h |    4 
 src/cairo-surface-wrapper.c         |  259 +++++++++++-------------------------
 4 files changed, 127 insertions(+), 175 deletions(-)

New commits:
commit 4c72c4df661b4cc24f40d8719da15a13adc7bb9b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jul 24 16:27:07 2011 +0100

    wrapper: Correct translation of clip for wrapper extents
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-clip-private.h b/src/cairo-clip-private.h
index 1fad89c..b4cb018 100644
--- a/src/cairo-clip-private.h
+++ b/src/cairo-clip-private.h
@@ -100,6 +100,9 @@ cairo_private cairo_clip_t *
 _cairo_clip_copy_region (const cairo_clip_t *clip);
 
 cairo_private cairo_clip_t *
+_cairo_clip_translate (cairo_clip_t *clip, int tx, int ty);
+
+cairo_private cairo_clip_t *
 _cairo_clip_copy_with_translation (const cairo_clip_t *clip, int tx, int ty);
 
 cairo_private cairo_bool_t
diff --git a/src/cairo-clip.c b/src/cairo-clip.c
index fcd1acb..7e4f8c5 100644
--- a/src/cairo-clip.c
+++ b/src/cairo-clip.c
@@ -387,6 +387,42 @@ _cairo_clip_path_copy_with_translation (cairo_clip_t      *clip,
 }
 
 cairo_clip_t *
+_cairo_clip_translate (cairo_clip_t *clip, int tx, int ty)
+{
+    int fx, fy, i;
+    cairo_clip_path_t *clip_path;
+
+    if (clip == NULL || _cairo_clip_is_all_clipped (clip))
+	return (cairo_clip_t *)clip;
+
+    if (tx == 0 && ty == 0)
+	return clip;
+
+    fx = _cairo_fixed_from_int (tx);
+    fy = _cairo_fixed_from_int (ty);
+
+    for (i = 0; i < clip->num_boxes; i++) {
+	clip->boxes[i].p1.x += fx;
+	clip->boxes[i].p2.x += fx;
+	clip->boxes[i].p1.y += fy;
+	clip->boxes[i].p2.y += fy;
+    }
+
+    clip->extents.x += tx;
+    clip->extents.y += ty;
+
+    if (clip->path == NULL)
+	return clip;
+
+    clip_path = clip->path;
+    clip->path = NULL;
+    clip = _cairo_clip_path_copy_with_translation (clip, clip_path, fx, fy);
+    _cairo_clip_path_destroy (clip_path);
+
+    return clip;
+}
+
+cairo_clip_t *
 _cairo_clip_copy_with_translation (const cairo_clip_t *clip, int tx, int ty)
 {
     cairo_clip_t *copy;
diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index e4436ea..df32837 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -98,18 +98,13 @@ _cairo_surface_wrapper_get_clip (cairo_surface_wrapper_t *wrapper,
 {
     cairo_clip_t *copy;
 
-    copy = _cairo_clip_copy_with_translation (clip,
-					      -wrapper->extents.x,
-					      -wrapper->extents.y);
-    if (wrapper->has_extents) { /* XXX broken. */
-	cairo_rectangle_int_t extents;
-
-	extents.x = extents.y = 0;
-	extents.width  = wrapper->extents.width;
-	extents.height = wrapper->extents.height;
-
-	copy = _cairo_clip_intersect_rectangle (copy, &extents);
-    }
+    copy = _cairo_clip_copy (clip);
+    if (wrapper->has_extents)
+	copy = _cairo_clip_intersect_rectangle (copy, &wrapper->extents);
+    if (wrapper->extents.x | wrapper->extents.y)
+	copy = _cairo_clip_translate (copy,
+				      -wrapper->extents.x,
+				      -wrapper->extents.y);
     if (wrapper->clip)
 	copy = _cairo_clip_intersect_clip (copy, wrapper->clip);
 
@@ -405,9 +400,6 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
     if (unlikely (wrapper->target->status))
 	return wrapper->target->status;
 
-    if (glyphs == NULL || num_glyphs == 0)
-	return CAIRO_STATUS_SUCCESS;
-
     dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
     if (_cairo_clip_is_all_clipped (dev_clip))
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
@@ -571,6 +563,7 @@ _cairo_surface_wrapper_init (cairo_surface_wrapper_t *wrapper,
     wrapper->target = cairo_surface_reference (target);
     cairo_matrix_init_identity (&wrapper->transform);
     wrapper->has_extents = FALSE;
+    wrapper->extents.x = wrapper->extents.y = 0;
 
     wrapper->needs_transform =
 	! _cairo_matrix_is_identity (&wrapper->target->device_transform);
commit cc745f5c2f5a513e195a9a3b66e4428ec932bfe3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jul 24 15:48:27 2011 +0100

    wrapper: show-text-glyphs can now operate on constant array of glyphs
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface-wrapper-private.h b/src/cairo-surface-wrapper-private.h
index b810730..806c8dd 100644
--- a/src/cairo-surface-wrapper-private.h
+++ b/src/cairo-surface-wrapper-private.h
@@ -149,13 +149,13 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 					 const cairo_pattern_t	    *source,
 					 const char		    *utf8,
 					 int			     utf8_len,
-					 cairo_glyph_t		    *glyphs,
+					 const cairo_glyph_t	    *glyphs,
 					 int			     num_glyphs,
 					 const cairo_text_cluster_t *clusters,
 					 int			     num_clusters,
 					 cairo_text_cluster_flags_t  cluster_flags,
 					 cairo_scaled_font_t	    *scaled_font,
-					 const cairo_clip_t		    *clip);
+					 const cairo_clip_t	    *clip);
 
 cairo_private cairo_surface_t *
 _cairo_surface_wrapper_create_similar (cairo_surface_wrapper_t *wrapper,
diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index 5a552ad..e4436ea 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -388,13 +388,13 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 					 const cairo_pattern_t	    *source,
 					 const char		    *utf8,
 					 int			     utf8_len,
-					 cairo_glyph_t		    *glyphs,
+					 const cairo_glyph_t	    *glyphs,
 					 int			     num_glyphs,
 					 const cairo_text_cluster_t *clusters,
 					 int			     num_clusters,
 					 cairo_text_cluster_flags_t  cluster_flags,
 					 cairo_scaled_font_t	    *scaled_font,
-					 const cairo_clip_t		    *clip)
+					 const cairo_clip_t	    *clip)
 {
     cairo_status_t status;
     cairo_clip_t *dev_clip;
commit 415d5d8fce8b685a92eef7d0ae2568e1ee7e02e7
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jul 24 15:45:57 2011 +0100

    wrapper: Use the stack for small glyph allocations
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index 1254697..5a552ad 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -398,7 +398,8 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 {
     cairo_status_t status;
     cairo_clip_t *dev_clip;
-    cairo_glyph_t *dev_glyphs = glyphs;
+    cairo_glyph_t stack_glyphs [CAIRO_STACK_ARRAY_LENGTH(cairo_glyph_t)];
+    cairo_glyph_t *dev_glyphs = stack_glyphs;
     cairo_pattern_union_t source_copy;
 
     if (unlikely (wrapper->target->status))
@@ -417,10 +418,12 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 
 	_cairo_surface_wrapper_get_transform (wrapper, &m);
 
-	dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
-	if (dev_glyphs == NULL) {
-	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    goto FINISH;
+	if (num_glyphs > ARRAY_LENGTH (stack_glyphs)) {
+	    dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
+	    if (dev_glyphs == NULL) {
+		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+		goto FINISH;
+	    }
 	}
 
 	for (i = 0; i < num_glyphs; i++) {
@@ -438,10 +441,12 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 	 * to modify the glyph array that's passed in.  We must always
 	 * copy the array before handing it to the backend.
 	 */
-	dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
-	if (unlikely (dev_glyphs == NULL)) {
-	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-	    goto FINISH;
+	if (num_glyphs > ARRAY_LENGTH (stack_glyphs)) {
+	    dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
+	    if (unlikely (dev_glyphs == NULL)) {
+		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+		goto FINISH;
+	    }
 	}
 
 	memcpy (dev_glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
@@ -456,7 +461,7 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 					      dev_clip);
  FINISH:
     _cairo_clip_destroy (dev_clip);
-    if (dev_glyphs != glyphs)
+    if (dev_glyphs != stack_glyphs)
 	free (dev_glyphs);
     return status;
 }
commit 8102bd868105770a97e7d895b76b1b3ad40dcee9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jul 24 15:33:21 2011 +0100

    wrapper: Factor out the common clip handling
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index b21f445..1254697 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -92,6 +92,30 @@ _cairo_surface_wrapper_get_transform (cairo_surface_wrapper_t *wrapper,
 }
 
 
+static cairo_clip_t *
+_cairo_surface_wrapper_get_clip (cairo_surface_wrapper_t *wrapper,
+				 const cairo_clip_t *clip)
+{
+    cairo_clip_t *copy;
+
+    copy = _cairo_clip_copy_with_translation (clip,
+					      -wrapper->extents.x,
+					      -wrapper->extents.y);
+    if (wrapper->has_extents) { /* XXX broken. */
+	cairo_rectangle_int_t extents;
+
+	extents.x = extents.y = 0;
+	extents.width  = wrapper->extents.width;
+	extents.height = wrapper->extents.height;
+
+	copy = _cairo_clip_intersect_rectangle (copy, &extents);
+    }
+    if (wrapper->clip)
+	copy = _cairo_clip_intersect_clip (copy, wrapper->clip);
+
+    return copy;
+}
+
 cairo_status_t
 _cairo_surface_wrapper_paint (cairo_surface_wrapper_t *wrapper,
 			      cairo_operator_t	 op,
@@ -99,31 +123,21 @@ _cairo_surface_wrapper_paint (cairo_surface_wrapper_t *wrapper,
 			      const cairo_clip_t	    *clip)
 {
     cairo_status_t status;
-    cairo_clip_t *dev_clip = (cairo_clip_t *) clip;
-    cairo_clip_t *target_clip = NULL;
+    cairo_clip_t *dev_clip;
     cairo_pattern_union_t source_copy;
 
     if (unlikely (wrapper->target->status))
 	return wrapper->target->status;
 
-    if (wrapper->has_extents)
-	dev_clip = target_clip = _cairo_clip_copy_intersect_rectangle (clip, &wrapper->extents);
-
-    if (_cairo_clip_is_all_clipped (dev_clip)) {
-	status = CAIRO_STATUS_SUCCESS;
-	goto FINISH;
-    }
+    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
+    if (_cairo_clip_is_all_clipped (dev_clip))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
     if (wrapper->needs_transform) {
 	cairo_matrix_t m;
 
 	_cairo_surface_wrapper_get_transform (wrapper, &m);
 
-	/* XXX */
-	dev_clip = _cairo_clip_copy_with_translation (dev_clip,
-						      wrapper->extents.x,
-						      wrapper->extents.y);
-
 	status = cairo_matrix_invert (&m);
 	assert (status == CAIRO_STATUS_SUCCESS);
 
@@ -131,20 +145,13 @@ _cairo_surface_wrapper_paint (cairo_surface_wrapper_t *wrapper,
 	source = &source_copy.base;
     }
 
-    if (wrapper->clip)
-	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
-
-    status = CAIRO_INT_STATUS_NOTHING_TO_DO;
-    if (! _cairo_clip_is_all_clipped (dev_clip))
-	status = _cairo_surface_paint (wrapper->target, op, source, dev_clip);
+    status = _cairo_surface_paint (wrapper->target, op, source, dev_clip);
 
-  FINISH:
-    _cairo_clip_destroy (target_clip);
-    if (dev_clip != clip)
-	_cairo_clip_destroy (dev_clip);
+    _cairo_clip_destroy (dev_clip);
     return status;
 }
 
+
 cairo_status_t
 _cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper,
 			     cairo_operator_t	 op,
@@ -153,31 +160,22 @@ _cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper,
 			     const cairo_clip_t	    *clip)
 {
     cairo_status_t status;
-    cairo_clip_t *dev_clip = (cairo_clip_t *) clip;
+    cairo_clip_t *dev_clip;
     cairo_pattern_union_t source_copy;
     cairo_pattern_union_t mask_copy;
-    cairo_clip_t *target_clip = NULL;
 
     if (unlikely (wrapper->target->status))
 	return wrapper->target->status;
 
-    if (wrapper->has_extents)
-	dev_clip = target_clip = _cairo_clip_copy_intersect_rectangle (clip, &wrapper->extents);
-
-    if (_cairo_clip_is_all_clipped (dev_clip)) {
-	status = CAIRO_STATUS_SUCCESS;
-	goto FINISH;
-    }
+    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
+    if (_cairo_clip_is_all_clipped (dev_clip))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
     if (wrapper->needs_transform) {
 	cairo_matrix_t m;
 
 	_cairo_surface_wrapper_get_transform (wrapper, &m);
 
-	dev_clip = _cairo_clip_copy_with_translation (dev_clip,
-						      wrapper->extents.x,
-						      wrapper->extents.y);
-
 	status = cairo_matrix_invert (&m);
 	assert (status == CAIRO_STATUS_SUCCESS);
 
@@ -188,17 +186,9 @@ _cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper,
 	mask = &mask_copy.base;
     }
 
-    if (wrapper->clip)
-	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
+    status = _cairo_surface_mask (wrapper->target, op, source, mask, dev_clip);
 
-    status = CAIRO_INT_STATUS_NOTHING_TO_DO;
-    if (! _cairo_clip_is_all_clipped (dev_clip))
-	status = _cairo_surface_mask (wrapper->target, op, source, mask, dev_clip);
-
-  FINISH:
-    _cairo_clip_destroy (target_clip);
-    if (dev_clip != clip)
-	_cairo_clip_destroy (dev_clip);
+    _cairo_clip_destroy (dev_clip);
     return status;
 }
 
@@ -216,22 +206,17 @@ _cairo_surface_wrapper_stroke (cairo_surface_wrapper_t *wrapper,
 {
     cairo_status_t status;
     cairo_path_fixed_t path_copy, *dev_path = (cairo_path_fixed_t *) path;
-    cairo_clip_t *dev_clip = (cairo_clip_t *) clip;
+    cairo_clip_t *dev_clip;
     cairo_matrix_t dev_ctm = *ctm;
     cairo_matrix_t dev_ctm_inverse = *ctm_inverse;
     cairo_pattern_union_t source_copy;
-    cairo_clip_t *target_clip = NULL;
 
     if (unlikely (wrapper->target->status))
 	return wrapper->target->status;
 
-    if (wrapper->has_extents)
-	dev_clip = target_clip = _cairo_clip_copy_intersect_rectangle (clip, &wrapper->extents);
-
-    if (_cairo_clip_is_all_clipped (dev_clip)) {
-	status = CAIRO_STATUS_SUCCESS;
-	goto FINISH;
-    }
+    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
+    if (_cairo_clip_is_all_clipped (dev_clip))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
     if (wrapper->needs_transform) {
 	cairo_matrix_t m;
@@ -245,11 +230,6 @@ _cairo_surface_wrapper_stroke (cairo_surface_wrapper_t *wrapper,
 	_cairo_path_fixed_transform (&path_copy, &m);
 	dev_path = &path_copy;
 
-	/* XXX */
-	dev_clip = _cairo_clip_copy_with_translation (dev_clip,
-						      wrapper->extents.x,
-						      wrapper->extents.y);
-
 	cairo_matrix_multiply (&dev_ctm, &dev_ctm, &m);
 
 	status = cairo_matrix_invert (&m);
@@ -261,24 +241,16 @@ _cairo_surface_wrapper_stroke (cairo_surface_wrapper_t *wrapper,
 	source = &source_copy.base;
     }
 
-    if (wrapper->clip)
-	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
-
-    status = CAIRO_INT_STATUS_NOTHING_TO_DO;
-    if (! _cairo_clip_is_all_clipped (dev_clip)) {
-	status = _cairo_surface_stroke (wrapper->target, op, source,
-					dev_path, stroke_style,
-					&dev_ctm, &dev_ctm_inverse,
-					tolerance, antialias,
-					dev_clip);
-    }
+    status = _cairo_surface_stroke (wrapper->target, op, source,
+				    dev_path, stroke_style,
+				    &dev_ctm, &dev_ctm_inverse,
+				    tolerance, antialias,
+				    dev_clip);
 
  FINISH:
     if (dev_path != path)
 	_cairo_path_fixed_fini (dev_path);
-    _cairo_clip_destroy (target_clip);
-    if (dev_clip != clip)
-	_cairo_clip_destroy (dev_clip);
+    _cairo_clip_destroy (dev_clip);
     return status;
 }
 
@@ -301,23 +273,18 @@ _cairo_surface_wrapper_fill_stroke (cairo_surface_wrapper_t *wrapper,
 {
     cairo_status_t status;
     cairo_path_fixed_t path_copy, *dev_path = path;
-    cairo_clip_t *dev_clip = (cairo_clip_t *) clip;
     cairo_matrix_t dev_ctm = *stroke_ctm;
     cairo_matrix_t dev_ctm_inverse = *stroke_ctm_inverse;
+    cairo_clip_t *dev_clip;
     cairo_pattern_union_t stroke_source_copy;
     cairo_pattern_union_t fill_source_copy;
-    cairo_clip_t *target_clip = NULL;
 
     if (unlikely (wrapper->target->status))
 	return wrapper->target->status;
 
-    if (wrapper->has_extents)
-	dev_clip = target_clip = _cairo_clip_copy_intersect_rectangle (clip, &wrapper->extents);
-
-    if (_cairo_clip_is_all_clipped (dev_clip)) {
-	status = CAIRO_STATUS_SUCCESS;
-	goto FINISH;
-    }
+    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
+    if (_cairo_clip_is_all_clipped (dev_clip))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
     if (wrapper->needs_transform) {
 	cairo_matrix_t m;
@@ -331,11 +298,6 @@ _cairo_surface_wrapper_fill_stroke (cairo_surface_wrapper_t *wrapper,
 	_cairo_path_fixed_transform (&path_copy, &m);
 	dev_path = &path_copy;
 
-	/* XXX */
-	dev_clip = _cairo_clip_copy_with_translation (dev_clip,
-						      wrapper->extents.x,
-						      wrapper->extents.y);
-
 	cairo_matrix_multiply (&dev_ctm, &dev_ctm, &m);
 
 	status = cairo_matrix_invert (&m);
@@ -350,28 +312,20 @@ _cairo_surface_wrapper_fill_stroke (cairo_surface_wrapper_t *wrapper,
 	fill_source = &fill_source_copy.base;
     }
 
-    if (wrapper->clip)
-	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
-
-    status = CAIRO_INT_STATUS_NOTHING_TO_DO;
-    if (! _cairo_clip_is_all_clipped (dev_clip)) {
-	status = _cairo_surface_fill_stroke (wrapper->target,
-					     fill_op, fill_source, fill_rule,
-					     fill_tolerance, fill_antialias,
-					     dev_path,
-					     stroke_op, stroke_source,
-					     stroke_style,
-					     &dev_ctm, &dev_ctm_inverse,
-					     stroke_tolerance, stroke_antialias,
-					     dev_clip);
-    }
+    status = _cairo_surface_fill_stroke (wrapper->target,
+					 fill_op, fill_source, fill_rule,
+					 fill_tolerance, fill_antialias,
+					 dev_path,
+					 stroke_op, stroke_source,
+					 stroke_style,
+					 &dev_ctm, &dev_ctm_inverse,
+					 stroke_tolerance, stroke_antialias,
+					 dev_clip);
 
   FINISH:
     if (dev_path != path)
 	_cairo_path_fixed_fini (dev_path);
-    _cairo_clip_destroy (target_clip);
-    if (dev_clip != clip)
-	_cairo_clip_destroy (dev_clip);
+    _cairo_clip_destroy (dev_clip);
     return status;
 }
 
@@ -387,20 +341,15 @@ _cairo_surface_wrapper_fill (cairo_surface_wrapper_t	*wrapper,
 {
     cairo_status_t status;
     cairo_path_fixed_t path_copy, *dev_path = (cairo_path_fixed_t *) path;
-    cairo_clip_t *dev_clip = (cairo_clip_t *) clip;
     cairo_pattern_union_t source_copy;
-    cairo_clip_t *target_clip = NULL;
+    cairo_clip_t *dev_clip;
 
     if (unlikely (wrapper->target->status))
 	return wrapper->target->status;
 
-    if (wrapper->has_extents)
-	dev_clip = target_clip = _cairo_clip_copy_intersect_rectangle (clip, &wrapper->extents);
-
-    if (_cairo_clip_is_all_clipped (dev_clip)) {
-	status = CAIRO_STATUS_SUCCESS;
-	goto FINISH;
-    }
+    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
+    if (_cairo_clip_is_all_clipped (dev_clip))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
     if (wrapper->needs_transform) {
 	cairo_matrix_t m;
@@ -414,11 +363,6 @@ _cairo_surface_wrapper_fill (cairo_surface_wrapper_t	*wrapper,
 	_cairo_path_fixed_transform (&path_copy, &m);
 	dev_path = &path_copy;
 
-	/* XXX */
-	dev_clip = _cairo_clip_copy_with_translation (dev_clip,
-						      wrapper->extents.x,
-						      wrapper->extents.y);
-
 	status = cairo_matrix_invert (&m);
 	assert (status == CAIRO_STATUS_SUCCESS);
 
@@ -426,23 +370,15 @@ _cairo_surface_wrapper_fill (cairo_surface_wrapper_t	*wrapper,
 	source = &source_copy.base;
     }
 
-    if (wrapper->clip)
-	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
-
-    status = CAIRO_INT_STATUS_NOTHING_TO_DO;
-    if (! _cairo_clip_is_all_clipped (dev_clip)) {
-	status = _cairo_surface_fill (wrapper->target, op, source,
-				      dev_path, fill_rule,
-				      tolerance, antialias,
-				      dev_clip);
-    }
+    status = _cairo_surface_fill (wrapper->target, op, source,
+				  dev_path, fill_rule,
+				  tolerance, antialias,
+				  dev_clip);
 
  FINISH:
     if (dev_path != path)
 	_cairo_path_fixed_fini (dev_path);
-    _cairo_clip_destroy (target_clip);
-    if (dev_clip != clip)
-	_cairo_clip_destroy (dev_clip);
+    _cairo_clip_destroy (dev_clip);
     return status;
 }
 
@@ -461,10 +397,9 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 					 const cairo_clip_t		    *clip)
 {
     cairo_status_t status;
-    cairo_clip_t *dev_clip = (cairo_clip_t *)clip;
+    cairo_clip_t *dev_clip;
     cairo_glyph_t *dev_glyphs = glyphs;
     cairo_pattern_union_t source_copy;
-    cairo_clip_t *target_clip = NULL;
 
     if (unlikely (wrapper->target->status))
 	return wrapper->target->status;
@@ -472,25 +407,7 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
     if (glyphs == NULL || num_glyphs == 0)
 	return CAIRO_STATUS_SUCCESS;
 
-    if (wrapper->has_extents)
-	dev_clip = target_clip = _cairo_clip_copy_intersect_rectangle (clip, &wrapper->extents);
-
-    if (_cairo_clip_is_all_clipped (dev_clip)) {
-	status = CAIRO_STATUS_SUCCESS;
-	goto FINISH;
-    }
-
-    if (wrapper->extents.x | wrapper->extents.y) {
-	/* XXX */
-	dev_clip = _cairo_clip_copy_with_translation (dev_clip,
-						      wrapper->extents.x,
-						      wrapper->extents.y);
-
-    }
-
-    if (wrapper->clip)
-	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
-
+    dev_clip = _cairo_surface_wrapper_get_clip (wrapper, clip);
     if (_cairo_clip_is_all_clipped (dev_clip))
 	return CAIRO_INT_STATUS_NOTHING_TO_DO;
 
@@ -538,9 +455,7 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 					      scaled_font,
 					      dev_clip);
  FINISH:
-    if (dev_clip != clip)
-	_cairo_clip_destroy (dev_clip);
-    _cairo_clip_destroy (target_clip);
+    _cairo_clip_destroy (dev_clip);
     if (dev_glyphs != glyphs)
 	free (dev_glyphs);
     return status;


More information about the cairo-commit mailing list