[cairo-commit] 8 commits - boilerplate/cairo-boilerplate.c configure.ac src/cairo.c src/cairo-ft-font.c src/cairoint.h src/cairo-scaled-font.c src/cairo-toy-font-face.c test/cairo-test.c util/cairo-trace util/Makefile.am

Chris Wilson ickle at kemper.freedesktop.org
Sun Jun 7 11:53:58 PDT 2009


 boilerplate/cairo-boilerplate.c |    2 
 configure.ac                    |    5 +
 src/cairo-ft-font.c             |  117 +++++++++++++++++-----------------------
 src/cairo-scaled-font.c         |   23 +++++--
 src/cairo-toy-font-face.c       |   41 ++++++++------
 src/cairo.c                     |   51 ++++++++++++++++-
 src/cairoint.h                  |    9 ++-
 test/cairo-test.c               |    2 
 util/Makefile.am                |    5 +
 util/cairo-trace/cairo-trace.in |    2 
 10 files changed, 160 insertions(+), 97 deletions(-)

New commits:
commit 25c37509396a89deb644cbd6ada99137ba9d3095
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 7 19:23:04 2009 +0100

    [scaled-font] Report the original-font-face
    
    When queried with cairo_scaled_font_get_font_face() return the original
    font-face which matches the one supplied by the user, rather than the
    implementation derived face.
    
    Fixes test/font-face-get-type.

diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index e6ad968..e342eb8 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -2744,6 +2744,9 @@ cairo_scaled_font_get_font_face (cairo_scaled_font_t *scaled_font)
     if (scaled_font->status)
 	return (cairo_font_face_t*) &_cairo_font_face_nil;
 
+    if (scaled_font->original_font_face != NULL)
+	return scaled_font->original_font_face;
+
     return scaled_font->font_face;
 }
 slim_hidden_def (cairo_scaled_font_get_font_face);
commit 6d693f6bd7c629372cfb6c284ca98dc04619bfe9
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 7 18:59:36 2009 +0100

    [ft] Support font_face->get_implementation
    
    The lazy resolution of patterns was defeating the scaled_font cache as
    ft-fonts that resolved to the same unscaled font were being given different
    font-faces upon creation. We can keep the lazy resolution by simply asking
    the ft backend to create a fully resolved ft-font-face when we need to
    create a scaled-font. This font is then keyed by the resolved font-face
    and so will match all future lazily resolved identical patterns.

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index eb3aa56..2150a41 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -149,13 +149,11 @@ static cairo_status_t
 _cairo_ft_font_options_substitute (const cairo_font_options_t *options,
 				   FcPattern                  *pattern);
 
-static cairo_status_t
+static cairo_font_face_t *
 _cairo_ft_resolve_pattern (FcPattern		      *pattern,
 			   const cairo_matrix_t       *font_matrix,
 			   const cairo_matrix_t       *ctm,
-			   const cairo_font_options_t *options,
-			   cairo_ft_unscaled_font_t  **unscaled,
-			   cairo_ft_options_t	      *ft_options);
+			   const cairo_font_options_t *options);
 
 #endif
 
@@ -1533,38 +1531,40 @@ _cairo_ft_options_merge (cairo_ft_options_t *options,
 }
 
 static cairo_status_t
-_cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
-			      cairo_font_face_t		 *font_face,
-			      const cairo_matrix_t	 *font_matrix,
-			      const cairo_matrix_t	 *ctm,
-			      const cairo_font_options_t *options,
-			      cairo_ft_options_t	  ft_options,
-			      cairo_scaled_font_t       **font_out)
+_cairo_ft_font_face_scaled_font_create (void		    *abstract_font_face,
+					const cairo_matrix_t	 *font_matrix,
+					const cairo_matrix_t	 *ctm,
+					const cairo_font_options_t *options,
+					cairo_scaled_font_t       **font_out)
 {
+    cairo_ft_font_face_t *font_face = abstract_font_face;
     cairo_ft_scaled_font_t *scaled_font;
     FT_Face face;
     FT_Size_Metrics *metrics;
     cairo_font_extents_t fs_metrics;
     cairo_status_t status;
+    cairo_ft_unscaled_font_t *unscaled;
 
-    face = _cairo_ft_unscaled_font_lock_face (unscaled);
+    assert (font_face->unscaled);
+
+    face = _cairo_ft_unscaled_font_lock_face (font_face->unscaled);
     if (unlikely (face == NULL)) /* backend error */
 	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
 
-    scaled_font = malloc (sizeof(cairo_ft_scaled_font_t));
+    scaled_font = malloc (sizeof (cairo_ft_scaled_font_t));
     if (unlikely (scaled_font == NULL)) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	goto FAIL;
     }
 
