[cairo-commit] 2 commits - configure.ac src/cairo-ft-font.c src/cairo-image-compositor.c src/cairo-image-surface.c src/cairo-pixman-private.h src/cairo-xlib-render-compositor.c src/cairo-xlib-surface.c src/Makefile.sources src/win32

Chris Wilson ickle at kemper.freedesktop.org
Fri Aug 23 04:54:53 PDT 2013


 configure.ac                            |    2 -
 src/Makefile.sources                    |    1 
 src/cairo-ft-font.c                     |    6 ++--
 src/cairo-image-compositor.c            |   44 +++++++++++++++++++------------
 src/cairo-image-surface.c               |    8 ++++-
 src/cairo-pixman-private.h              |   45 ++++++++++++++++++++++++++++++++
 src/cairo-xlib-render-compositor.c      |    1 
 src/cairo-xlib-surface.c                |    1 
 src/win32/cairo-win32-display-surface.c |    3 +-
 9 files changed, 90 insertions(+), 21 deletions(-)

New commits:
commit fb8881e84bb24b2a54ee5aa449b6f5638de36404
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Fri Aug 23 12:48:08 2013 +0100

    win32: Prevent double-free of similar images
    
    Based on a patch and analysis by Michael Henning.
    
    When we create a similar-image surface for win32, we set up a couple of
    back references from the image to the win32 surface, and vice versa. We
    need to be careful when decoupling the reference cycle to avoid chasing
    around the loop upon destruction. Currently we handled destroying the
    similar-image via the parent win32 surface, but similar precaution is
    required when destroying the surface via the similar-image.
    
    Reported-by: Michael Henning <drawoc at darkrefraction.com>
    Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=63787
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 5390d4a..824dbf3 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -848,8 +848,9 @@ _cairo_image_surface_finish (void *abstract_surface)
     }
 
     if (surface->parent) {
-	cairo_surface_destroy (surface->parent);
+	cairo_surface_t *parent = surface->parent;
 	surface->parent = NULL;
+	cairo_surface_destroy (parent);
     }
 
     return CAIRO_STATUS_SUCCESS;
