[cairo-commit] 8 commits - src/cairo-directfb-surface.c

Jeff Muizelaar jrmuizel at kemper.freedesktop.org
Thu Dec 11 11:41:16 PST 2008


 src/cairo-directfb-surface.c |    1 +
 1 file changed, 1 insertion(+)

New commits:
commit 391c6026402dee09bb34816637114cea990cd93a
Merge: 2f1b581... d93bf10...
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Thu Dec 11 14:41:01 2008 -0500

    Merge branch '1.8'

commit d93bf10edc7e432349524221a3d1b0f0b2ec8090
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Wed Dec 10 17:02:55 2008 -0500

    [quartz] Create a copy of the pattern so that the reference counts are balanced
    
    The pattern could be stack allocated so we can't take a reference to it;
    instead make a copy.
    
    Based on a patch by Paolo Bonzini.

diff --git a/src/cairo-quartz-surface.c b/src/cairo-quartz-surface.c
index 41fde0b..163c9fb 100644
--- a/src/cairo-quartz-surface.c
+++ b/src/cairo-quartz-surface.c
@@ -682,13 +682,19 @@ ComputeGradientValue (void *info, const float *in, float *out)
 static CGFunctionRef
 CreateGradientFunction (cairo_gradient_pattern_t *gpat)
 {
+    cairo_pattern_t *pat;
     float input_value_range[2] = { 0.f, 1.f };
     float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
     CGFunctionCallbacks callbacks = {
 	0, ComputeGradientValue, (CGFunctionReleaseInfoCallback) cairo_pattern_destroy
     };
 
-    return CGFunctionCreate (gpat,
+    if (_cairo_pattern_create_copy (&pat, &gpat->base))
+	/* quartz doesn't deal very well with malloc failing, so there's
+	 * not much point in us trying either */
+	return NULL;
+
+    return CGFunctionCreate (pat,
 			     1,
 			     input_value_range,
 			     4,
@@ -702,6 +708,7 @@ CreateRepeatingGradientFunction (cairo_quartz_surface_t *surface,
 				 CGPoint *start, CGPoint *end,
 				 CGAffineTransform matrix)
 {
+    cairo_pattern_t *pat;
     float input_value_range[2];
     float output_value_ranges[8] = { 0.f, 1.f, 0.f, 1.f, 0.f, 1.f, 0.f, 1.f };
     CGFunctionCallbacks callbacks = {
@@ -766,7 +773,12 @@ CreateRepeatingGradientFunction (cairo_quartz_surface_t *surface,
     input_value_range[0] = 0.0 - 1.0 * rep_start;
     input_value_range[1] = 1.0 + 1.0 * rep_end;
 
-    return CGFunctionCreate (gpat,
+    if (_cairo_pattern_create_copy (&pat, &gpat->base))
+	/* quartz doesn't deal very well with malloc failing, so there's
+	 * not much point in us trying either */
+	return NULL;
+
+    return CGFunctionCreate (pat,
 			     1,
 			     input_value_range,
 			     4,
commit 673640a3b3931995897b01d49c5dd8d82b50dac2
Author: Jeff Muizelaar <jmuizelaar at mozilla.com>
Date:   Thu Dec 4 17:53:06 2008 -0500

    [win32] Use MOD instead of the '%' operator
    
    Repeat should be handled using MOD instead of '%' so that negative numbers
    are handled as expected. E.g. -1 mod 600 = 599, not 495 as the '%' operator
    gives. This was causing https://bugzilla.mozilla.org/show_bug.cgi?id=466258
    
    Patch from Robert O'Callahan

diff --git a/src/cairo-win32-surface.c b/src/cairo-win32-surface.c
index 5787e26..4327621 100644
--- a/src/cairo-win32-surface.c
+++ b/src/cairo-win32-surface.c
@@ -872,6 +872,9 @@ _cairo_win32_surface_composite_inner (cairo_win32_surface_t *src,
     return CAIRO_STATUS_SUCCESS;
 }
 
+/* from pixman-private.h */
+#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
+
 static cairo_int_status_t
 _cairo_win32_surface_composite (cairo_operator_t	op,
 				cairo_pattern_t       	*pattern,
@@ -1153,8 +1156,8 @@ _cairo_win32_surface_composite (cairo_operator_t	op,
 	uint32_t rendered_width = 0, rendered_height = 0;
 	uint32_t to_render_height, to_render_width;
 	int32_t piece_x, piece_y;
-	int32_t src_start_x = src_r.x % src_extents.width;
-	int32_t src_start_y = src_r.y % src_extents.height;
+	int32_t src_start_x = MOD(src_r.x, src_extents.width);
+	int32_t src_start_y = MOD(src_r.y, src_extents.height);
 
 	if (needs_scale)
 	    goto UNSUPPORTED;
commit 540de34453d16092acd2978b513831a02f01f59f
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Sun Oct 26 12:53:29 2008 +0000

    [matrix] Optimise invert for simple scaling|translation matrices.
    
    Peter Hercek reported, and provided a very useful test case for, a bug
    that caused his applications to crash with Cairo detecting an
    non-invertible pattern matrix and thus asserting the impossible happened.
    Bisecting revealed that the bug first appeared with 3c18d95 and
    disappeared with 0d0c6a1. Since neither of these explain the crash,
    further investigation revealed a compiler bug (gcc 4.3.3 20081130,
    earlier versions have different bugs!) that caused the matrix inversion
    to be invalid iff _cairo_matrix_scalar_multiply() was inlined (i.e. -O0,
    or an explicit noinline atttribute on that function prevented the bug, as
    did -msse.) So we apply this workaround to hide the bug in the stable
    series...
    
    The matrix is quite often just a simple scale and translate (or even
    identity!). For this class of matrix, we can skip the full adjoint
    rearrangement and determinant calculation and just compute the inverse
    directly.
    (cherry picked from commit 0d0c6a199c5b631299c72dce80d66ac0f4936a64)

diff --git a/src/cairo-matrix.c b/src/cairo-matrix.c
index ca18323..6a29aec 100644
--- a/src/cairo-matrix.c
+++ b/src/cairo-matrix.c
@@ -485,9 +485,33 @@ _cairo_matrix_compute_adjoint (cairo_matrix_t *matrix)
 cairo_status_t
 cairo_matrix_invert (cairo_matrix_t *matrix)
 {
-    /* inv (A) = 1/det (A) * adj (A) */
     double det;
 
+    /* Simple scaling|translation matrices are quite common... */
+    if (matrix->xy == 0. && matrix->yx == 0.) {
+	matrix->x0 = -matrix->x0;
+	matrix->y0 = -matrix->y0;
+
+	if (matrix->xx != 1.) {
+	    if (matrix->xx == 0.)
+		return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+
+	    matrix->xx = 1. / matrix->xx;
+	    matrix->x0 *= matrix->xx;
+	}
+
+	if (matrix->yy != 1.) {
+	    if (matrix->yy == 0.)
+		return _cairo_error (CAIRO_STATUS_INVALID_MATRIX);
+
+	    matrix->yy = 1. / matrix->yy;
+	    matrix->y0 *= matrix->yy;
+	}
+
+	return CAIRO_STATUS_SUCCESS;
+    }
+
+    /* inv (A) = 1/det (A) * adj (A) */
     det = _cairo_matrix_compute_determinant (matrix);
 
     if (! ISFINITE (det))
commit f5634818f1e5cc0adaa326662c099a75f4e615eb
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Nov 13 14:56:38 2008 +0000

    [os2] Move include cairo.h before os2.h
    
    The defines need to come first, but we specify that cairo.h is the first
    header file to be included by files.

diff --git a/src/cairo-os2.h b/src/cairo-os2.h
index 17f0263..0d18674 100644
--- a/src/cairo-os2.h
+++ b/src/cairo-os2.h
@@ -44,10 +44,10 @@
 #define INCL_WIN
 #define INCL_GPI
 
-#include <os2.h>
-
 #include "cairo.h"
 
+#include <os2.h>
+
 CAIRO_BEGIN_DECLS
 
 /* The OS/2 Specific Cairo API */
commit 2f0f9a1a593db43dd04507c5989cd0af4b1486de
Author: Behdad Esfahbod <behdad at behdad.org>
Date:   Thu Nov 13 10:50:41 2008 +0100

    [os2] Fix includes
    
    Patch from Dave Yeo to make cairo-os2.h include os2.h directly so the
    header is standalone.

diff --git a/src/cairo-os2-private.h b/src/cairo-os2-private.h
index 5fa2829..e71a6dc 100644
--- a/src/cairo-os2-private.h
+++ b/src/cairo-os2-private.h
@@ -41,17 +41,6 @@
 #include "cairo-os2.h"
 #include "cairoint.h"
 
-#define INCL_DOS
-#define INCL_DOSSEMAPHORES
-#define INCL_DOSERRORS
-#define INCL_WIN
-#define INCL_GPI
-#ifdef __WATCOMC__
-# include <os2.h>
-#else
-# include <os2emx.h>
-#endif
-
 typedef struct _cairo_os2_surface
 {
     cairo_surface_t        base;
diff --git a/src/cairo-os2-surface.c b/src/cairo-os2-surface.c
index bff649a..e4cef05 100644
--- a/src/cairo-os2-surface.c
+++ b/src/cairo-os2-surface.c
@@ -43,11 +43,6 @@
 
 #include <float.h>
 #ifdef BUILD_CAIRO_DLL
-# define INCL_WIN
-# define INCL_GPI
-# define INCL_DOS
-# define INCL_DOSERRORS
-# include <os2emx.h>
 # include "cairo-os2.h"
 # ifndef __WATCOMC__
 #  include <emx/startup.h>
diff --git a/src/cairo-os2.h b/src/cairo-os2.h
index d0a13e4..17f0263 100644
--- a/src/cairo-os2.h
+++ b/src/cairo-os2.h
@@ -38,6 +38,14 @@
 #ifndef _CAIRO_OS2_H_
 #define _CAIRO_OS2_H_
 
+#define INCL_DOS
+#define INCL_DOSSEMAPHORES
+#define INCL_DOSERRORS
+#define INCL_WIN
+#define INCL_GPI
+
+#include <os2.h>
+
 #include "cairo.h"
 
 CAIRO_BEGIN_DECLS
commit 77e60df32fa59328bd32095c77f8c360805b5db7
Author: Maarten Maathuis <madman2003 at gmail.com>
Date:   Sat Nov 8 15:29:40 2008 +0100

    cairo-xcb: avoid leaking memory

diff --git a/src/cairo-xcb-surface.c b/src/cairo-xcb-surface.c
index dede00f..9b7eb4b 100644
--- a/src/cairo-xcb-surface.c
+++ b/src/cairo-xcb-surface.c
@@ -2416,6 +2416,9 @@ _cairo_xcb_surface_emit_glyphs (cairo_xcb_surface_t *dst,
 	}
     }
 
+    /* We wouldn't want to leak memory, would we? */
+    free(output_glyphs);
+
     return CAIRO_STATUS_SUCCESS;
 }
 
commit 361962b7fb4385f164673991670b6fce0839d32a
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Oct 31 08:42:30 2008 +0000

    [directfb] Compile fix with debug enabled.
    
    Fix a trivial compile failure reported here:
      Bug 18322 - bug in _cairo_directfb_surface_release_source_image function
      (http://bugs.freedesktop.org/show_bug.cgi?id=18322)

diff --git a/src/cairo-directfb-surface.c b/src/cairo-directfb-surface.c
index aa67b02..bb02dbf 100644
--- a/src/cairo-directfb-surface.c
+++ b/src/cairo-directfb-surface.c
@@ -549,6 +549,7 @@ _cairo_directfb_surface_release_source_image (void                  *abstract_su
                                               cairo_image_surface_t *image,
                                               void                  *image_extra)
 {
+    cairo_directfb_surface_t *surface = abstract_surface;
     IDirectFBSurface *buffer = image_extra;
 
     D_DEBUG_AT (CairoDFB_Acquire,


More information about the cairo-commit mailing list