+    scaled_font->unscaled = unscaled = font_face->unscaled;
     _cairo_unscaled_font_reference (&unscaled->base);
-    scaled_font->unscaled = unscaled;
 
     _cairo_font_options_init_copy (&scaled_font->ft_options.base, options);
-    _cairo_ft_options_merge (&scaled_font->ft_options, &ft_options);
+    _cairo_ft_options_merge (&scaled_font->ft_options, &font_face->ft_options);
 
     status = _cairo_scaled_font_init (&scaled_font->base,
-			              font_face,
+			              &font_face->base,
 				      font_matrix, ctm, options,
 				      &_cairo_ft_scaled_font_backend);
     if (unlikely (status))
@@ -1644,7 +1644,7 @@ _cairo_ft_scaled_font_create (cairo_ft_unscaled_font_t	 *unscaled,
     _cairo_unscaled_font_destroy (&unscaled->base);
     free (scaled_font);
   FAIL:
-    _cairo_ft_unscaled_font_unlock_face (unscaled);
+    _cairo_ft_unscaled_font_unlock_face (font_face->unscaled);
     *font_out = _cairo_scaled_font_create_in_error (status);
     return CAIRO_STATUS_SUCCESS; /* non-backend error */
 }
@@ -2294,16 +2294,13 @@ _cairo_ft_font_face_destroy (void *abstract_face)
 #endif
 }
 
-static cairo_status_t
-_cairo_ft_font_face_scaled_font_create (void                     *abstract_face,
+static cairo_font_face_t *
+_cairo_ft_font_face_get_implementation (void                     *abstract_face,
 					const cairo_matrix_t       *font_matrix,
 					const cairo_matrix_t       *ctm,
-					const cairo_font_options_t *options,
-					cairo_scaled_font_t       **scaled_font)
+					const cairo_font_options_t *options)
 {
     cairo_ft_font_face_t      *font_face = abstract_face;
-    cairo_ft_unscaled_font_t  *unscaled = NULL;
-    cairo_ft_options_t         ft_options;
 
     /* The handling of font options is different depending on how the
      * font face was created. When the user creates a font face with
@@ -2320,34 +2317,14 @@ _cairo_ft_font_face_scaled_font_create (void                     *abstract_face,
      * unscaled font.  Otherwise, use the ones stored in font_face.
      */
     if (font_face->pattern) {
-	cairo_status_t status;
-
-	status = _cairo_ft_resolve_pattern (font_face->pattern,
-					    font_matrix,
-					    ctm,
-					    options,
-					    &unscaled,
-					    &ft_options);
-	if (unlikely (status)) {
-	    /* XXX It is possible for a failure to generate the unscaled font
-	     * here could indicate that the font_face itself is broken - for
-	     * which we should propagate the error.
-	     */
-	    *scaled_font = _cairo_scaled_font_create_in_error (status);
-	    return CAIRO_STATUS_SUCCESS;
-	}
-    } else
-#endif
-    {
-	unscaled = font_face->unscaled;
-	ft_options = font_face->ft_options;
+	return _cairo_ft_resolve_pattern (font_face->pattern,
+					  font_matrix,
+					  ctm,
+					  options);
     }
+#endif
 
-    return _cairo_ft_scaled_font_create (unscaled,
-					 &font_face->base,
-					 font_matrix, ctm,
-					 options, ft_options,
-					 scaled_font);
+    return abstract_face;
 }
 
 const cairo_font_face_backend_t _cairo_ft_font_face_backend = {
@@ -2358,7 +2335,8 @@ const cairo_font_face_backend_t _cairo_ft_font_face_backend = {
     NULL,
 #endif
     _cairo_ft_font_face_destroy,
-    _cairo_ft_font_face_scaled_font_create
+    _cairo_ft_font_face_scaled_font_create,
+    _cairo_ft_font_face_get_implementation
 };
 
 #if CAIRO_HAS_FC_FONT
@@ -2573,13 +2551,11 @@ cairo_ft_font_options_substitute (const cairo_font_options_t *options,
     _cairo_ft_font_options_substitute (options, pattern);
 }
 
-static cairo_status_t
+static cairo_font_face_t *
 _cairo_ft_resolve_pattern (FcPattern		      *pattern,
 			   const cairo_matrix_t       *font_matrix,
 			   const cairo_matrix_t       *ctm,
-			   const cairo_font_options_t *font_options,
-			   cairo_ft_unscaled_font_t  **unscaled,
-			   cairo_ft_options_t	      *ft_options)
+			   const cairo_font_options_t *font_options)
 {
     cairo_status_t status;
 
@@ -2587,6 +2563,9 @@ _cairo_ft_resolve_pattern (FcPattern		      *pattern,
     FcPattern *resolved;
     cairo_ft_font_transform_t sf;
     FcResult result;
+    cairo_ft_unscaled_font_t *unscaled;
+    cairo_ft_options_t ft_options;
+    cairo_font_face_t *font_face;
 
     scale = *ctm;
     scale.x0 = scale.y0 = 0;
@@ -2595,42 +2574,48 @@ _cairo_ft_resolve_pattern (FcPattern		      *pattern,
                            &scale);
 
     status = _compute_transform (&sf, &scale);
-    if (status)
-	return status;
+    if (unlikely (status))
+	return (cairo_font_face_t *)&_cairo_font_face_nil;
 
     pattern = FcPatternDuplicate (pattern);
     if (pattern == NULL)
-	return _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	return (cairo_font_face_t *)&_cairo_font_face_nil;
 
     if (! FcPatternAddDouble (pattern, FC_PIXEL_SIZE, sf.y_scale)) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	font_face = (cairo_font_face_t *)&_cairo_font_face_nil;
 	goto FREE_PATTERN;
     }
 
     if (! FcConfigSubstitute (NULL, pattern, FcMatchPattern)) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	font_face = (cairo_font_face_t *)&_cairo_font_face_nil;
 	goto FREE_PATTERN;
     }
 
     status = _cairo_ft_font_options_substitute (font_options, pattern);
