[cairo-commit] 8 commits - build/configure.ac.analysis src/cairo-path-in-fill.c src/cairo-pattern.c test/in-fill-trapezoid.c util/cairo-script util/cairo-trace

Chris Wilson ickle at kemper.freedesktop.org
Mon May 25 14:15:13 PDT 2009


 build/configure.ac.analysis              |   37 ++++++++------
 src/cairo-path-in-fill.c                 |   10 ++--
 src/cairo-pattern.c                      |   21 +++++++-
 test/in-fill-trapezoid.c                 |   77 ++++++++++++++++++++++---------
 util/cairo-script/cairo-script-hash.c    |    7 ++
 util/cairo-script/cairo-script-objects.c |    4 -
 util/cairo-trace/cairo-trace.in          |    2 
 util/cairo-trace/trace.c                 |    4 -
 8 files changed, 111 insertions(+), 51 deletions(-)

New commits:
commit 7dbc2fe80a4fe0dcee4a293e47ab6edcefc24e18
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 20:36:34 2009 +0100

    [script] Simplify _dictionary_name_equal
    
    Just a simple return TRUE since all necessary checking is performed by
    _csi_hash_table_lookup().

diff --git a/util/cairo-script/cairo-script-objects.c b/util/cairo-script/cairo-script-objects.c
index 2e81df4..84398f1 100644
--- a/util/cairo-script/cairo-script-objects.c
+++ b/util/cairo-script/cairo-script-objects.c
@@ -194,9 +194,7 @@ csi_boolean_new (csi_t *ctx,
 static cairo_bool_t
 _dictionary_name_equal (const void *_a, const void *_b)
 {
-    const csi_dictionary_entry_t *a = _a;
-    const csi_dictionary_entry_t *b = _b;
-    return a->hash_entry.hash == b->hash_entry.hash;
+    return TRUE;
 }
 
 csi_status_t
commit 0b5e92e66be94ce7cc9c31e911f23c4cb7ec77af
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 19:56:57 2009 +0100

    [script] Check hash value between comparing keys

diff --git a/util/cairo-script/cairo-script-hash.c b/util/cairo-script/cairo-script-hash.c
index 4fa9e49..6745111 100644
--- a/util/cairo-script/cairo-script-hash.c
+++ b/util/cairo-script/cairo-script-hash.c
@@ -279,7 +279,7 @@ _csi_hash_table_lookup (csi_hash_table_t *hash_table,
     entry = &hash_table->entries[idx];
 
     if (ENTRY_IS_LIVE (*entry)) {
-	if (hash_table->keys_equal (key, *entry))
+	if ((*entry)->hash == key->hash && hash_table->keys_equal (key, *entry))
 	    return *entry;
     } else if (ENTRY_IS_FREE (*entry))
 	return NULL;
@@ -295,8 +295,11 @@ _csi_hash_table_lookup (csi_hash_table_t *hash_table,
 
 	entry = &hash_table->entries[idx];
 	if (ENTRY_IS_LIVE (*entry)) {
-	    if (hash_table->keys_equal (key, *entry))
+	    if ((*entry)->hash == key->hash &&
+		hash_table->keys_equal (key, *entry))
+	    {
 		return *entry;
+	    }
 	} else if (ENTRY_IS_FREE (*entry))
 	    return NULL;
     } while (++i < table_size);
commit a364f71194aa2ea92071662f156c9b2a4d9211b4
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 21:25:27 2009 +0100

    [trace] Set output location using pwd
    
    Record the current working directory and pass that along to cairo-trace so
    that the trace output is local to the user and not the application. This
    is vital if the application is called via a script that changes directory.

diff --git a/util/cairo-trace/cairo-trace.in b/util/cairo-trace/cairo-trace.in
index 6660ff8..bf17217 100644
--- a/util/cairo-trace/cairo-trace.in
+++ b/util/cairo-trace/cairo-trace.in
@@ -86,7 +86,7 @@ if test -n "$flush"; then
 fi
 
 if test -z "$nofile"; then
-    CAIRO_TRACE_OUTDIR=. "$@"
+    CAIRO_TRACE_OUTDIR=`pwd` "$@"
 else
     CAIRO_TRACE_FD=3 "$@" 3>&1 >/dev/null
 fi
commit a76e09ea656faa63fbfa159e8f52c9c9ec7d35c6
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 21:22:43 2009 +0100

    [trace] Missing newlines in error messages.

diff --git a/util/cairo-trace/trace.c b/util/cairo-trace/trace.c
index 4a7096d..4826e99 100644
--- a/util/cairo-trace/trace.c
+++ b/util/cairo-trace/trace.c
@@ -703,7 +703,7 @@ _init_logfile (void)
 	int fd = atoi (filename);
 	logfile = fdopen (fd, "w");
 	if (logfile == NULL) {
-	    fprintf (stderr, "Failed to open trace file descriptor '%s': %s",
+	    fprintf (stderr, "Failed to open trace file descriptor '%s': %s\n",
 		       filename, strerror (errno));
 	    return false;
 	}
@@ -730,7 +730,7 @@ _init_logfile (void)
 
     logfile = fopen (filename, "wb");
     if (logfile == NULL) {
-	fprintf (stderr, "Failed to open trace file '%s': %s",
+	fprintf (stderr, "Failed to open trace file '%s': %s\n",
 		   filename, strerror (errno));
 	return false;
     }
commit b7f199fde25c960bf87302d5e868a7c2dffa4f5d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 12:40:35 2009 +0100

    [pattern] Trim REPEAT source size when applicable.
    
    Some backends are quite constrained with surface sizes and so trigger
    fallbacks when asked to clone large images. To avoid this we attempt
    to trim ROIs (as these are often limited to the destination image, and
    so can be accommodated by the hardware). This patch allows trimming
    REPEAT sources both horizontally and vertically independently.

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 49187c4..654989f 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -1972,13 +1972,28 @@ _cairo_pattern_acquire_surface_for_surface (const cairo_surface_pattern_t   *pat
 	/* Never acquire a larger area than the source itself */
 	is_empty = _cairo_rectangle_intersect (&extents, &sampled_area);
     } else {
+	int trim = 0;
+
 	if (sampled_area.x >= extents.x &&
-	    sampled_area.y >= extents.y &&
-	    sampled_area.x + (int) sampled_area.width <= extents.x + (int) extents.width &&
+	    sampled_area.x + (int) sampled_area.width <= extents.x + (int) extents.width)
+	{
+	    /* source is horizontally contained within extents, trim */
+	    extents.x = sampled_area.x;
+	    extents.width = sampled_area.width;
+	    trim |= 0x1;
+	}
+
+	if (sampled_area.y >= extents.y &&
 	    sampled_area.y + (int) sampled_area.height <= extents.y + (int) extents.height)
 	{
+	    /* source is vertically contained within extents, trim */
+	    extents.y = sampled_area.y;
+	    extents.height = sampled_area.height;
+	    trim |= 0x2;
+	}
+
+	if (trim == 0x3) {
 	    /* source is wholly contained within extents, drop the REPEAT */
-	    extents = sampled_area;
 	    attr->extend = CAIRO_EXTEND_NONE;
 	}
 
commit e4efc80b8e89b05afc22d74f984f4ec9012bc39b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 21:15:22 2009 +0100

    [build] Make valgrind support user-configurable
    
    As the number of places where we add valgrind client requests grows, it
    becomes imperative that we should be able to disable them with a simple
    configure time option.

diff --git a/build/configure.ac.analysis b/build/configure.ac.analysis
index f425a9a..4e8a02d 100644
--- a/build/configure.ac.analysis
+++ b/build/configure.ac.analysis
@@ -82,18 +82,25 @@ AM_CONDITIONAL(CAIRO_HAS_LCOV, test "x$cairo_has_lcov" = "xyes")
 
 dnl ===========================================================================
 dnl Check for some custom valgrind modules
-PKG_CHECK_MODULES(VALGRIND, valgrind, [
-	_save_CFLAGS="$CFLAGS"
-	_save_CPPFLAGS="$CPPFLAGS"
-	CFLAGS="$CFLAGS $VALGRIND_CFLAGS"
-	CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
-	AC_CHECK_HEADER([valgrind.h], [AC_DEFINE([HAVE_VALGRIND], [1],
-			[Define to 1 if you have Valgrind])])
-	AC_CHECK_HEADER([lockdep.h], [AC_DEFINE([HAVE_LOCKDEP], [1],
-			[Define to 1 if you have the Valgrind lockdep tool])])
-	AC_CHECK_HEADER([memfault.h], [AC_DEFINE([HAVE_MEMFAULT], [1],
-			[Define to 1 if you have the Valgrind memfault tool])])
-	CAIRO_CFLAGS="$VALGRIND_CFLAGS $CAIRO_CFLAGS"
-	CFLAGS="$_save_CFLAGS"
-	CPPFLAGS="$_save_CPPFLAGS"
-    ], AC_MSG_RESULT(no))
+AC_ARG_ENABLE(valgrind,
+  AS_HELP_STRING([--disable-valgrind],
+		 [Disable valgrind support]),
+  [use_valgrind=$enableval], [use_valgrind=yes])
+
+if test "x$use_valgrind" = "xyes"; then
+    PKG_CHECK_MODULES(VALGRIND, valgrind, [
+	    _save_CFLAGS="$CFLAGS"
+	    _save_CPPFLAGS="$CPPFLAGS"
+	    CFLAGS="$CFLAGS $VALGRIND_CFLAGS"
+	    CPPFLAGS="$CPPFLAGS $VALGRIND_CFLAGS"
+	    AC_CHECK_HEADER([valgrind.h], [AC_DEFINE([HAVE_VALGRIND], [1],
+			    [Define to 1 if you have Valgrind])])
+	    AC_CHECK_HEADER([lockdep.h], [AC_DEFINE([HAVE_LOCKDEP], [1],
+			    [Define to 1 if you have the Valgrind lockdep tool])])
+	    AC_CHECK_HEADER([memfault.h], [AC_DEFINE([HAVE_MEMFAULT], [1],
+			    [Define to 1 if you have the Valgrind memfault tool])])
+	    CAIRO_CFLAGS="$VALGRIND_CFLAGS $CAIRO_CFLAGS"
+	    CFLAGS="$_save_CFLAGS"
+	    CPPFLAGS="$_save_CPPFLAGS"
+	], AC_MSG_RESULT(no))
+fi
commit d840deb57b51236820dc8c320ecd7540973de873
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 22:11:22 2009 +0100

    [in-fill] Fix typo in on-vertex test.
    
    Eeek! Comparing point->y against in_fill->x is a bad idea.

diff --git a/src/cairo-path-in-fill.c b/src/cairo-path-in-fill.c
index d7b499c..24f43ca 100644
--- a/src/cairo-path-in-fill.c
+++ b/src/cairo-path-in-fill.c
@@ -122,11 +122,11 @@ _cairo_in_fill_add_edge (cairo_in_fill_t *in_fill,
     }
 
     /* First check whether the query is on an edge */
-    if ((p1->x == in_fill->x && p1->x == in_fill->y) ||
-	(p2->x == in_fill->x && p2->x == in_fill->y) ||
-	(! (p2->y < in_fill->y || p1->y > in_fill->y) &&
-	 ! (p1->x > in_fill->x && p2->x > in_fill->x) &&
-	 ! (p1->x < in_fill->x && p2->x < in_fill->x) &&
+    if ((p1->x == in_fill->x && p1->y == in_fill->y) ||
+	(p2->x == in_fill->x && p2->y == in_fill->y) ||
+	(! (p2->y < in_fill->y || p1->y > in_fill->y ||
+	   (p1->x > in_fill->x && p2->x > in_fill->x) ||
+	   (p1->x < in_fill->x && p2->x < in_fill->x)) &&
 	 edge_compare_for_y_against_x (p1, p2, in_fill->y, in_fill->x) == 0))
     {
 	in_fill->on_edge = TRUE;
commit cfd484cd01a77b1f91e27daccfc5f240cf7c692d
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Mon May 25 22:10:20 2009 +0100

    [test] Change test semantics to match new in-fill definition
    
    The in-fill definition has changed to include queries on the edges and
    vertices, so update the test case to match.

diff --git a/test/in-fill-trapezoid.c b/test/in-fill-trapezoid.c
index 5742968..b05f000 100644
--- a/test/in-fill-trapezoid.c
+++ b/test/in-fill-trapezoid.c
@@ -43,24 +43,24 @@ draw (cairo_t *cr, int width, int height)
     }
 
     /* rectangular boundary tests */
-    if (cairo_in_fill (cr, -10, -10)) {
-	cairo_test_log (ctx, "Error: Found top-left vertex inside rectangle\n");
+    if (! cairo_in_fill (cr, -10, -10)) {
+	cairo_test_log (ctx, "Error: Failed to find top-left vertex inside rectangle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
-    if (cairo_in_fill (cr, -10, 10)) {
-	cairo_test_log (ctx, "Error: Found bottom-left vertex inside rectangle\n");
+    if (! cairo_in_fill (cr, -10, 10)) {
+	cairo_test_log (ctx, "Error: Failed to find bottom-left vertex inside rectangle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
     if (! cairo_in_fill (cr, 10, -10)) {
 	cairo_test_log (ctx, "Error: Failed to find top-right vertex inside rectangle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
-    if (cairo_in_fill (cr, 10, 10)) {
-	cairo_test_log (ctx, "Error: Found bottom-right vertex inside rectangle\n");
+    if (! cairo_in_fill (cr, 10, 10)) {
+	cairo_test_log (ctx, "Error: Failed to find bottom-right vertex inside rectangle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
-    if (cairo_in_fill (cr, -10, 0)) {
-	cairo_test_log (ctx, "Error: Found left edge inside rectangle\n");
+    if (! cairo_in_fill (cr, -10, 0)) {
+	cairo_test_log (ctx, "Error: Failed to find left edge inside rectangle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
     if (! cairo_in_fill (cr, 0, -10)) {
@@ -71,8 +71,8 @@ draw (cairo_t *cr, int width, int height)
 	cairo_test_log (ctx, "Error: Failed to find right edge inside rectangle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
-    if (cairo_in_fill (cr, 0, 10)) {
-	cairo_test_log (ctx, "Error: Found bottom edge inside rectangle\n");
+    if (! cairo_in_fill (cr, 0, 10)) {
+	cairo_test_log (ctx, "Error: Failed to find bottom edge inside rectangle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
 
@@ -89,7 +89,7 @@ draw (cairo_t *cr, int width, int height)
     cairo_rectangle (cr, -10, -10, 20, 20);
     cairo_rectangle (cr, -5, -5, 10, 10);
     if (cairo_in_fill (cr, 0, 0)) {
-	cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular hole\n");
+	cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular eo-hole\n");
 	ret = CAIRO_TEST_FAILURE;
     }
 
@@ -98,7 +98,7 @@ draw (cairo_t *cr, int width, int height)
     cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
     cairo_arc (cr, 0, 0, 5, 0, 2 * M_PI);
     if (cairo_in_fill (cr, 0, 0)) {
-	cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
+	cairo_test_log (ctx, "Error: Found an unexpected point inside circular eo-hole\n");
 	ret = CAIRO_TEST_FAILURE;
     }
 
@@ -136,7 +136,7 @@ draw (cairo_t *cr, int width, int height)
     cairo_rectangle (cr, -10, -10, 20, 20);
     cairo_rectangle (cr, 5, -5, -10, 10);
     if (cairo_in_fill (cr, 0, 0)) {
-	cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular hole\n");
+	cairo_test_log (ctx, "Error: Found an unexpected point inside rectangular non-zero-hole\n");
 	ret = CAIRO_TEST_FAILURE;
     }
 
@@ -145,7 +145,7 @@ draw (cairo_t *cr, int width, int height)
     cairo_arc (cr, 0, 0, 10, 0, 2 * M_PI);
     cairo_arc_negative (cr, 0, 0, 5, 0, -2 * M_PI);
     if (cairo_in_fill (cr, 0, 0)) {
-	cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
+	cairo_test_log (ctx, "Error: Found an unexpected point inside circular non-zero-hole\n");
 	ret = CAIRO_TEST_FAILURE;
     }
 
@@ -163,26 +163,26 @@ draw (cairo_t *cr, int width, int height)
     cairo_arc (cr, 7.5, 0, 10, 0, 2 * M_PI);
     cairo_arc_negative (cr, 7.5, 0, 5, 0, -2 * M_PI);
     if (cairo_in_fill (cr, 7.5, 0)) {
-	cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
+	cairo_test_log (ctx, "Error: Found an unexpected point inside off-centre-x circular non-zero-hole\n");
 	ret = CAIRO_TEST_FAILURE;
     }
     cairo_new_path (cr);
     cairo_arc (cr, 0, 7.5, 10, 0, 2 * M_PI);
     cairo_arc_negative (cr, 0, 7.5, 5, 0, -2 * M_PI);
     if (cairo_in_fill (cr, 0, 7.5)) {
-	cairo_test_log (ctx, "Error: Found an unexpected point inside circular hole\n");
+	cairo_test_log (ctx, "Error: Found an unexpected point inside off-centre-y circular non-zero-hole\n");
 	ret = CAIRO_TEST_FAILURE;
     }
     cairo_new_path (cr);
     cairo_arc (cr, 15, 0, 10, 0, 2 * M_PI);
     if (! cairo_in_fill (cr, 15, 0)) {
-	cairo_test_log (ctx, "Error: Failed to find point inside circle\n");
+	cairo_test_log (ctx, "Error: Failed to find point inside off-centre-x circle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
     cairo_new_path (cr);
     cairo_arc (cr, 0, 15, 10, 0, 2 * M_PI);
     if (! cairo_in_fill (cr, 0, 15)) {
-	cairo_test_log (ctx, "Error: Failed to find point inside circle\n");
+	cairo_test_log (ctx, "Error: Failed to find point inside off-centre-y circle\n");
 	ret = CAIRO_TEST_FAILURE;
     }
 
@@ -209,12 +209,49 @@ draw (cairo_t *cr, int width, int height)
     cairo_line_to (cr, 5, 5);
     cairo_close_path (cr);
     if (cairo_in_fill (cr, 0, 0) ||
-	cairo_in_fill (cr, 10, 10) ||
+	cairo_in_fill (cr, 5, 0) ||
+	cairo_in_fill (cr, 15, 0) ||
 	cairo_in_fill (cr, 20, 0) ||
+	cairo_in_fill (cr, 0, 10) ||
+	cairo_in_fill (cr, 10, 10) ||
+	cairo_in_fill (cr, 20, 10) ||
 	cairo_in_fill (cr, 7, 2.5) ||
 	cairo_in_fill (cr, 13, 2.5))
     {
-	cairo_test_log (ctx, "Error: Found an unexpected point outside triangle\n");
+	cairo_test_log (ctx,
+			"Error: Found an unexpected point outside triangle\n"
+			"\t(0, 0) -> %s\n"
+			"\t(5, 0) -> %s\n"
+			"\t(15, 0) -> %s\n"
+			"\t(20, 0) -> %s\n"
+			"\t(0, 10) -> %s\n"
+			"\t(10, 10) -> %s\n"
+			"\t(20, 10) -> %s\n"
+			"\t(7, 2.5) -> %s\n"
+			"\t(13, 2.5) -> %s\n",
+			cairo_in_fill (cr, 0, 0) ? "inside" : "outside",
+			cairo_in_fill (cr, 5, 0) ? "inside" : "outside",
+			cairo_in_fill (cr, 15, 0) ? "inside" : "outside",
+			cairo_in_fill (cr, 20, 0) ? "inside" : "outside",
+			cairo_in_fill (cr, 0, 10) ? "inside" : "outside",
+			cairo_in_fill (cr, 10, 10) ? "inside" : "outside",
+			cairo_in_fill (cr, 20, 10) ? "inside" : "outside",
+			cairo_in_fill (cr, 7, 2.5) ? "inside" : "outside",
+			cairo_in_fill (cr, 13, 2.5) ? "inside" : "outside");
+	ret = CAIRO_TEST_FAILURE;
+    }
+    if (! cairo_in_fill (cr, 7.5, 2.5) ||
+	! cairo_in_fill (cr, 12.5, 2.5) ||
+	! cairo_in_fill (cr, 10, 5))
+    {
+	cairo_test_log (ctx,
+			"Error: Failed to find point on triangle edge\n"
+			"\t(7.5, 2.5) -> %s\n"
+			"\t(12.5, 2.5) -> %s\n"
+			"\t(10, 5) -> %s\n",
+			cairo_in_fill (cr, 7.5, 2.5) ? "inside" : "outside",
+			cairo_in_fill (cr, 12.5, 2.5) ? "inside" : "outside",
+			cairo_in_fill (cr, 10, 5) ? "inside" : "outside");
 	ret = CAIRO_TEST_FAILURE;
     }
     if (! cairo_in_fill (cr, 8, 2.5) ||


More information about the cairo-commit mailing list