[cairo-commit] 4 commits - src/cairo-xcb-connection.c src/cairo-xcb-surface-render.c

Uli Schlachter psychon at kemper.freedesktop.org
Sun Dec 11 05:06:37 PST 2011


 src/cairo-xcb-connection.c     |   10 ++-
 src/cairo-xcb-surface-render.c |  125 +++++++++++++++++++++++++++++++++--------
 2 files changed, 110 insertions(+), 25 deletions(-)

New commits:
commit 8025fcc4d38db1e2f7adabe732dbde481b6aeade
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Dec 11 13:58:10 2011 +0100

    xcb: Add a special case for recording surface
    
    An unbounded recording surface will complain loudly when you call
    acquire_source_image on it and thus we need a special case which draws the
    recording surface to a temporary surface and then proceeds with that.
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index afd339a..13d92f7 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -42,6 +42,8 @@
 #include "cairo-surface-snapshot-private.h"
 #include "cairo-surface-subsurface-private.h"
 #include "cairo-traps-private.h"
+#include "cairo-recording-surface-private.h"
+#include "cairo-paginated-private.h"
 
 #define PIXMAN_MAX_INT ((pixman_fixed_1 >> 1) - pixman_fixed_e) /* need to ensure deltas also fit */
 
@@ -1060,6 +1062,66 @@ _cairo_xcb_surface_setup_surface_picture(cairo_xcb_picture_t *picture,
 }
 
 static cairo_xcb_picture_t *
+record_to_picture (cairo_surface_t *target,
+		   const cairo_surface_pattern_t *pattern,
+		   const cairo_rectangle_int_t *extents)
+{
+    cairo_surface_pattern_t tmp_pattern;
+    cairo_xcb_picture_t *picture;
+    cairo_status_t status;
+    cairo_matrix_t matrix;
+    cairo_surface_t *tmp;
+    cairo_surface_t *source = pattern->surface;
+
+    /* XXX: The following is more or less copied from cairo-xlibs-ource.c,
+     * record_source() and recording_pattern_get_surface(), can we share a
+     * single version?
+     */
+
+    /* First get the 'real' recording surface */
+    if (_cairo_surface_is_paginated (source))
+	source = _cairo_paginated_surface_get_recording (source);
+    if (_cairo_surface_is_snapshot (source))
+	source = _cairo_surface_snapshot_get_target (source);
+    assert (_cairo_surface_is_recording (source));
+
+    /* Now draw the recording surface to an xcb surface */
+    tmp = _cairo_surface_create_similar_scratch (target,
+						 source->content,
+						 extents->width,
+						 extents->height);
+    if (tmp->status != CAIRO_STATUS_SUCCESS) {
+	return (cairo_xcb_picture_t *) tmp;
+    }
+
+    cairo_matrix_init_translate (&matrix, extents->x, extents->y);
+    status = _cairo_recording_surface_replay_with_clip (source,
+							&matrix, tmp,
+							NULL);
+    if (unlikely (status)) {
+	cairo_surface_destroy (tmp);
+	return (cairo_xcb_picture_t *) _cairo_surface_create_in_error (status);
+    }
+
+    /* Now that we have drawn this to an xcb surface, try again with that */
+    _cairo_pattern_init_static_copy (&tmp_pattern.base, &pattern->base);
+    tmp_pattern.surface = tmp;
+
+    if (extents->x | extents->y) {
+	cairo_matrix_t *pmatrix = &tmp_pattern.base.matrix;
+
+	cairo_matrix_init_translate (&matrix, -extents->x, -extents->y);
+	cairo_matrix_multiply (pmatrix, pmatrix, &matrix);
+    }
+
+    picture = _copy_to_picture ((cairo_xcb_surface_t *) tmp);
+    if (picture->base.status == CAIRO_STATUS_SUCCESS)
+	_cairo_xcb_surface_setup_surface_picture (picture, &tmp_pattern, extents);
+    cairo_surface_destroy (tmp);
+    return picture;
+}
+
+static cairo_xcb_picture_t *
 _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 			    const cairo_surface_pattern_t *pattern,
 			    const cairo_rectangle_int_t *extents)
@@ -1177,6 +1239,14 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 	/* pixmap from texture */
     }
 #endif
+    else if (source->type == CAIRO_SURFACE_TYPE_RECORDING)
+    {
+	/* We have to skip the call to attach_snapshot() because we possibly
+	 * only drew part of the recording surface.
+	 * TODO: When can we safely attach a snapshot?
+	 */
+	return record_to_picture(&target->base, pattern, extents);
+    }
 
     if (picture == NULL) {
 	cairo_image_surface_t *image;
commit 420110d12bd74969f84d6a1979b33f1d71d63c43
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Dec 11 13:41:39 2011 +0100

    xcb: Move the surface picture setup into its own function
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 265fc04..afd339a 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -1032,6 +1032,33 @@ _copy_to_picture (cairo_xcb_surface_t *source)
     return picture;
 }
 