-    if (status)
+    if (status) {
+	font_face = (cairo_font_face_t *)&_cairo_font_face_nil;
 	goto FREE_PATTERN;
+    }
 
     FcDefaultSubstitute (pattern);
 
     resolved = FcFontMatch (NULL, pattern, &result);
     if (!resolved) {
-	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
+	font_face = (cairo_font_face_t *)&_cairo_font_face_nil;
 	goto FREE_PATTERN;
     }
 
-    status = _cairo_ft_unscaled_font_create_for_pattern (resolved, unscaled);
-    if (unlikely (status))
+    status = _cairo_ft_unscaled_font_create_for_pattern (resolved, &unscaled);
+    if (unlikely (status)) {
+	font_face = (cairo_font_face_t *)&_cairo_font_face_nil;
 	goto FREE_RESOLVED;
+    }
 
-    assert (*unscaled != NULL);
+    assert (unscaled != NULL);
 
-    _get_pattern_ft_options (resolved, ft_options);
+    _get_pattern_ft_options (resolved, &ft_options);
+    font_face = _cairo_ft_font_face_create (unscaled, &ft_options);
+    _cairo_unscaled_font_destroy (&unscaled->base);
 
 FREE_RESOLVED:
     FcPatternDestroy (resolved);
@@ -2638,7 +2623,7 @@ FREE_RESOLVED:
 FREE_PATTERN:
     FcPatternDestroy (pattern);
 
-    return status;
+    return font_face;
 }
 
 /**
diff --git a/src/cairo-scaled-font.c b/src/cairo-scaled-font.c
index 22f4395..e6ad968 100644
--- a/src/cairo-scaled-font.c
+++ b/src/cairo-scaled-font.c
@@ -899,12 +899,11 @@ cairo_scaled_font_create (cairo_font_face_t          *font_face,
     /* Note that degenerate ctm or font_matrix *are* allowed.
      * We want to support a font size of 0. */
 
