[cairo-commit] 2 commits - src/cairo-recording-surface.c src/cairo-surface-wrapper.c src/cairo-xcb-surface-render.c

Chris Wilson ickle at kemper.freedesktop.org
Sun Jul 24 07:13:19 PDT 2011


 src/cairo-recording-surface.c  |   21 ---------
 src/cairo-surface-wrapper.c    |   88 +++++++++++++++++++++++++++--------------
 src/cairo-xcb-surface-render.c |   16 ++-----
 3 files changed, 66 insertions(+), 59 deletions(-)

New commits:
commit 87e9c8a5ea84bd00311a6a6ea3cea1fd87823172
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jul 24 15:10:18 2011 +0100

    recording: Move the glyph allocation into the wrapper after checking clip status
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-recording-surface.c b/src/cairo-recording-surface.c
index 1460aff..2866155 100644
--- a/src/cairo-recording-surface.c
+++ b/src/cairo-recording-surface.c
@@ -959,35 +959,16 @@ _cairo_recording_surface_replay_internal (cairo_surface_t	     *surface,
 	    break;
 
 	case CAIRO_COMMAND_SHOW_TEXT_GLYPHS:
-	{
-	    cairo_glyph_t *glyphs = command->show_text_glyphs.glyphs;
-	    cairo_glyph_t *glyphs_copy;
-	    int num_glyphs = command->show_text_glyphs.num_glyphs;
-
-            /* show_text_glyphs is special because _cairo_surface_show_text_glyphs is allowed
-	     * to modify the glyph array that's passed in.  We must always
-	     * copy the array before handing it to the backend.
-	     */
-	    glyphs_copy = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
-	    if (unlikely (glyphs_copy == NULL)) {
-		status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
-		break;
-	    }
-
-	    memcpy (glyphs_copy, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
-
 	    status = _cairo_surface_wrapper_show_text_glyphs (&wrapper,
 							      command->header.op,
 							      &command->show_text_glyphs.source.base,
 							      command->show_text_glyphs.utf8, command->show_text_glyphs.utf8_len,
-							      glyphs_copy, num_glyphs,
+							      command->show_text_glyphs.glyphs, command->show_text_glyphs.num_glyphs,
 							      command->show_text_glyphs.clusters, command->show_text_glyphs.num_clusters,
 							      command->show_text_glyphs.cluster_flags,
 							      command->show_text_glyphs.scaled_font,
 							      clip);
-	    free (glyphs_copy);
 	    break;
-	}
 
 	default:
 	    ASSERT_NOT_REACHED;
diff --git a/src/cairo-surface-wrapper.c b/src/cairo-surface-wrapper.c
index 5684a14..b21f445 100644
--- a/src/cairo-surface-wrapper.c
+++ b/src/cairo-surface-wrapper.c
@@ -134,7 +134,9 @@ _cairo_surface_wrapper_paint (cairo_surface_wrapper_t *wrapper,
     if (wrapper->clip)
 	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
 
-    status = _cairo_surface_paint (wrapper->target, op, source, dev_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);
 
   FINISH:
     _cairo_clip_destroy (target_clip);
@@ -189,7 +191,9 @@ _cairo_surface_wrapper_mask (cairo_surface_wrapper_t *wrapper,
     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);
@@ -260,11 +264,14 @@ _cairo_surface_wrapper_stroke (cairo_surface_wrapper_t *wrapper,
     if (wrapper->clip)
 	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
 
-    status = _cairo_surface_stroke (wrapper->target, op, source,
-				    dev_path, stroke_style,
-				    &dev_ctm, &dev_ctm_inverse,
-				    tolerance, antialias,
-				    dev_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);
+    }
 
  FINISH:
     if (dev_path != path)
@@ -346,15 +353,18 @@ _cairo_surface_wrapper_fill_stroke (cairo_surface_wrapper_t *wrapper,
     if (wrapper->clip)
 	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->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_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);
+    }
 
   FINISH:
     if (dev_path != path)
@@ -419,10 +429,13 @@ _cairo_surface_wrapper_fill (cairo_surface_wrapper_t	*wrapper,
     if (wrapper->clip)
 	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
 
-    status = _cairo_surface_fill (wrapper->target, op, source,
-				  dev_path, fill_rule,
-				  tolerance, antialias,
-				  dev_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);
+    }
 
  FINISH:
     if (dev_path != path)
@@ -467,17 +480,26 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 	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);
+
+    if (_cairo_clip_is_all_clipped (dev_clip))
+	return CAIRO_INT_STATUS_NOTHING_TO_DO;
+
     if (wrapper->needs_transform) {
 	cairo_matrix_t m;
 	int i;
 
 	_cairo_surface_wrapper_get_transform (wrapper, &m);
 
-	/* XXX */
-	dev_clip = _cairo_clip_copy_with_translation (dev_clip,
-						      wrapper->extents.x,
-						      wrapper->extents.y);
-
 	dev_glyphs = _cairo_malloc_ab (num_glyphs, sizeof (cairo_glyph_t));
 	if (dev_glyphs == NULL) {
 	    status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
@@ -494,10 +516,19 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 
 	_copy_transformed_pattern (&source_copy.base, source, &m);
 	source = &source_copy.base;
-    }
+    } else {
+	/* show_text_glyphs is special because _cairo_surface_show_text_glyphs is allowed
+	 * 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 (wrapper->clip)
-	dev_clip = _cairo_clip_copy_intersect_clip (dev_clip, wrapper->clip);
+	memcpy (dev_glyphs, glyphs, sizeof (cairo_glyph_t) * num_glyphs);
+    }
 
     status = _cairo_surface_show_text_glyphs (wrapper->target, op, source,
 					      utf8, utf8_len,
@@ -506,7 +537,6 @@ _cairo_surface_wrapper_show_text_glyphs (cairo_surface_wrapper_t *wrapper,
 					      cluster_flags,
 					      scaled_font,
 					      dev_clip);
-
  FINISH:
     if (dev_clip != clip)
 	_cairo_clip_destroy (dev_clip);
commit 59612847e31ac6f22f7a59c57ff39c179aab9bca
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jul 24 15:08:03 2011 +0100

    xcb: set the right members of cairo_color_t for generating the opacity mask
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 4995be7..a9d000b 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -3126,15 +3126,13 @@ static void composite_box(void *closure,
     struct composite_box_info *info = closure;
 
     if (coverage < 0xff00) {
-	cairo_solid_pattern_t mask_pattern;
 	cairo_xcb_picture_t *mask;
 	cairo_color_t color;
 
-	color.red = color.green = color.blue = 0;
-	color.alpha = coverage;
-	_cairo_pattern_init_solid (&mask_pattern, &color);
+	color.red_short = color.green_short = color.blue_short = 0;
+	color.alpha_short = coverage;
 
-	mask = _cairo_xcb_picture_for_pattern (info->dst, &mask_pattern.base, NULL);
+	mask = _solid_picture (info->dst, &color);
 	if (likely (mask->base.status == CAIRO_STATUS_SUCCESS)) {
 	    _cairo_xcb_connection_render_composite (info->dst->connection,
 						    info->op,
@@ -3270,15 +3268,13 @@ static void composite_opacity(void *closure,
 			      uint16_t coverage)
 {
     struct composite_opacity_info *info = closure;
-    cairo_solid_pattern_t mask_pattern;
     cairo_xcb_picture_t *mask;
     cairo_color_t color;
 
-    color.red = color.green = color.blue = 0;
-    color.alpha = info->opacity * coverage;
-    _cairo_pattern_init_solid (&mask_pattern, &color);
+    color.red_short = color.green_short = color.blue_short = 0;
+    color.alpha_short = info->opacity * coverage;
 
-    mask = _cairo_xcb_picture_for_pattern (info->dst, &mask_pattern.base, NULL);
+    mask = _solid_picture (info->dst, &color);
     if (likely (mask->base.status == CAIRO_STATUS_SUCCESS)) {
 	if (info->src) {
 	    _cairo_xcb_connection_render_composite (info->dst->connection,


More information about the cairo-commit mailing list