diff --git a/src/win32/cairo-win32-display-surface.c b/src/win32/cairo-win32-display-surface.c
index 0390625..5ecdbee 100644
--- a/src/win32/cairo-win32-display-surface.c
+++ b/src/win32/cairo-win32-display-surface.c
@@ -415,7 +415,8 @@ _cairo_win32_display_surface_finish (void *abstract_surface)
 {
     cairo_win32_display_surface_t *surface = abstract_surface;
 
-    if (surface->image) {
+    if (surface->image && to_image_surface(surface->image)->parent) {
+	assert (to_image_surface(surface->image)->parent == &surface->win32.base);
 	/* Unhook ourselves first to avoid the double-unref from the image */
 	to_image_surface(surface->image)->parent = NULL;
 	cairo_surface_finish (surface->image);
commit 054f34111d220541bc785b30207387541fdd31d2
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Thu Aug 15 14:28:44 2013 +0000

    Provide backwards compatibilty with old pixman
    
    The goal is to allow compilation against older pixman to ease regression
    testing.
    
    Signed-off-by: Chris Wilson <chris at chris-wilson.co.uk>

diff --git a/configure.ac b/configure.ac
index c08dbb2..fd54ad1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -656,7 +656,7 @@ CAIRO_ENABLE(test_surfaces, test surfaces, no)
 dnl ===========================================================================
 
 CAIRO_ENABLE_SURFACE_BACKEND(image, image, always, [
-  pixman_REQUIRES="pixman-1 >= 0.22.0"
+  pixman_REQUIRES="pixman-1 >= 0.16.0"
   PKG_CHECK_MODULES(pixman, $pixman_REQUIRES, ,
     [use_image="no (requires $pixman_REQUIRES http://cairographics.org/releases/)"])
   image_REQUIRES=$pixman_REQUIRES
diff --git a/src/Makefile.sources b/src/Makefile.sources
index 4abf57d..2e14fff 100644
--- a/src/Makefile.sources
+++ b/src/Makefile.sources
@@ -99,6 +99,7 @@ cairo_private = \
 	cairo-path-private.h \
 	cairo-pattern-inline.h \
 	cairo-pattern-private.h \
+	cairo-pixman-private.h \
 	cairo-private.h \
 	cairo-recording-surface-inline.h \
 	cairo-recording-surface-private.h \
diff --git a/src/cairo-ft-font.c b/src/cairo-ft-font.c
index 0dfe9be..9f4b524 100644
--- a/src/cairo-ft-font.c
+++ b/src/cairo-ft-font.c
@@ -45,6 +45,7 @@
 #include "cairo-image-surface-private.h"
 #include "cairo-ft-private.h"
 #include "cairo-pattern-private.h"
+#include "cairo-pixman-private.h"
 
 #include <float.h>
 
@@ -1126,9 +1127,10 @@ _get_bitmap_surface (FT_Bitmap		     *bitmap,
 		     cairo_font_options_t    *font_options,
 		     cairo_image_surface_t  **surface)
 {
-    int width, height, stride;
+    unsigned int width, height;
     unsigned char *data;
     int format = CAIRO_FORMAT_A8;
+    int stride;
     cairo_image_surface_t *image;
     cairo_bool_t component_alpha = FALSE;
 
@@ -1599,7 +1601,7 @@ _transform_glyph_bitmap (cairo_matrix_t         * shape,
     if (unlikely (status))
 	return status;
 
-    if (cairo_image_surface_get_format (*surface) == CAIRO_FORMAT_ARGB32 &&
+    if ((*surface)->format == CAIRO_FORMAT_ARGB32 &&
         !pixman_image_get_component_alpha ((*surface)->pixman_image))
       image = cairo_image_surface_create (CAIRO_FORMAT_ARGB32, width, height);
     else
diff --git a/src/cairo-image-compositor.c b/src/cairo-image-compositor.c
index 8245882..d0c4dd9 100644
--- a/src/cairo-image-compositor.c
+++ b/src/cairo-image-compositor.c
@@ -52,6 +52,8 @@
 #include "cairo-traps-private.h"
 #include "cairo-tristrip-private.h"
 
+#include "cairo-pixman-private.h"
+
 static pixman_image_t *
 to_pixman_image (cairo_surface_t *s)
 {
@@ -256,9 +258,9 @@ _pixman_operator (cairo_operator_t op)
 }
 
 static cairo_bool_t
-fill_reduces_to_source (cairo_operator_t op,
-			const cairo_color_t *color,
-			cairo_image_surface_t *dst)
+__fill_reduces_to_source (cairo_operator_t op,
+			  const cairo_color_t *color,
+			  const cairo_image_surface_t *dst)
 {
     if (op == CAIRO_OPERATOR_SOURCE || op == CAIRO_OPERATOR_CLEAR)
 	return TRUE;
@@ -270,6 +272,20 @@ fill_reduces_to_source (cairo_operator_t op,
     return FALSE;
 }
 
+static cairo_bool_t
+fill_reduces_to_source (cairo_operator_t op,
+			const cairo_color_t *color,
+			const cairo_image_surface_t *dst,
+			uint32_t *pixel)
+{
+    if (__fill_reduces_to_source (op, color, dst)) {
+	color_to_pixel (color, dst->pixman_format, pixel);
+	return TRUE;
+    }
+
+    return FALSE;
+}
+
 static cairo_int_status_t
 fill_rectangles (void			*_dst,
 		 cairo_operator_t	 op,
@@ -283,9 +299,7 @@ fill_rectangles (void			*_dst,
 
     TRACE ((stderr, "%s\n", __FUNCTION__));
 
-    if (fill_reduces_to_source (op, color, dst) &&
-	color_to_pixel (color, dst->pixman_format, &pixel))
-    {
+    if (fill_reduces_to_source (op, color, dst, &pixel)) {
 	for (i = 0; i < num_rects; i++) {
 	    pixman_fill ((uint32_t *) dst->data, dst->stride / sizeof (uint32_t),
 			 PIXMAN_FORMAT_BPP (dst->pixman_format),
@@ -293,9 +307,7 @@ fill_rectangles (void			*_dst,
 			 rects[i].width, rects[i].height,
 			 pixel);
 	}
-    }
-    else
-    {
+    } else {
 	pixman_image_t *src = _pixman_image_for_color (color);
 
 	op = _pixman_operator (op);
@@ -327,9 +339,7 @@ fill_boxes (void		*_dst,
 
     TRACE ((stderr, "%s x %d\n", __FUNCTION__, boxes->num_boxes));
 
-    if (fill_reduces_to_source (op, color, dst) &&
-	color_to_pixel (color, dst->pixman_format, &pixel))
-    {
+    if (fill_reduces_to_source (op, color, dst, &pixel)) {
 	for (chunk = &boxes->chunks; chunk; chunk = chunk->next) {
 	    for (i = 0; i < chunk->count; i++) {
 		int x = _cairo_fixed_integer_part (chunk->base[i].p1.x);
@@ -674,6 +684,7 @@ composite_traps (void			*_dst,
     return  CAIRO_STATUS_SUCCESS;
 }
 
+#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0)
 static void
 set_point (pixman_point_fixed_t *p, cairo_point_t *c)
 {
@@ -749,6 +760,7 @@ composite_tristrip (void			*_dst,
 
     return  CAIRO_STATUS_SUCCESS;
 }
+#endif
 
 static cairo_int_status_t
 check_composite_glyphs (const cairo_composite_rectangles_t *extents,
@@ -1215,7 +1227,9 @@ _cairo_image_traps_compositor_get (void)
 	//compositor.check_composite_traps = check_composite_traps;
 	compositor.composite_traps = composite_traps;
 	//compositor.check_composite_tristrip = check_composite_traps;
+#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0)
 	compositor.composite_tristrip = composite_tristrip;
+#endif
 	compositor.check_composite_glyphs = check_composite_glyphs;
 	compositor.composite_glyphs = composite_glyphs;
     }
@@ -2010,8 +2024,7 @@ mono_renderer_init (cairo_image_span_renderer_t	*r,
 	if (composite->op == CAIRO_OPERATOR_CLEAR)
 	    color = CAIRO_COLOR_TRANSPARENT;
 
-	if (fill_reduces_to_source (composite->op, color, dst) &&
-	    color_to_pixel (color, dst->pixman_format, &r->u.fill.pixel)) {
+	if (fill_reduces_to_source (composite->op, color, dst, &r->u.fill.pixel)) {
 	    /* Use plain C for the fill operations as the span length is
 	     * typically small, too small to payback the startup overheads of
 	     * using SSE2 etc.
@@ -2755,8 +2768,7 @@ inplace_renderer_init (cairo_image_span_renderer_t	*r,
 	if (composite->op == CAIRO_OPERATOR_CLEAR)
 	    color = CAIRO_COLOR_TRANSPARENT;
 
-	if (fill_reduces_to_source (composite->op, color, dst) &&
-	    color_to_pixel (color, dst->pixman_format, &r->u.fill.pixel)) {
+	if (fill_reduces_to_source (composite->op, color, dst, &r->u.fill.pixel)) {
 	    /* Use plain C for the fill operations as the span length is
 	     * typically small, too small to payback the startup overheads of
 	     * using SSE2 etc.
diff --git a/src/cairo-image-surface.c b/src/cairo-image-surface.c
index 98d928f..5390d4a 100644
--- a/src/cairo-image-surface.c
+++ b/src/cairo-image-surface.c
@@ -48,6 +48,7 @@
 #include "cairo-image-surface-inline.h"
 #include "cairo-paginated-private.h"
 #include "cairo-pattern-private.h"
+#include "cairo-pixman-private.h"
 #include "cairo-recording-surface-private.h"
 #include "cairo-region-private.h"
 #include "cairo-scaled-font-private.h"
@@ -103,7 +104,9 @@ _cairo_format_from_pixman_format (pixman_format_code_t pixman_format)
 	return CAIRO_FORMAT_A1;
     case PIXMAN_r5g6b5:
 	return CAIRO_FORMAT_RGB16_565;
+#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0)
     case PIXMAN_r8g8b8a8: case PIXMAN_r8g8b8x8:
+#endif
     case PIXMAN_a8b8g8r8: case PIXMAN_x8b8g8r8: case PIXMAN_r8g8b8:
     case PIXMAN_b8g8r8:   case PIXMAN_b5g6r5:
     case PIXMAN_a1r5g5b5: case PIXMAN_x1r5g5b5: case PIXMAN_a1b5g5r5:
@@ -120,7 +123,9 @@ _cairo_format_from_pixman_format (pixman_format_code_t pixman_format)
     case PIXMAN_a2b10g10r10:
     case PIXMAN_x2b10g10r10:
     case PIXMAN_a2r10g10b10:
+#if PIXMAN_VERSION >= PIXMAN_VERSION_ENCODE(0,22,0)
     case PIXMAN_x14r6g6b6:
+#endif
     default:
 	return CAIRO_FORMAT_INVALID;
     }
diff --git a/src/cairo-pixman-private.h b/src/cairo-pixman-private.h
new file mode 100644
index 0000000..13ec82e
--- /dev/null
+++ b/src/cairo-pixman-private.h
@@ -0,0 +1,45 @@
+/* -*- Mode: c; tab-width: 8; c-basic-offset: 4; indent-tabs-mode: t; -*- */
+/* cairo - a vector graphics library with display and print output
+ *
+ * Copyright ©2013 Intel Corporation
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it either under the terms of the GNU Lesser General Public
+ * License version 2.1 as published by the Free Software Foundation
+ * (the "LGPL") or, at your option, under the terms of the Mozilla
+ * Public License Version 1.1 (the "MPL"). If you do not alter this
+ * notice, a recipient may use your version of this file under either
+ * the MPL or the LGPL.
+ *
+ * You should have received a copy of the LGPL along with this library
+ * in the file COPYING-LGPL-2.1; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Suite 500, Boston, MA 02110-1335, USA
+ * You should have received a copy of the MPL along with this library
+ * in the file COPYING-MPL-1.1
+ *
+ * The contents of this file are subject to the Mozilla Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://www.mozilla.org/MPL/
+ *
+ * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY
+ * OF ANY KIND, either express or implied. See the LGPL or the MPL for
+ * the specific language governing rights and limitations.
+ *
+ * The Original Code is the cairo graphics library.
+ *
+ * The Initial Developer of the Original Code is University of Southern
+ * California.
+ *
+ * Contributor(s):
+ *	Chris Wilson <chris at chris-wilson.co.uk>
+ */
+
+#include <pixman.h>
+
+#if PIXMAN_VERSION < PIXMAN_VERSION_ENCODE(0,22,0)
+#define pixman_image_composite32 pixman_image_composite
+#define pixman_image_get_component_alpha(i) 0
+#define pixman_image_set_component_alpha(i, x) do { } while (0)
+#endif
+
diff --git a/src/cairo-xlib-render-compositor.c b/src/cairo-xlib-render-compositor.c
index 013e2af..68e7ce5 100644
--- a/src/cairo-xlib-render-compositor.c
+++ b/src/cairo-xlib-render-compositor.c
@@ -51,6 +51,7 @@
 #include "cairo-image-surface-private.h"
 #include "cairo-list-inline.h"
 #include "cairo-pattern-private.h"
+#include "cairo-pixman-private.h"
 #include "cairo-traps-private.h"
 #include "cairo-tristrip-private.h"
 
diff --git a/src/cairo-xlib-surface.c b/src/cairo-xlib-surface.c
index 41e3a8d..029a542 100644
--- a/src/cairo-xlib-surface.c
+++ b/src/cairo-xlib-surface.c
@@ -60,6 +60,7 @@
 #include "cairo-image-surface-private.h"
 #include "cairo-list-inline.h"
 #include "cairo-pattern-private.h"
+#include "cairo-pixman-private.h"
 #include "cairo-region-private.h"
 #include "cairo-scaled-font-private.h"
 #include "cairo-surface-snapshot-private.h"


More information about the cairo-commit mailing list