-    if (font_face->backend->type == CAIRO_FONT_TYPE_TOY) {
-	/* indirect implementation, lookup the face that is used for the toy face */
-	font_face = _cairo_toy_font_face_get_implementation (font_face);
-
-	if (unlikely (font_face->status))
-	    return _cairo_scaled_font_create_in_error (font_face->status);
+    if (font_face->backend->get_implementation != NULL) {
+	font_face = font_face->backend->get_implementation (font_face,
+							    font_matrix,
+							    ctm,
+							    options);
     }
 
     font_map = _cairo_scaled_font_map_lock ();
@@ -1018,6 +1017,12 @@ cairo_scaled_font_create (cairo_font_face_t          *font_face,
 	return scaled_font;
     }
 
+    /* Our caching above is defeated if the backend switches fonts on us -
+     * e.g. old incarnations of toy-font-face and lazily resolved
+     * ft-font-faces
+     */
+    assert (scaled_font->font_face == font_face);
+
     scaled_font->original_font_face =
 	cairo_font_face_reference (original_font_face);
 
@@ -1043,6 +1048,9 @@ cairo_scaled_font_create (cairo_font_face_t          *font_face,
 
     cairo_scaled_font_destroy (old);
 
+    if (font_face != original_font_face)
+	cairo_font_face_destroy (font_face);
+
     return scaled_font;
 }
 slim_hidden_def (cairo_scaled_font_create);
diff --git a/src/cairo-toy-font-face.c b/src/cairo-toy-font-face.c
index b2d41af..a9b600a 100644
--- a/src/cairo-toy-font-face.c
+++ b/src/cairo-toy-font-face.c
@@ -387,26 +387,34 @@ _cairo_toy_font_face_scaled_font_create (void                *abstract_font_face
     return _cairo_font_face_set_error (&font_face->base, CAIRO_STATUS_FONT_TYPE_MISMATCH);
 }
 
-static cairo_bool_t
-_cairo_font_face_is_toy (cairo_font_face_t *font_face)
+static cairo_font_face_t *
+_cairo_toy_font_face_get_implementation (void                *abstract_font_face,
+					 const cairo_matrix_t       *font_matrix,
+					 const cairo_matrix_t       *ctm,
+					 const cairo_font_options_t *options)
 {
-    return font_face->backend == &_cairo_toy_font_face_backend;
-}
+    cairo_toy_font_face_t *font_face = abstract_font_face;
 
-cairo_font_face_t *
-_cairo_toy_font_face_get_implementation (cairo_font_face_t *font_face)
-{
-    cairo_toy_font_face_t *toy_font_face;
+    if (font_face->impl_face) {
+	cairo_font_face_t *impl = font_face->impl_face;
 
-    if (font_face->status)
-	return NULL;
+	if (impl->backend->get_implementation != NULL) {
+	    return impl->backend->get_implementation (impl,
+						      font_matrix,
+						      ctm,
+						      options);
+	}
 
-    toy_font_face = (cairo_toy_font_face_t *) font_face;
-    if (! _cairo_font_face_is_toy (font_face)) {
-	if (_cairo_font_face_set_error (font_face, CAIRO_STATUS_FONT_TYPE_MISMATCH))
-	    return NULL;
+	return cairo_font_face_reference (impl);
     }
-    return toy_font_face->impl_face ? toy_font_face->impl_face : font_face;
+
+    return abstract_font_face;
+}
+
+static cairo_bool_t
+_cairo_font_face_is_toy (cairo_font_face_t *font_face)
+{
+    return font_face->backend == &_cairo_toy_font_face_backend;
 }
 
 /**
@@ -495,7 +503,8 @@ static const cairo_font_face_backend_t _cairo_toy_font_face_backend = {
     CAIRO_FONT_TYPE_TOY,
     NULL,					/* create_for_toy */
     _cairo_toy_font_face_destroy,
-    _cairo_toy_font_face_scaled_font_create
+    _cairo_toy_font_face_scaled_font_create,
+    _cairo_toy_font_face_get_implementation
 };
 
 void
diff --git a/src/cairoint.h b/src/cairoint.h
index 81b1690..9021ebf 100644
--- a/src/cairoint.h
+++ b/src/cairoint.h
@@ -525,6 +525,12 @@ struct _cairo_font_face_backend {
 			   const cairo_matrix_t		*ctm,
 			   const cairo_font_options_t	*options,
 			   cairo_scaled_font_t	       **scaled_font);
+
+    cairo_font_face_t *
+    (*get_implementation) (void				*font_face,
+			   const cairo_matrix_t		*font_matrix,
+			   const cairo_matrix_t		*ctm,
+			   const cairo_font_options_t	*options);
 };
 
 extern const cairo_private struct _cairo_font_face_backend _cairo_user_font_face_backend;
@@ -1427,9 +1433,6 @@ _cairo_unscaled_font_reference (cairo_unscaled_font_t *font);
 cairo_private void
 _cairo_unscaled_font_destroy (cairo_unscaled_font_t *font);
 
