[cairo-commit] 6 commits - configure.in NEWS

Carl Worth cworth at kemper.freedesktop.org
Fri Apr 11 10:08:33 PDT 2008


 NEWS         |   35 +++++++++++++++++++++++++++++++++++
 configure.in |    4 ++--
 2 files changed, 37 insertions(+), 2 deletions(-)

New commits:
commit 75001079c1c6361f116409dc13263e87081637d1
Merge: a5770c3... f57100a...
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 11 10:08:14 2008 -0700

    Merge in origin/master, (a few changes in parallel to 1.6.2 release)

commit a5770c3335fccd1591f2cd58ab950a6eba77f271
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 11 10:05:18 2008 -0700

    Increment version to 1.6.3 after the 1.6.2 release

diff --git a/configure.in b/configure.in
index c8d4ecf..065ff31 100644
--- a/configure.in
+++ b/configure.in
@@ -7,7 +7,7 @@ dnl For the micro number: odd => in-progress development (from git)
 dnl			  even => tar-file snapshot or release
 m4_define(cairo_version_major, 1)
 m4_define(cairo_version_minor, 6)
-m4_define(cairo_version_micro, 2)
+m4_define(cairo_version_micro, 3)
 
 AC_INIT([cairo],
       cairo_version_major.cairo_version_minor.cairo_version_micro,
commit 5bc6fd71398f8aa902fcffe2da5d1e70fb94aa8a
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 11 09:52:28 2008 -0700

    Increment version to 1.6.2

diff --git a/configure.in b/configure.in
index 1810851..c8d4ecf 100644
--- a/configure.in
+++ b/configure.in
@@ -7,7 +7,7 @@ dnl For the micro number: odd => in-progress development (from git)
 dnl			  even => tar-file snapshot or release
 m4_define(cairo_version_major, 1)
 m4_define(cairo_version_minor, 6)
-m4_define(cairo_version_micro, 1)
+m4_define(cairo_version_micro, 2)
 
 AC_INIT([cairo],
       cairo_version_major.cairo_version_minor.cairo_version_micro,
@@ -30,7 +30,7 @@ LT_CURRENT=19
 
 # Increment any time the source changes; set to
 # 0 if you increment CURRENT
-LT_REVISION=3
+LT_REVISION=4
 
 # Increment if any interfaces have been added; set to 0
 # if any interfaces have been removed. removal has
commit 0c32497c3447d6d02d45a14ff4c400b6d1ea37da
Author: Carl Worth <cworth at cworth.org>
Date:   Fri Apr 11 09:50:53 2008 -0700

    NEWS: Add notes for 1.6.2 release

diff --git a/NEWS b/NEWS
index 589b270..4b34a30 100644
--- a/NEWS
+++ b/NEWS
@@ -1,3 +1,38 @@
+Release 1.6.2 (2008-04-11 Carl Worth <cworth at cworth.org>)
+=========================================================
+The cairo community is pleased (but somewhat sheepish) to announce the
+1.6.2 release of the cairo graphics library. This is an update to
+yesterday's 1.6.0 release with an important fix to prevent cairo's
+PostScript output from crashing some printers. This release also
+includes a locking fix for cairo's xlib backend to improve thread
+safety. There are no changes beyond these two fixes.
+
+Fix for PostScript printer crash
+--------------------------------
+Adrian Johnson discovered that cairo 1.6.0 was being a bit hard on
+PostScript printers, by changing the font matrix very frequently. This
+causes some PostScript interpreters to allocate new font objects every
+few glyphs, eventually exhausting available resources. The fix
+involves leaving translational components of the font matrix as zero,
+so that the PostScript interpreter sees an identical font matrix
+repeatedly, and can more easily share internal font object resources.
+
+This fix has been tested to resolve the bugs posted here, (for both
+Xerox and Dell printers):
+
+	Printing some PDFs from evince is crashing our Xerox printer
+	http://bugs.freedesktop.org/show_bug.cgi?id=15348
+
+	Cairo-generated postscript blocks Dell 5100cn
+	http://bugs.freedesktop.org/show_bug.cgi?id=15445
+
+Add missing locking in cairo-xlib
+---------------------------------
+Chris Wilson noticed that cairo 1.6.0 was manipulating an internal
+cache of GC object within cairo's Xlib backend without proper
+locking. The missing locking could cause failures for multi-threaded
+applications. He fixed this in 1.6.2 by adding the missing locks.
+
 Release 1.6.0 (2008-04-10 Carl Worth <cworth at cworth.org>)
 =========================================================
 The cairo community is quite pleased to announce the 1.6.0 release of
commit 9cfd82e87b60c0d65e9cafda026cb9a498874575
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Apr 10 14:49:47 2008 +0100

    [xlib] Add locking around GC cache.
    
    The per-screen cached of most-recently freed GCs lacks suitable locking
    for it to be threadsafe.
    (cherry picked from commit dc714106e156cb7901e376c0935922446ae9bcdf)

diff --git a/src/cairo-xlib-private.h b/src/cairo-xlib-private.h
index 5bfc2ec..2d9737d 100644
--- a/src/cairo-xlib-private.h
+++ b/src/cairo-xlib-private.h
@@ -79,6 +79,7 @@ typedef struct _cairo_xlib_visual_info {
 struct _cairo_xlib_screen_info {
     cairo_xlib_screen_info_t *next;
     cairo_reference_count_t ref_count;
+    cairo_mutex_t mutex;
 
     cairo_xlib_display_t *display;
     Screen *screen;
diff --git a/src/cairo-xlib-screen.c b/src/cairo-xlib-screen.c
index 8a3da66..fc07fda 100644
--- a/src/cairo-xlib-screen.c
+++ b/src/cairo-xlib-screen.c
@@ -256,12 +256,14 @@ _cairo_xlib_screen_info_close_display (cairo_xlib_screen_info_t *info)
 {
     int i;
 
+    CAIRO_MUTEX_LOCK (info->mutex);
     for (i = 0; i < ARRAY_LENGTH (info->gc); i++) {
 	if (info->gc[i] != NULL) {
 	    XFreeGC (info->display->display, info->gc[i]);
 	    info->gc[i] = NULL;
 	}
     }
+    CAIRO_MUTEX_UNLOCK (info->mutex);
 }
 
 void
@@ -295,6 +297,8 @@ _cairo_xlib_screen_info_destroy (cairo_xlib_screen_info_t *info)
 
     _cairo_array_fini (&info->visuals);
 
+    CAIRO_MUTEX_FINI (info->mutex);
+
     free (info);
 }
 
@@ -335,6 +339,7 @@ _cairo_xlib_screen_info_get (Display *dpy, Screen *screen)
 	info = malloc (sizeof (cairo_xlib_screen_info_t));
 	if (info != NULL) {
 	    CAIRO_REFERENCE_COUNT_INIT (&info->ref_count, 2); /* Add one for display cache */
+	    CAIRO_MUTEX_INIT (info->mutex);
 	    info->display = _cairo_xlib_display_reference (display);
 	    info->screen = screen;
 	    info->has_render = FALSE;
@@ -385,16 +390,18 @@ GC
 _cairo_xlib_screen_get_gc (cairo_xlib_screen_info_t *info, int depth)
 {
     GC gc;
+    cairo_bool_t needs_reset;
 
     depth = depth_to_index (depth);
 
+    CAIRO_MUTEX_LOCK (info->mutex);
     gc = info->gc[depth];
     info->gc[depth] = NULL;
+    needs_reset = info->gc_needs_clip_reset & (1 << depth);
+    CAIRO_MUTEX_UNLOCK (info->mutex);
 
-    if (info->gc_needs_clip_reset & (1 << depth)) {
+    if (needs_reset)
 	XSetClipMask(info->display->display, gc, None);
-	info->gc_needs_clip_reset &= ~(1 << depth);
-    }
 
     return gc;
 }
@@ -403,21 +410,25 @@ cairo_status_t
 _cairo_xlib_screen_put_gc (cairo_xlib_screen_info_t *info, int depth, GC gc, cairo_bool_t reset_clip)
 {
     cairo_status_t status = CAIRO_STATUS_SUCCESS;
+    GC oldgc;
 
     depth = depth_to_index (depth);
 
-    if (info->gc[depth] != NULL) {
-	status = _cairo_xlib_display_queue_work (info->display,
-		                               (cairo_xlib_notify_func) XFreeGC,
-					       info->gc[depth],
-					       NULL);
-    }
-
+    CAIRO_MUTEX_LOCK (info->mutex);
+    oldgc = info->gc[depth];
     info->gc[depth] = gc;
     if (reset_clip)
 	info->gc_needs_clip_reset |= 1 << depth;
     else
 	info->gc_needs_clip_reset &= ~(1 << depth);
+    CAIRO_MUTEX_UNLOCK (info->mutex);
+
+    if (oldgc != NULL) {
+	status = _cairo_xlib_display_queue_work (info->display,
+		                               (cairo_xlib_notify_func) XFreeGC,
+					       oldgc,
+					       NULL);
+    }
 
     return status;
 }
commit cf057c1e8603014033c079189369e91aecac2adf
Author: Adrian Johnson <ajohnson at redneon.com>
Date:   Fri Apr 11 21:42:19 2008 +0930

    PS: Fix inefficient implementation of Tm/Td operators that was crashing printers
    
    The Td and Tm operator emulation were setting the font matrix like this:
    
      /some_font [xx yx xy yy x0 y0] selectfont
    
    where [xx yx xy yy] is the font matrix and [x0 y0] is the position of
    the first glyph to be drawn. This seemed to be the easiest way to
    emulate the Tm operator since the six arguments to Tm required by PDF
    are xx,yx,xy,yy,x0,y0.
    
    Before the switch to pdf-operators the font matrix was set like this:
    
      /somefont [xx yx xy yy 0 0] selectfont x0 y0 moveto
    
    The selectfont operator is equivalent to calling findfont, makefont,
    and setfont. The makefont operator creates a new font dictionary for
    specified font that contains the specified font matrix. The
    description of the makefont operator in the PostScript Language
    Reference Manual states:
    
      "The interpreter keeps track of font dictionaries recently created
       by makefont. Calling makefont multiple times with the same font and
       matrix will usually return the same font rather than create a new
       one."
    
    So the emulation of Tm and Td was creating a new font dictionary every
    time a text string was displayed due to the change in the translation
    components of the font matrix. Previously the font dictionary was
    re-used as with the translation components of the matrix set to zero,
    the font matrix did not change frequently.
    
    Some printers did not handle well the frequent creation a font
    dictionary every time a few glyphs were displayed.
    
    Fix this by ensuring the translation components of the font matrix
    used in the emulation of Tm and Td operators is always set to
    zero. Use moveto instead for the translation components.
    (cherry picked from commit c5814d2aa3cb68a13bc9cc8b6a47f660febcad71)

diff --git a/src/cairo-ps-surface.c b/src/cairo-ps-surface.c
index 54f5afe..f6940bf 100644
--- a/src/cairo-ps-surface.c
+++ b/src/cairo-ps-surface.c
@@ -183,10 +183,11 @@ _cairo_ps_surface_emit_header (cairo_ps_surface_t *surface)
 				 "    { show } { -0.001 mul 0 cairo_font_matrix dtransform rmoveto } ifelse\n"
 				 "  } forall\n"
 				 "} bind def\n"
-				 "/Td { matrix translate cairo_font_matrix matrix concatmatrix dup\n"
-				 "   /cairo_font_matrix exch def cairo_font exch selectfont 0 0 moveto } bind def\n"
-				 "/Tm { 6 array astore dup /cairo_font_matrix exch def\n"
-				 "      cairo_font exch selectfont 0 0 moveto } bind def\n"
+				 "/Td { matrix translate cairo_font_matrix matrix concatmatrix aload\n"
+				 "      /cairo_font_matrix exch def 6 2 roll 0 0 6 array astore\n"
+				 "      cairo_font exch selectfont moveto } bind def\n"
+				 "/Tm { 6 copy 6 array astore /cairo_font_matrix exch def 6 2 roll 0 0\n"
+				 "      6 array astore cairo_font exch selectfont moveto } bind def\n"
 				 "/g { setgray } bind def\n"
 				 "/rg { setrgbcolor } bind def\n");
 


More information about the cairo-commit mailing list