[cairo-commit] 2 commits - src/cairo-pattern.c src/cairo-xlib-surface.c

Chris Wilson ickle at kemper.freedesktop.org
Tue Oct 7 13:31:16 PDT 2008


 src/cairo-pattern.c      |   16 +++++++++++++---
 src/cairo-xlib-surface.c |   10 ++++++++--
 2 files changed, 21 insertions(+), 5 deletions(-)

New commits:
commit eaa4bd13926728e9da97a23df8a465ef2296049a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 7 21:09:16 2008 +0100

    [pattern] After cloning adjust [xy]_offset if possible.
    
    For the simple case where the pattern matrix only contains an integer
    translation then care is taken to convert that to a identity source matrix
    with the translation applied to the [xy]_offsets. 5b97ee6525 broke this
    guarantee by applying the clone offsets to the source matrix. So when the
    source matrix is identity we can simply adjust the [xy]_offsets and
    preserve the identity matrix. (This idea can be extended further by
    removing any integer translation from the source matrix and storing it in
    the [xy]_offsets as a means to extend the limited precision in
    pixman_matrix_t - encountered when downscaling large images offset onto
    the target surface.)

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 33a99a1..16c3dc9 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1890,10 +1890,20 @@ _cairo_pattern_acquire_surface_for_surface (cairo_surface_pattern_t   *pattern,
 					       extents.width, extents.height,
 					       &x, &y, out);
 	if (status == CAIRO_STATUS_SUCCESS && (x != 0 || y != 0)) {
-	    cairo_matrix_t m;
+	    if (_cairo_matrix_is_identity (&attr->matrix)) {
+		attr->x_offset -= x;
+		attr->y_offset -= y;
+	    } else {
+		cairo_matrix_t m;
 
-	    cairo_matrix_init_translate (&m, -x, -y);
-	    cairo_matrix_multiply (&attr->matrix, &attr->matrix, &m);
+		x -= attr->x_offset;
+		y -= attr->y_offset;
+		attr->x_offset = 0;
+		attr->y_offset = 0;
+
+		cairo_matrix_init_translate (&m, -x, -y);
+		cairo_matrix_multiply (&attr->matrix, &attr->matrix, &m);
+	    }
 	}
     }
 
commit 552cc09e6be2b704dc32f986c84640d50316c25c
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Oct 7 21:05:57 2008 +0100

    [xlib] Check integer translation for XCopyArea.
    
    A precondition for using the core XCopyArea protocol is that the source
    attributes contain only integer translations. However, we failed to apply
    any integer translations from the source matrix to the XCopyArea offsets.
    This worked prior to 5b97ee6525 as
    _cairo_pattern_acquire_surface_for_surface() was careful to only generate
    an identity matrix if the pattern matrix only contained an integer
    translation (and thus we would use XCopyArea in the xlib backend).

diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 0b01762..4f526c1 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -1741,12 +1741,18 @@ _cairo_xlib_surface_composite (cairo_operator_t		op,
 	status = _cairo_xlib_surface_ensure_gc (dst);
 	if (status)
 	    goto BAIL;
+
+	is_integer_translation = _cairo_matrix_is_integer_translation (&src_attr.matrix,
+								       &itx, &ity);
+	/* This is a pre-condition for DO_XCOPYAREA. */
+	assert (is_integer_translation);
+
 	XCopyArea (dst->dpy,
 		   src->drawable,
 		   dst->drawable,
 		   dst->gc,
-		   src_x + src_attr.x_offset,
-		   src_y + src_attr.y_offset,
+		   src_x + src_attr.x_offset + itx,
+		   src_y + src_attr.y_offset + ity,
 		   width, height,
 		   dst_x, dst_y);
 	break;


More information about the cairo-commit mailing list