[cairo-commit] 3 commits - src/cairo-surface-fallback.c test/buffer-diff.c test/buffer-diff.h test/cairo-test.c test/cairo-test-trace.c test/fallback-resolution.c test/Makefile.sources test/xlib-surface.c

Benjamin Otte company at kemper.freedesktop.org
Wed Apr 28 04:15:30 PDT 2010


 src/cairo-surface-fallback.c |   16 +++++++++++++++-
 test/Makefile.sources        |    2 +-
 test/buffer-diff.c           |    8 ++++++++
 test/buffer-diff.h           |    4 ++++
 test/cairo-test-trace.c      |    3 +--
 test/cairo-test.c            |    9 +++------
 test/fallback-resolution.c   |    3 +--
 test/xlib-surface.c          |    4 ++--
 8 files changed, 35 insertions(+), 14 deletions(-)

New commits:
commit 13914039567d5e8269fc29c51018ce172a40f2e9
Author: Benjamin Otte <otte at redhat.com>
Date:   Wed Apr 28 13:05:28 2010 +0200

    test: run xlib-expose-event test unconditionally

diff --git a/test/Makefile.sources b/test/Makefile.sources
index df6c666..bf73d8e 100644
--- a/test/Makefile.sources
+++ b/test/Makefile.sources
@@ -261,6 +261,7 @@ test_sources = \
 	user-font-proxy.c				\
 	user-font-rescale.c				\
 	xcomposite-projection.c				\
+	xlib-expose-event.c 				\
 	zero-alpha.c
 
 pthread_test_sources =					\
@@ -302,7 +303,6 @@ xcb_surface_test_sources = \
 	xcb-surface-source.c
 
 xlib_surface_test_sources = \
-	xlib-expose-event.c \
 	xlib-surface.c \
 	xlib-surface-source.c
 
commit 2ce1afa3222145e9c4f8c74a0034e0da9e93b70b
Author: Benjamin Otte <otte at redhat.com>
Date:   Wed Apr 28 12:54:54 2010 +0200

    test-suite: add image_diff_is_failure() function
    
    This cleans the code and fixes a boolean logic error where this check
    was done manually.

diff --git a/test/buffer-diff.c b/test/buffer-diff.c
index 8fc3f89..087ac45 100644
--- a/test/buffer-diff.c
+++ b/test/buffer-diff.c
@@ -252,3 +252,11 @@ image_diff (const cairo_test_context_t *ctx,
 
     return CAIRO_STATUS_SUCCESS;
 }
+
+cairo_bool_t
+image_diff_is_failure (const buffer_diff_result_t *result,
+                       unsigned int                tolerance)
+{
+  return result->pixels_changed &&
+         result->max_diff > tolerance;
+}
diff --git a/test/buffer-diff.h b/test/buffer-diff.h
index c09bc64..2cbb895 100644
--- a/test/buffer-diff.h
+++ b/test/buffer-diff.h
@@ -66,4 +66,8 @@ image_diff (const cairo_test_context_t *ctx,
 	    cairo_surface_t *surface_diff,
 	    buffer_diff_result_t *result);
 
+cairo_bool_t
+image_diff_is_failure (const buffer_diff_result_t *result,
+                       unsigned int                tolerance);
+
 #endif
diff --git a/test/cairo-test-trace.c b/test/cairo-test-trace.c
index ed81eb2..77ee84b 100644
--- a/test/cairo-test-trace.c
+++ b/test/cairo-test-trace.c
@@ -723,8 +723,7 @@ matches_reference (struct slave *slave)
 	    return FALSE;
 	}
 
-	if (slave->result.pixels_changed &&
-	    slave->result.max_diff > slave->target->error_tolerance) {
+	if (image_diff_is_failure (&slave->result, slave->target->error_tolerance)) {
 	    slave->difference = diff;
 	    return FALSE;
 	} else {
diff --git a/test/cairo-test.c b/test/cairo-test.c
index e2bc687..286df09 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -1319,8 +1319,7 @@ REPEAT:
 				  &result);
 	_xunlink (ctx, diff_png_path);
 	if (diff_status ||
-	    (result.pixels_changed &&
-	     result.max_diff > target->error_tolerance))
+            image_diff_is_failure (&result, target->error_tolerance))
 	{
 	    /* that failed, so check against the specific backend */
 	    ref_image = cairo_test_get_reference_image (ctx, ref_png_path,
@@ -1345,8 +1344,7 @@ REPEAT:
 				cairo_status_to_string (diff_status));
 		ret = CAIRO_TEST_FAILURE;
 	    }
