[cairo-commit] 3 commits - src/cairo-pattern.c src/cairo-surface.c test/.valgrind-suppressions

Chris Wilson ickle at kemper.freedesktop.org
Thu Aug 7 02:57:54 PDT 2008


 src/cairo-pattern.c         |   16 +++++++++++++---
 src/cairo-surface.c         |   11 ++---------
 test/.valgrind-suppressions |   32 ++++++++++++++++++++++++++++++++
 3 files changed, 47 insertions(+), 12 deletions(-)

New commits:
commit 56619a16ddc6add30b4a5c51ce02d7030752429f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Aug 7 08:25:37 2008 +0100

    [cairo-surface] Use the pre-computed device_transform_inverse.
    
    Avoid inverting the device_transform when copying the pattern for the
    destination surface by using the pre-computed inverse.

diff --git a/src/cairo-surface.c b/src/cairo-surface.c
index ce8b890..ca703aa 100644
--- a/src/cairo-surface.c
+++ b/src/cairo-surface.c
@@ -2558,15 +2558,8 @@ _cairo_surface_copy_pattern_for_destination (const cairo_pattern_t *pattern,
 	return status;
 
     if (_cairo_surface_has_device_transform (destination)) {
-	cairo_matrix_t device_to_surface = destination->device_transform;
-
-	status = cairo_matrix_invert (&device_to_surface);
-	/* We only ever allow for scaling (under the implementation's
-	 * control) or translation (under the user's control). So the
-	 * matrix should always be invertible. */
-	assert (status == CAIRO_STATUS_SUCCESS);
-
-	_cairo_pattern_transform (*pattern_out, &device_to_surface);
+	_cairo_pattern_transform (*pattern_out,
+		                  &destination->device_transform_inverse);
     }
 
     return CAIRO_STATUS_SUCCESS;
commit 6a4ddb6f47c552f416e6dec069eb57ebe16005fd
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Aug 6 13:45:08 2008 +0100

    [pattern] Set the reference count for stack allocations to 0.
    
    Keep the reference count as zero for temporary, on-stack patterns in
    order to detect attempts to keep references beyond their scope. (And
    mismatched _init()/_destroy()).

diff --git a/src/cairo-pattern.c b/src/cairo-pattern.c
index 8fde845..e861d88 100644
--- a/src/cairo-pattern.c
+++ b/src/cairo-pattern.c
@@ -95,9 +95,12 @@ static void
 _cairo_pattern_init (cairo_pattern_t *pattern, cairo_pattern_type_t type)
 {
     pattern->type      = type;
-    CAIRO_REFERENCE_COUNT_INIT (&pattern->ref_count, 1);
     pattern->status    = CAIRO_STATUS_SUCCESS;
 
+    /* Set the reference count to zero for on-stack patterns.
+     * Callers needs to explicitly increment the count for heap allocations. */
+    CAIRO_REFERENCE_COUNT_INIT (&pattern->ref_count, 0);
+
     _cairo_user_data_array_init (&pattern->user_data);
 
     if (type == CAIRO_PATTERN_TYPE_SURFACE)
@@ -183,7 +186,7 @@ _cairo_pattern_init_copy (cairo_pattern_t	*pattern,
     }
 
     /* The reference count and user_data array are unique to the copy. */
-    CAIRO_REFERENCE_COUNT_INIT (&pattern->ref_count, 1);
+    CAIRO_REFERENCE_COUNT_INIT (&pattern->ref_count, 0);
     _cairo_user_data_array_init (&pattern->user_data);
 
     return CAIRO_STATUS_SUCCESS;
@@ -246,6 +249,8 @@ _cairo_pattern_create_copy (cairo_pattern_t	  **pattern,
 	return status;
     }
 
+    CAIRO_REFERENCE_COUNT_INIT (&(*pattern)->ref_count, 1);
+
     return CAIRO_STATUS_SUCCESS;
 }
 
@@ -350,8 +355,10 @@ _cairo_pattern_create_solid (const cairo_color_t *color,
     if (pattern == NULL) {
 	_cairo_error_throw (CAIRO_STATUS_NO_MEMORY);
 	pattern = (cairo_solid_pattern_t *) &_cairo_pattern_nil;
-    } else
+    } else {
 	_cairo_pattern_init_solid (pattern, color, content);
+	CAIRO_REFERENCE_COUNT_INIT (&pattern->base.ref_count, 1);
+    }
 
     return &pattern->base;
 }
@@ -504,6 +511,7 @@ cairo_pattern_create_for_surface (cairo_surface_t *surface)
     CAIRO_MUTEX_INITIALIZE ();
 
     _cairo_pattern_init_for_surface (pattern, surface);
+    CAIRO_REFERENCE_COUNT_INIT (&pattern->base.ref_count, 1);
 
     return &pattern->base;
 }
@@ -549,6 +557,7 @@ cairo_pattern_create_linear (double x0, double y0, double x1, double y1)
     CAIRO_MUTEX_INITIALIZE ();
 
     _cairo_pattern_init_linear (pattern, x0, y0, x1, y1);
+    CAIRO_REFERENCE_COUNT_INIT (&pattern->base.base.ref_count, 1);
 
     return &pattern->base.base;
 }
@@ -596,6 +605,7 @@ cairo_pattern_create_radial (double cx0, double cy0, double radius0,
     CAIRO_MUTEX_INITIALIZE ();
 
     _cairo_pattern_init_radial (pattern, cx0, cy0, radius0, cx1, cy1, radius1);
+    CAIRO_REFERENCE_COUNT_INIT (&pattern->base.base.ref_count, 1);
 
     return &pattern->base.base;
 }
commit ae7bdd7ee0642c5b0f2e1ea3dabf38e79cf18c0b
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Aug 6 13:00:21 2008 +0100

    [valgrind] More suppressions for XrmGetStringDatabase().
    
    Another variation in the callstack needs suppressing.

diff --git a/test/.valgrind-suppressions b/test/.valgrind-suppressions
index c28d586..f481a2f 100644
--- a/test/.valgrind-suppressions
+++ b/test/.valgrind-suppressions
@@ -278,6 +278,38 @@
 {
    XrmGetStringDatabase is fairly obnoxious about leaving reachable memory around
    Memcheck:Leak
+   fun:realloc
+   fun:add_codeset
+   fun:load_generic
+   fun:initialize
+   fun:_XlcCreateLC
+   fun:_XlcDefaultLoader
+   fun:_XOpenLC
+}
+{
+   XrmGetStringDatabase is fairly obnoxious about leaving reachable memory around
+   Memcheck:Leak
+   fun:malloc
+   fun:add_codeset
+   fun:load_generic
+   fun:initialize
+   fun:_XlcCreateLC
+   fun:_XlcDefaultLoader
+   fun:_XOpenLC
+}
+{
+   XrmGetStringDatabase is fairly obnoxious about leaving reachable memory around
+   Memcheck:Leak
+   fun:malloc
+   fun:load_generic
+   fun:initialize
+   fun:_XlcCreateLC
+   fun:_XlcDefaultLoader
+   fun:_XOpenLC
+}
+{
+   XrmGetStringDatabase is fairly obnoxious about leaving reachable memory around
+   Memcheck:Leak
    fun:malloc
    fun:_XlcAddCharSet
    fun:_XlcAddCT


More information about the cairo-commit mailing list