-cairo_private cairo_font_face_t *
-_cairo_toy_font_face_get_implementation (cairo_font_face_t *font_face);
-
 /* cairo-font-face-twin.c */
 
 cairo_private cairo_status_t
commit a29426f4bffc0a3f5bb349a2ba44203394339ae8
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 7 17:24:40 2009 +0100

    [ft] Assert that we create an unscaled font for the resolved pattern

diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 50dd6de..eb3aa56 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -2628,6 +2628,8 @@ _cairo_ft_resolve_pattern (FcPattern		      *pattern,
     if (unlikely (status))
 	goto FREE_RESOLVED;
 
+    assert (*unscaled != NULL);
+
     _get_pattern_ft_options (resolved, ft_options);
 
 FREE_RESOLVED:
commit 7d8a0a1cdd62112ccdae2a80bb55ec9cec99b978
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 7 17:01:57 2009 +0100

    [cairo] Keep a small stash of cairo contexts
    
    A cairo context is meant to be extremely cheap to create such that it can
    be used in transient expose events. Thus these are allocated reasonably
    frequently and show up malloc profiles.

diff --git a/src/cairo.c b/src/cairo.c
index 0c58cfe..91b8828 100644
--- a/src/cairo.c
+++ b/src/cairo.c
@@ -117,6 +117,53 @@ _cairo_set_error (cairo_t *cr, cairo_status_t status)
     status = _cairo_error (status);
 }
 
+#if HAS_ATOMIC_OPS
+/* We keep a small stash of contexts to reduce malloc pressure */
+#define CAIRO_STASH_SIZE 4
+static struct {
+    cairo_t pool[CAIRO_STASH_SIZE];
+    int occupied;
+} _context_stash;
+
+static cairo_t *
+_context_get (void)
+{
+    int avail, old, new;
+
+    do {
+	old = _context_stash.occupied;
+	avail = ffs (~old) - 1;
+	if (avail >= CAIRO_STASH_SIZE)
+	    return malloc (sizeof (cairo_t));
+
+	new = old | (1 << avail);
+    } while (_cairo_atomic_int_cmpxchg (&_context_stash.occupied, old, new) != old);
+
+    return &_context_stash.pool[avail];
+}
+
+static void
+_context_put (cairo_t *cr)
+{
+    int old, new, avail;
+
+    if (cr < &_context_stash.pool[0] ||
+	cr >= &_context_stash.pool[CAIRO_STASH_SIZE])
+    {
+	return free (cr);
+    }
+
+    avail = ~(1 << (cr - &_context_stash.pool[0]));
+    do {
+	old = _context_stash.occupied;
+	new = old & avail;
+    } while (_cairo_atomic_int_cmpxchg (&_context_stash.occupied, old, new) != old);
+}
+#else
+#define _context_get() malloc (sizeof (cairo_t))
+#define _context_put(cr) free (cr)
+#endif
+
 /**
  * cairo_create:
  * @target: target surface for the context
@@ -150,7 +197,7 @@ cairo_create (cairo_surface_t *target)
     if (target && target->status == CAIRO_STATUS_NO_MEMORY)
 	return (cairo_t *) &_cairo_nil;
 
-    cr = malloc (sizeof (cairo_t));
+    cr = _context_get ();
     if (unlikely (cr == NULL)) {
 	status = _cairo_error (CAIRO_STATUS_NO_MEMORY);
 	return (cairo_t *) &_cairo_nil;
@@ -248,7 +295,7 @@ cairo_destroy (cairo_t *cr)
 
     _cairo_user_data_array_fini (&cr->user_data);
 
-    free (cr);
+    _context_put (cr);
 }
 slim_hidden_def (cairo_destroy);
 
commit f08fe5b550d53c93b73c6295f8a85a8dcd4a1f4a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Jun 7 15:55:20 2009 +0100

    [trace] Redirect stdout to /dev/null when compressing
    
    Otherwise we mix in stdout in with the trace and prevent replay.

diff --git a/util/cairo-trace/cairo-trace.in b/util/cairo-trace/cairo-trace.in
index 2686970..8a1e1b8 100644
--- a/util/cairo-trace/cairo-trace.in
+++ b/util/cairo-trace/cairo-trace.in
@@ -104,7 +104,7 @@ if test -z "$nofile"; then
     CAIRO_TRACE_OUTDIR=`pwd` "$@"
 elif test -n "$compress"; then
     echo Generating compressed trace file $1.$$.lzma
-    CAIRO_TRACE_FD=3 "$@" 3>&1 | lzma -cz9 > $1.$$.lzma
+    CAIRO_TRACE_FD=3 "$@" 3>&1 >/dev/null | lzma -cz9 > $1.$$.lzma
 else
     CAIRO_TRACE_FD=3 "$@" 3>&1 >/dev/null
 fi
commit 750c1b5b48dcd33ba4a4d5290c50f564bf45bc58
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jun 6 21:45:18 2009 +0100

    [configure] Check for FcInit()

diff --git a/configure.ac b/configure.ac
index b20afef..7c406e7 100644
--- a/configure.ac
+++ b/configure.ac
@@ -322,7 +322,7 @@ if test "x$use_ft" = "xyes"; then
 fi
 
 if test "x$use_fc" = "xyes"; then
-  CAIRO_CHECK_FUNCS_WITH_FLAGS(FcFini, [$FONTCONFIG_CFLAGS], [$FONTCONFIG_LIBS])
+  CAIRO_CHECK_FUNCS_WITH_FLAGS(FcInit FcFini, [$FONTCONFIG_CFLAGS], [$FONTCONFIG_LIBS])
 fi
 
 dnl ===========================================================================
diff --git a/test/cairo-test.c b/test/cairo-test.c
index 4e3d2fb..758a352 100644
--- a/test/cairo-test.c
+++ b/test/cairo-test.c
@@ -747,7 +747,9 @@ REPEAT:
     /* Pre-initialise fontconfig so that the configuration is loaded without
      * malloc failures (our primary goal is to test cairo fault tolerance).
      */