-	    else if (result.pixels_changed &&
-		     result.max_diff > target->error_tolerance)
+	    else if (image_diff_is_failure (&result, target->error_tolerance))
 	    {
 		ret = CAIRO_TEST_FAILURE;
 
@@ -1403,8 +1401,7 @@ REPEAT:
 						  diff_image,
 						  &result);
 			if (diff_status == CAIRO_STATUS_SUCCESS &&
-			    (result.pixels_changed == 0 ||
-			     result.max_diff > target->error_tolerance))
+			    !image_diff_is_failure (&result, target->error_tolerance))
 			{
 			    ret = CAIRO_TEST_XFAILURE;
 			}
diff --git a/test/fallback-resolution.c b/test/fallback-resolution.c
index 1ffacb1..5b18a7e 100644
--- a/test/fallback-resolution.c
+++ b/test/fallback-resolution.c
@@ -234,8 +234,7 @@ check_result (cairo_test_context_t *ctx,
 	cairo_test_log (ctx, "Error: Failed to compare images: %s\n",
 			cairo_status_to_string (status));
 	ret = FALSE;
-    } else if (result.pixels_changed &&
-	       result.max_diff > target->error_tolerance)
+    } else if (image_diff_is_failure (&result, target->error_tolerance))
     {
 	ret = FALSE;
 
diff --git a/test/xlib-surface.c b/test/xlib-surface.c
index a7ff020..be44b14 100644
--- a/test/xlib-surface.c
+++ b/test/xlib-surface.c
@@ -250,9 +250,9 @@ do_test (const cairo_test_context_t *ctx,
 		    use_pixmap ?
 		    "           " :
 		    (offscreen ? ", offscreen" : ",  onscreen"),
-		    result.pixels_changed ? "FAIL" : "PASS");
+		    image_diff_is_failure (&result, 0) ? "FAIL" : "PASS");
 
-    if (result.pixels_changed)
+    if (image_diff_is_failure (&result, 0))
 	return CAIRO_TEST_FAILURE;
     else
 	return CAIRO_TEST_SUCCESS;
commit 2a91d425088cb8a93de76f2f91f32a7f23f0aecd
Author: Benjamin Otte <otte at redhat.com>
Date:   Wed Apr 28 12:26:29 2010 +0200

    fallback: Fix clip_region handling in mask creation
    
    Fixes the xlib-expose-event test.

diff --git a/src/cairo-surface-fallback.c b/src/cairo-surface-fallback.c
index 801ed56..36ff667 100644
--- a/src/cairo-surface-fallback.c
+++ b/src/cairo-surface-fallback.c
@@ -127,7 +127,7 @@ _create_composite_mask_pattern (cairo_surface_pattern_t       *mask_pattern,
 				const cairo_rectangle_int_t   *extents)
 {
     cairo_surface_t *mask;
-    cairo_region_t *clip_region = NULL;
+    cairo_region_t *clip_region = NULL, *fallback_region = NULL;
     cairo_status_t status;
     cairo_bool_t clip_surface = FALSE;
 
@@ -153,6 +153,18 @@ _create_composite_mask_pattern (cairo_surface_pattern_t       *mask_pattern,
     if (unlikely (mask->status))
 	return mask->status;
 
+    if (clip_region && (extents->x || extents->y)) {
+	fallback_region = cairo_region_copy (clip_region);
+	status = fallback_region->status;
+	if (unlikely (status))
+	    goto CLEANUP_SURFACE;
+
+	cairo_region_translate (fallback_region,
+				-extents->x,
+				-extents->y);
+	clip_region = fallback_region;
+    }
+
     status = draw_func (draw_closure, CAIRO_OPERATOR_ADD,
 			&_cairo_pattern_white.base, mask,
 			extents->x, extents->y,
@@ -167,6 +179,8 @@ _create_composite_mask_pattern (cairo_surface_pattern_t       *mask_pattern,
     _cairo_pattern_init_for_surface (mask_pattern, mask);
 
  CLEANUP_SURFACE:
+    if (fallback_region)
+        cairo_region_destroy (fallback_region);
     cairo_surface_destroy (mask);
 
     return status;


More information about the cairo-commit mailing list