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

Chris Wilson ickle at kemper.freedesktop.org
Thu Oct 21 04:18:41 PDT 2010


 src/cairo-xcb-surface-render.c |   84 +++++++++++++++++++++++++----------------
 1 file changed, 52 insertions(+), 32 deletions(-)

New commits:
commit fae88051c18722566d15b96a1b23bfde1844c3ee
Author: Uli Schlachter <psychon at znc.in>
Date:   Sun Oct 17 17:47:22 2010 +0200

    XCB: Use consistent rounding modes for a1 rasterisation.
    
    This ports commits 36b4b0631 and 7ab9ce1b9 from the image backend to xcb. Look
    there for an explanation of why this is correct, I only copied this over and the
    test suite said it was good. :-)
    
    This fixes unantialiased-shapes, a1-rasterisation-rectangles and
    a1-rasterisation-triangles.
    
    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 e98148a..f7db491 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -1489,10 +1489,10 @@ _render_fill_boxes (void			*abstract_dst,
 	int i, j;
 
 	for (i = j = 0; i < chunk->count; i++) {
-	    int x1 = _cairo_fixed_integer_round (chunk->base[i].p1.x);
-	    int y1 = _cairo_fixed_integer_round (chunk->base[i].p1.y);
-	    int x2 = _cairo_fixed_integer_round (chunk->base[i].p2.x);
-	    int y2 = _cairo_fixed_integer_round (chunk->base[i].p2.y);
+	    int x1 = _cairo_fixed_integer_round_down (chunk->base[i].p1.x);
+	    int y1 = _cairo_fixed_integer_round_down (chunk->base[i].p1.y);
+	    int x2 = _cairo_fixed_integer_round_down (chunk->base[i].p2.x);
+	    int y2 = _cairo_fixed_integer_round_down (chunk->base[i].p2.y);
 
 	    if (x2 > x1 && y2 > y1) {
 		xrects[j].x = x1;
@@ -1552,10 +1552,10 @@ _render_composite_boxes (cairo_xcb_surface_t	*dst,
 	    int i;
 
 	    for (i = 0; i < chunk->count; i++) {
-		int x = _cairo_fixed_integer_round (box[i].p1.x);
-		int y = _cairo_fixed_integer_round (box[i].p1.y);
-		int width  = _cairo_fixed_integer_round (box[i].p2.x) - x;
-		int height = _cairo_fixed_integer_round (box[i].p2.y) - y;
+		int x = _cairo_fixed_integer_round_down (box[i].p1.x);
+		int y = _cairo_fixed_integer_round_down (box[i].p1.y);
+		int width  = _cairo_fixed_integer_round_down (box[i].p2.x) - x;
+		int height = _cairo_fixed_integer_round_down (box[i].p2.y) - y;
 
 		if (width && height) {
 		    _cairo_xcb_connection_render_composite (dst->connection,
@@ -1580,10 +1580,10 @@ _render_composite_boxes (cairo_xcb_surface_t	*dst,
 	    int i;
 
 	    for (i = 0; i < chunk->count; i++) {
-		int x = _cairo_fixed_integer_round (box[i].p1.x);
-		int y = _cairo_fixed_integer_round (box[i].p1.y);
-		int width  = _cairo_fixed_integer_round (box[i].p2.x) - x;
-		int height = _cairo_fixed_integer_round (box[i].p2.y) - y;
+		int x = _cairo_fixed_integer_round_down (box[i].p1.x);
+		int y = _cairo_fixed_integer_round_down (box[i].p1.y);
+		int width  = _cairo_fixed_integer_round_down (box[i].p2.x) - x;
+		int height = _cairo_fixed_integer_round_down (box[i].p2.y) - y;
 
 		if (width && height) {
 		    _cairo_xcb_connection_render_composite (dst->connection,
@@ -2817,7 +2817,7 @@ _clip_and_composite_boxes (cairo_xcb_surface_t *dst,
 static cairo_bool_t
 _mono_edge_is_vertical (const cairo_line_t *line)
 {
-    return _cairo_fixed_integer_round (line->p1.x) == _cairo_fixed_integer_round (line->p2.x);
+    return _cairo_fixed_integer_round_down (line->p1.x) == _cairo_fixed_integer_round_down (line->p2.x);
 }
 
 static cairo_bool_t
@@ -2855,7 +2855,8 @@ _traps_are_pixel_aligned (cairo_traps_t *traps,
 
 static void
 _boxes_for_traps (cairo_boxes_t *boxes,
-		  cairo_traps_t *traps)
+		  cairo_traps_t *traps,
+		  cairo_antialias_t antialias)
 {
     int i;
 
@@ -2866,21 +2867,40 @@ _boxes_for_traps (cairo_boxes_t *boxes,
     boxes->chunks.count = traps->num_traps;
     boxes->chunks.size  = traps->num_traps;
 
-    for (i = 0; i < traps->num_traps; i++) {
-	cairo_fixed_t x1 = traps->traps[i].left.p1.x;
-	cairo_fixed_t x2 = traps->traps[i].right.p1.x;
-	cairo_fixed_t y1 = traps->traps[i].top;
-	cairo_fixed_t y2 = traps->traps[i].bottom;
-
-	boxes->chunks.base[i].p1.x = x1;
-	boxes->chunks.base[i].p1.y = y1;
-	boxes->chunks.base[i].p2.x = x2;
-	boxes->chunks.base[i].p2.y = y2;
-
-	if (boxes->is_pixel_aligned) {
-	    boxes->is_pixel_aligned =
-		_cairo_fixed_is_integer (x1) && _cairo_fixed_is_integer (y1) &&
-		_cairo_fixed_is_integer (x2) && _cairo_fixed_is_integer (y2);
+    if (antialias != CAIRO_ANTIALIAS_NONE) {
+	for (i = 0; i < traps->num_traps; i++) {
+	    /* Note the traps and boxes alias so we need to take the local copies first. */
+	    cairo_fixed_t x1 = traps->traps[i].left.p1.x;
+	    cairo_fixed_t x2 = traps->traps[i].right.p1.x;
+	    cairo_fixed_t y1 = traps->traps[i].top;
+	    cairo_fixed_t y2 = traps->traps[i].bottom;
+
+	    boxes->chunks.base[i].p1.x = x1;
+	    boxes->chunks.base[i].p1.y = y1;
+	    boxes->chunks.base[i].p2.x = x2;
+	    boxes->chunks.base[i].p2.y = y2;
+
+	    if (boxes->is_pixel_aligned) {
+		boxes->is_pixel_aligned =
+		    _cairo_fixed_is_integer (x1) && _cairo_fixed_is_integer (y1) &&
+		    _cairo_fixed_is_integer (x2) && _cairo_fixed_is_integer (y2);
+	    }
+	}
+    } else {
+	boxes->is_pixel_aligned = TRUE;
+
+	for (i = 0; i < traps->num_traps; i++) {
+	    /* Note the traps and boxes alias so we need to take the local copies first. */
+	    cairo_fixed_t x1 = traps->traps[i].left.p1.x;
+	    cairo_fixed_t x2 = traps->traps[i].right.p1.x;
+	    cairo_fixed_t y1 = traps->traps[i].top;
+	    cairo_fixed_t y2 = traps->traps[i].bottom;
+
+	    /* round down here to match Pixman's behavior when using traps. */
+	    boxes->chunks.base[i].p1.x = _cairo_fixed_round_down (x1);
+	    boxes->chunks.base[i].p1.y = _cairo_fixed_round_down (y1);
+	    boxes->chunks.base[i].p2.x = _cairo_fixed_round_down (x2);
+	    boxes->chunks.base[i].p2.y = _cairo_fixed_round_down (y2);
 	}
     }
 }
@@ -3316,7 +3336,7 @@ _cairo_xcb_surface_render_composite_polygon (cairo_xcb_surface_t *dst,
     {
 	cairo_boxes_t boxes;
 
-	_boxes_for_traps (&boxes, &traps.traps);
+	_boxes_for_traps (&boxes, &traps.traps, antialias);
 	status = _clip_and_composite_boxes (dst, op, source,
 					    &boxes, antialias,
 					    extents, clip);
commit b80bcf66b284deeb4d44d68a860a1e7857136982
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Oct 14 20:38:35 2010 +0200

    XCB: Fix for all unbounded operators
    
    _cairo_xcb_surface_fixup_unbounded_boxes() calculated a list of boxes that it
    has to clear to make an unbounded operator work correctly. Then it cleared the
    boxes that were drawn instead of clearing the list of boxes that it has to
    clear.
    
    The reason that this wasn't noticed before is that there is an optimization in
    case we have only one box instead of a whole list of boxes. This hid the bug.
    
    This fixes the "unbounded-operator" test case.
    
    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 7258c59..e98148a 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -2331,7 +2331,7 @@ _cairo_xcb_surface_fixup_unbounded_boxes (cairo_xcb_surface_t *dst,
 	status = _render_fill_boxes (dst,
 				     CAIRO_OPERATOR_CLEAR,
 				     CAIRO_COLOR_TRANSPARENT,
-				     boxes);
+				     &clear);
     }
 
     _cairo_boxes_fini (&clear);
commit 4465ff779aae506194e8bf0a649947ee67bbc5fc
Author: Uli Schlachter <psychon at znc.in>
Date:   Thu Oct 14 18:12:39 2010 +0200

    XCB: Move the assert from 5a0f8f7320c916c
    
    Calling _cairo_xcb_surface_ensure_picture() on a XCB surface whose fallback
    member is non-null is always an error. It's possible that the surface first gets
    a picture assigned and later it's fallback member is set. In this situation,
    it's still wrong to use the surface's picture for any drawing-
    
    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 8a6aa28..7258c59 100644
--- a/src/cairo-xcb-surface-render.c
+++ b/src/cairo-xcb-surface-render.c
@@ -300,8 +300,8 @@ _cairo_xcb_surface_clear_clip_region (cairo_xcb_surface_t *surface)
 static void
 _cairo_xcb_surface_ensure_picture (cairo_xcb_surface_t *surface)
 {
+    assert (surface->fallback == NULL);
     if (surface->picture == XCB_NONE) {
-	assert (surface->fallback == NULL);
 	surface->picture = _cairo_xcb_connection_get_xid (surface->connection);
 	_cairo_xcb_connection_render_create_picture (surface->connection,
 						     surface->picture,


More information about the cairo-commit mailing list