+#if HAVE_FCINIT
     FcInit ();
+#endif
 
     MEMFAULT_ENABLE_FAULTS ();
 #endif
commit f7a562a590493904cf10b4fb9af3b42fb3f8a3a2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jun 6 14:58:46 2009 +0100

    [configure] Don't attempt to build GTK+ utilities on system without GTK+

diff --git a/configure.ac b/configure.ac
index 5856f59..b20afef 100644
--- a/configure.ac
+++ b/configure.ac
@@ -537,7 +537,8 @@ fi
 dnl ===========================================================================
 
 # We use GTK+ for some utility/debugging tools
-PKG_CHECK_MODULES(gtk, "gtk+-2.0",, AC_MSG_RESULT(no))
+PKG_CHECK_MODULES(gtk, "gtk+-2.0",have_gtk=yes, have_gtk=no)
+AM_CONDITIONAL(HAVE_GTK, test "x$have_gtk" = "xyes")
 
 SHAVE_INIT([build], [enable]) # dnl Make the output pretty
 
diff --git a/util/Makefile.am b/util/Makefile.am
index 103bc71..ca25951 100644
--- a/util/Makefile.am
+++ b/util/Makefile.am
@@ -24,10 +24,13 @@ backtrace_symbols_la_LIBADD  = -lbfd -liberty
 
 #malloc_stats_la_LIBADD  = $(backtrace_symbols_la_LIBADD) backtrace-symbols.lo
 
-noinst_PROGRAMS = font-view
+noinst_PROGRAMS =
 
+if HAVE_GTK
+noinst_PROGRAMS += font-view
 font_view_CFLAGS = $(gtk_CFLAGS)
 font_view_LDADD = ../src/libcairo.la $(gtk_LIBS)
+endif
 
 EXTRA_DIST += \
 	COPYING \
commit 7a95b2745ae619f6ca4631f3cdb03e12203126f3
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sat Jun 6 21:36:08 2009 +0100

    [boilerplate] Minor typo in win32-printing

diff --git a/boilerplate/cairo-boilerplate.c b/boilerplate/cairo-boilerplate.c
index da2a618..fb8897e 100644
--- a/boilerplate/cairo-boilerplate.c
+++ b/boilerplate/cairo-boilerplate.c
@@ -490,7 +490,7 @@ static cairo_boilerplate_target_t targets[] =
 	NULL, TRUE, TRUE
     },
     {
-	"win32-printing", "win32"".ps",
+	"win32-printing", "win32", ".ps",
 	CAIRO_INTERNAL_SURFACE_TYPE_META, CAIRO_CONTENT_COLOR, 0,
 	_cairo_boilerplate_win32_printing_create_surface, NULL,
 	NULL,


More information about the cairo-commit mailing list