+static void
+_cairo_xcb_surface_setup_surface_picture(cairo_xcb_picture_t *picture,
+					 const cairo_surface_pattern_t *pattern,
+					 const cairo_rectangle_int_t *extents)
+{
+    cairo_filter_t filter;
+
+    filter = pattern->base.filter;
+    if (filter != CAIRO_FILTER_NEAREST &&
+	_cairo_matrix_has_unity_scale (&pattern->base.matrix) &&
+	_cairo_fixed_is_integer (_cairo_fixed_from_double (pattern->base.matrix.x0)) &&
+	_cairo_fixed_is_integer (_cairo_fixed_from_double (pattern->base.matrix.y0)))
+    {
+	filter = CAIRO_FILTER_NEAREST;
+    }
+    _cairo_xcb_picture_set_filter (picture, filter);
+
+    _cairo_xcb_picture_set_matrix (picture,
+				   &pattern->base.matrix, filter,
+				   extents->x + extents->width/2.,
+				   extents->y + extents->height/2.);
+
+
+    _cairo_xcb_picture_set_extend (picture, pattern->base.extend);
+    _cairo_xcb_picture_set_component_alpha (picture, pattern->base.has_component_alpha);
+}
+
 static cairo_xcb_picture_t *
 _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 			    const cairo_surface_pattern_t *pattern,
@@ -1039,14 +1066,14 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 {
     cairo_surface_t *source = pattern->surface;
     cairo_xcb_picture_t *picture;
-    cairo_filter_t filter;
 
     picture = (cairo_xcb_picture_t *)
 	_cairo_surface_has_snapshot (source, &_cairo_xcb_picture_backend);
     if (picture != NULL) {
 	if (picture->screen == target->screen) {
 	    picture = (cairo_xcb_picture_t *) cairo_surface_reference (&picture->base);
-	    goto setup_picture;
+	    _cairo_xcb_surface_setup_surface_picture (picture, pattern, extents);
+	    return picture;
 	}
 	picture = NULL;
     }
@@ -1191,26 +1218,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 				    &picture->base,
 				    NULL);
 
-setup_picture:
-    filter = pattern->base.filter;
-    if (filter != CAIRO_FILTER_NEAREST &&
-	_cairo_matrix_has_unity_scale (&pattern->base.matrix) &&
-	_cairo_fixed_is_integer (_cairo_fixed_from_double (pattern->base.matrix.x0)) &&
-	_cairo_fixed_is_integer (_cairo_fixed_from_double (pattern->base.matrix.y0)))
-    {
-	filter = CAIRO_FILTER_NEAREST;
-    }
-    _cairo_xcb_picture_set_filter (picture, filter);
-
-    _cairo_xcb_picture_set_matrix (picture,
-				   &pattern->base.matrix, filter,
-				   extents->x + extents->width/2.,
-				   extents->y + extents->height/2.);
-
-
-    _cairo_xcb_picture_set_extend (picture, pattern->base.extend);
-    _cairo_xcb_picture_set_component_alpha (picture, pattern->base.has_component_alpha);
-
+    _cairo_xcb_surface_setup_surface_picture (picture, pattern, extents);
     return picture;
 }
 
commit fe04df11ed491db719f299213665bfe8be83c971
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Dec 11 11:17:06 2011 +0100

    xcb: Silence compiler warnings about ignored return values
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-connection.c b/src/cairo-xcb-connection.c
index 2c63a93..b045d6e 100644
--- a/src/cairo-xcb-connection.c
+++ b/src/cairo-xcb-connection.c
@@ -808,7 +808,10 @@ cairo_xcb_device_debug_cap_xshm_version (cairo_device_t *device,
     cairo_xcb_connection_t *connection = (cairo_xcb_connection_t *) device;
 
     if (device->backend->type != CAIRO_DEVICE_TYPE_XCB) {
-	_cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
 	return;
     }
 
@@ -844,7 +847,10 @@ cairo_xcb_device_debug_cap_xrender_version (cairo_device_t *device,
     cairo_xcb_connection_t *connection = (cairo_xcb_connection_t *) device;
 
     if (device->backend->type != CAIRO_DEVICE_TYPE_XCB) {
-	_cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	cairo_status_t status;
+
+	status = _cairo_device_set_error (device, CAIRO_STATUS_DEVICE_TYPE_MISMATCH);
+	(void) status;
 	return;
     }
 
diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 40f0316..265fc04 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -468,6 +468,7 @@ _cairo_xcb_picture_set_matrix (cairo_xcb_picture_t *picture,
     ignored = _cairo_matrix_to_pixman_matrix_offset (matrix, filter, xc, yc,
 						     pixman_transform,
 						     &picture->x, &picture->y);
+    (void) ignored;
 
     if (memcmp (&picture->transform, &transform, sizeof (xcb_render_transform_t))) {
 	_cairo_xcb_connection_render_set_picture_transform (_picture_to_connection (picture),
commit b6fcf0768c361b15db09d5732b92613a41168a25
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Dec 11 11:10:20 2011 +0100

    xcb: Silence a compiler warning for mixing type and internal type enums
    
    cairo-xcb-surface-render.c:1134:35: warning: comparison between
    'cairo_surface_type_t' and 'enum _cairo_internal_surface_type' [-Wenum-compare]
    
    Signed-off-by: Uli Schlachter <psychon at znc.in>

diff --git a/src/cairo-xcb-surface-render.c b/src/cairo-xcb-surface-render.c
index 5a4f74b..40f0316 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -1131,7 +1131,7 @@ _cairo_xcb_surface_picture (cairo_xcb_surface_t *target,
 		picture->width  = rect.width;
 		picture->height = rect.height;
 	    }
-	} else if (source->backend->type == CAIRO_INTERNAL_SURFACE_TYPE_SNAPSHOT) {
+	} else if (_cairo_surface_is_snapshot (source)) {
 	    cairo_surface_snapshot_t *snap = (cairo_surface_snapshot_t *) source;
 	    cairo_xcb_surface_t *xcb = ((cairo_xlib_xcb_surface_t *) snap->target)->xcb;
 


More information about the cairo-commit mailing list