[oe-commits] org.oe.dev cairo: add 1.4.4 + Chris Wilsons workqueue patch

koen commit openembedded-commits at lists.openembedded.org
Wed Apr 18 21:06:04 UTC 2007


cairo: add 1.4.4 + Chris Wilsons workqueue patch

Author: koen at openembedded.org
Branch: org.openembedded.dev
Revision: 4ab3710b70f820537b311ab17eff50c0c82a07a2
ViewMTN: http://monotone.openembedded.org/revision.psp?id=4ab3710b70f820537b311ab17eff50c0c82a07a2
Files:
1
packages/cairo/cairo-1.4.4
packages/cairo/cairo-1.4.4/cairo-workqueue.patch
packages/cairo/cairo_1.4.4.bb
Diffs:

#
# mt diff -rd30c39870a82c6df11e6307662c3ccfbd34262bc -r4ab3710b70f820537b311ab17eff50c0c82a07a2
#
# 
# 
# add_dir "packages/cairo/cairo-1.4.4"
# 
# add_file "packages/cairo/cairo-1.4.4/cairo-workqueue.patch"
#  content [fcb6ab3e31ee78acb61b50cc95429df3b5aa0691]
# 
# add_file "packages/cairo/cairo_1.4.4.bb"
#  content [8dd64f5226ca70a1d236457704a988baea0caa04]
# 
============================================================
--- packages/cairo/cairo-1.4.4/cairo-workqueue.patch	fcb6ab3e31ee78acb61b50cc95429df3b5aa0691
+++ packages/cairo/cairo-1.4.4/cairo-workqueue.patch	fcb6ab3e31ee78acb61b50cc95429df3b5aa0691
@@ -0,0 +1,2148 @@
+From: Chris Wilson <chris at chris-wilson.co.uk>
+Date: Wed, 18 Apr 2007 17:34:44 +0000 (+0100)
+Subject: Cache freed GCs
+X-Git-Url: http://gitweb.freedesktop.org/?p=users/ickle/cairo;a=commitdiff;h=3126c3948691cf7a6c0fc0f9cc6a7eca43c3553b
+
+Cache freed GCs
+
+Maintain a cache of freed GCs, one for each used depth.
+---
+
+--- a/src/Makefile.am
++++ b/src/Makefile.am
+@@ -46,7 +46,11 @@ endif
+ 
+ if CAIRO_HAS_XLIB_SURFACE
+ libcairo_xlib_headers = cairo-xlib.h cairo-xlib-xrender.h
+-libcairo_xlib_sources = cairo-xlib-surface.c cairo-xlib-screen.c cairo-xlib-private.h cairo-xlib-test.h
++libcairo_xlib_sources = cairo-xlib-surface.c \
++			cairo-xlib-display.c \
++			cairo-xlib-screen.c \
++			cairo-xlib-private.h \
++			cairo-xlib-test.h
+ backend_pkgconfigs += cairo-xlib.pc
+ endif
+ 
+--- a/src/cairo-clip.c
++++ b/src/cairo-clip.c
+@@ -404,7 +404,8 @@ _cairo_clip_intersect_mask (cairo_clip_t
+ 						   CAIRO_CONTENT_ALPHA,
+ 						   surface_rect.width,
+ 						   surface_rect.height,
+-						   CAIRO_COLOR_WHITE);
++						   CAIRO_COLOR_WHITE,
++						   NULL);
+     if (surface->status)
+ 	return CAIRO_STATUS_NO_MEMORY;
+ 
+--- a/src/cairo-debug.c
++++ b/src/cairo-debug.c
+@@ -59,10 +59,6 @@
+ void
+ cairo_debug_reset_static_data (void)
+ {
+-#if CAIRO_HAS_XLIB_SURFACE
+-    _cairo_xlib_screen_reset_static_data ();
+-#endif
+-
+     _cairo_font_reset_static_data ();
+ 
+ #if CAIRO_HAS_FT_FONT
+--- a/src/cairo-directfb-surface.c
++++ b/src/cairo-directfb-surface.c
+@@ -1511,6 +1511,16 @@ _cairo_directfb_surface_show_glyphs ( vo
+ #endif /* DFB_SHOW_GLYPHS */
+ 
+ 
++static cairo_bool_t
++_cairo_directfb_surface_is_compatible (void *surface_a,
++	                               void *surface_b)
++{
++    cairo_directfb_surface_t *a = (cairo_directfb_surface_t *) surface_a;
++    cairo_directfb_surface_t *b = (cairo_directfb_surface_t *) surface_b;
++
++    return a->dfb == b->dfb;
++}
++
+ static cairo_surface_backend_t cairo_directfb_surface_backend = {
+          CAIRO_SURFACE_TYPE_DIRECTFB, /*type*/
+         _cairo_directfb_surface_create_similar,/*create_similar*/
+@@ -1560,7 +1570,8 @@ static cairo_surface_backend_t cairo_dir
+ #else
+         NULL, /* show_glyphs */
+ #endif
+-        NULL /* snapshot */
++        NULL, /* snapshot */
++	_cairo_directfb_is_compatible
+ };
+ 
+ 
+--- a/src/cairo-glitz-surface.c
++++ b/src/cairo-glitz-surface.c
+@@ -1002,7 +1002,8 @@ _cairo_glitz_surface_fill_rectangles (vo
+ 	    _cairo_surface_create_similar_solid (&dst->base,
+ 						 CAIRO_CONTENT_COLOR_ALPHA,
+ 						 1, 1,
+-						 (cairo_color_t *) color);
++						 (cairo_color_t *) color,
++						 NULL);
+ 	if (src->base.status)
+ 	    return CAIRO_STATUS_NO_MEMORY;
+ 
+@@ -2171,6 +2172,19 @@ _cairo_glitz_surface_flush (void *abstra
+     return CAIRO_STATUS_SUCCESS;
+ }
+ 
++static cairo_bool_t
++_cairo_glitz_surface_is_compatible (void *surface_a,
++	                            void *surface_b)
++{
++    cairo_glitz_surface_t *a = (cairo_glitz_surface_t *) surface_a;
++    cairo_glitz_surface_t *b = (cairo_glitz_surface_t *) surface_b;
++
++    glitz_drawable_t *drawable_a = glitz_surface_get_drawable (a->surface);
++    glitz_drawable_t *drawable_b = glitz_surface_get_drawable (b->surface);
++
++    return drawable_a == drawable_b;
++}
++
+ static const cairo_surface_backend_t cairo_glitz_surface_backend = {
+     CAIRO_SURFACE_TYPE_GLITZ,
+     _cairo_glitz_surface_create_similar,
+@@ -2193,7 +2207,16 @@ static const cairo_surface_backend_t cai
+     _cairo_glitz_surface_flush,
+     NULL, /* mark_dirty_rectangle */
+     _cairo_glitz_surface_scaled_font_fini,
+-    _cairo_glitz_surface_scaled_glyph_fini
++    _cairo_glitz_surface_scaled_glyph_fini,
++
++    NULL, /* paint */
++    NULL, /* mask */
++    NULL, /* stroke */
++    NULL, /* fill */
++    NULL, /* show_glyphs */
++
++    NULL, /* snapshot */
++    _cairo_glitz_surface_is_compatible
+ };
+ 
+ static const cairo_surface_backend_t *
+--- a/src/cairo-mutex-list-private.h
++++ b/src/cairo-mutex-list-private.h
+@@ -34,7 +34,8 @@
+ #ifndef CAIRO_MUTEX_LIST_PRIVATE_H
+ #define CAIRO_MUTEX_LIST_PRIVATE_H
+ 
+-CAIRO_MUTEX_DECLARE (_cairo_pattern_solid_cache_lock);
++CAIRO_MUTEX_DECLARE (_cairo_pattern_solid_pattern_cache_lock);
++CAIRO_MUTEX_DECLARE (_cairo_pattern_solid_surface_cache_lock);
+ 
+ CAIRO_MUTEX_DECLARE (_cairo_font_face_mutex);
+ CAIRO_MUTEX_DECLARE (_cairo_scaled_font_map_mutex);
+@@ -44,7 +45,7 @@ CAIRO_MUTEX_DECLARE (_cairo_ft_unscaled_
+ #endif
+ 
+ #if CAIRO_HAS_XLIB_SURFACE
+-CAIRO_MUTEX_DECLARE (_cairo_xlib_screen_mutex);
++CAIRO_MUTEX_DECLARE (_cairo_xlib_display_mutex);
+ #endif
+ 
+ #endif
+--- a/src/cairo-pattern.c
++++ b/src/cairo-pattern.c
+@@ -282,7 +282,7 @@ _cairo_pattern_create_solid (const cairo
+ {
+     cairo_solid_pattern_t *pattern = NULL;
+ 
+-    CAIRO_MUTEX_LOCK (_cairo_pattern_solid_cache_lock);
++    CAIRO_MUTEX_LOCK (_cairo_pattern_solid_pattern_cache_lock);
+ 
+     if (solid_pattern_cache.size) {
+ 	int i = --solid_pattern_cache.size %
+@@ -291,7 +291,7 @@ _cairo_pattern_create_solid (const cairo
+ 	solid_pattern_cache.patterns[i] = NULL;
+     }
+ 
+-    CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_cache_lock);
++    CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_pattern_cache_lock);
+ 
+     if (pattern == NULL) {
+ 	/* None cached, need to create a new pattern. */
+@@ -306,12 +306,12 @@ _cairo_pattern_create_solid (const cairo
+     return &pattern->base;
+ }
+ 
+-void
+-_cairo_pattern_reset_static_data (void)
++static void
++_cairo_pattern_reset_solid_pattern_cache (void)
+ {
+     int i;
+ 
+-    CAIRO_MUTEX_LOCK (_cairo_pattern_solid_cache_lock);
++    CAIRO_MUTEX_LOCK (_cairo_pattern_solid_pattern_cache_lock);
+ 
+     for (i = 0; i < MIN (ARRAY_LENGTH (solid_pattern_cache.patterns), solid_pattern_cache.size); i++) {
+ 	free (solid_pattern_cache.patterns[i]);
+@@ -319,7 +319,7 @@ _cairo_pattern_reset_static_data (void)
+     }
+     solid_pattern_cache.size = 0;
+ 
+-    CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_cache_lock);
++    CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_pattern_cache_lock);
+ }
+ 
+ static const cairo_pattern_t *
+@@ -630,7 +630,7 @@ cairo_pattern_destroy (cairo_pattern_t *
+     if (pattern->type == CAIRO_PATTERN_TYPE_SOLID) {
+ 	int i;
+ 
+-	CAIRO_MUTEX_LOCK (_cairo_pattern_solid_cache_lock);
++	CAIRO_MUTEX_LOCK (_cairo_pattern_solid_pattern_cache_lock);
+ 
+ 	i = solid_pattern_cache.size++ %
+ 	    ARRAY_LENGTH (solid_pattern_cache.patterns);
+@@ -640,7 +640,7 @@ cairo_pattern_destroy (cairo_pattern_t *
+ 
+ 	solid_pattern_cache.patterns[i] = (cairo_solid_pattern_t *) pattern;
+ 
+-	CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_cache_lock);
++	CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_pattern_cache_lock);
+     } else {
+ 	free (pattern);
+     }
+@@ -1235,6 +1235,17 @@ _cairo_pattern_acquire_surface_for_gradi
+     return status;
+ }
+ 
++/* We maintain a small cache here, because we don't want to constantly
++ * recreate surfaces for simple solid colors. */
++#define MAX_SURFACE_CACHE_SIZE 16
++static struct {
++    struct {
++	cairo_color_t    color;
++	cairo_surface_t *surface;
++    } cache[MAX_SURFACE_CACHE_SIZE];
++    int size;
++} solid_surface_cache;
++
+ static cairo_int_status_t
+ _cairo_pattern_acquire_surface_for_solid (cairo_solid_pattern_t	     *pattern,
+ 					  cairo_surface_t	     *dst,
+@@ -1245,12 +1256,54 @@ _cairo_pattern_acquire_surface_for_solid
+ 					  cairo_surface_t	     **out,
+ 					  cairo_surface_attributes_t *attribs)
+ {
+-    *out = _cairo_surface_create_similar_solid (dst,
+-						CAIRO_CONTENT_COLOR_ALPHA,
+-						1, 1,
+-						&pattern->color);
+-    if ((*out)->status)
+-	return CAIRO_STATUS_NO_MEMORY;
++    static int i;
++
++    cairo_surface_t *surface;
++    cairo_status_t   status;
++
++    CAIRO_MUTEX_LOCK (_cairo_pattern_solid_surface_cache_lock);
++
++    /* Check cache first */
++    if (i < solid_surface_cache.size &&
++	    _cairo_color_equal (&solid_surface_cache.cache[i].color,
++		                &pattern->color) &&
++	    _cairo_surface_is_compatible (solid_surface_cache.cache[i].surface, dst))
++	    goto DONE;
++
++    for (i = 0 ; i < solid_surface_cache.size; i++) {
++	if (_cairo_color_equal (&solid_surface_cache.cache[i].color,
++		                &pattern->color) &&
++	    _cairo_surface_is_compatible (solid_surface_cache.cache[i].surface, dst))
++	    goto DONE;
++    }
++
++    /* Not cached, need to create new */
++    surface = _cairo_surface_create_similar_solid (dst,
++						   CAIRO_CONTENT_COLOR_ALPHA,
++						   1, 1,
++						   &pattern->color,
++						   pattern);
++    assert (_cairo_surface_is_compatible (surface, dst));
++    if (surface->status) {
++	status = surface->status;
++	goto UNLOCK;
++    }
++
++    /* Cache new */
++    if (solid_surface_cache.size < MAX_SURFACE_CACHE_SIZE) {
++	solid_surface_cache.size++;
++    } else {
++	i = rand () % MAX_SURFACE_CACHE_SIZE;
++
++	/* Evict old */
++	cairo_surface_destroy (solid_surface_cache.cache[i].surface);
++    }
++
++    solid_surface_cache.cache[i].color = pattern->color;
++    solid_surface_cache.cache[i].surface = surface;
++
++DONE:
++    *out = cairo_surface_reference (solid_surface_cache.cache[i].surface);
+ 
+     attribs->x_offset = attribs->y_offset = 0;
+     cairo_matrix_init_identity (&attribs->matrix);
+@@ -1258,7 +1311,26 @@ _cairo_pattern_acquire_surface_for_solid
+     attribs->filter = CAIRO_FILTER_NEAREST;
+     attribs->acquired = FALSE;
+ 
+-    return CAIRO_STATUS_SUCCESS;
++    status = CAIRO_STATUS_SUCCESS;
++
++UNLOCK:
++    CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_surface_cache_lock);
++
++    return status;
++}
++
++static void
++_cairo_pattern_reset_solid_surface_cache (void)
++{
++    int i;
++
++    CAIRO_MUTEX_LOCK (_cairo_pattern_solid_surface_cache_lock);
++
++    for (i = 0; i < solid_surface_cache.size; i++)
++	cairo_surface_destroy (solid_surface_cache.cache[i].surface);
++    solid_surface_cache.size = 0;
++
++    CAIRO_MUTEX_UNLOCK (_cairo_pattern_solid_surface_cache_lock);
+ }
+ 
+ /**
+@@ -2049,3 +2121,10 @@ cairo_pattern_get_radial_circles (cairo_
+ 
+     return CAIRO_STATUS_SUCCESS;
+ }
++
++void
++_cairo_pattern_reset_static_data (void)
++{
++    _cairo_pattern_reset_solid_pattern_cache ();
++    _cairo_pattern_reset_solid_surface_cache ();
++}
+--- a/src/cairo-surface.c
++++ b/src/cairo-surface.c
+@@ -288,7 +288,8 @@ cairo_surface_create_similar (cairo_surf
+ 
+     return _cairo_surface_create_similar_solid (other, content,
+ 						width, height,
+-						CAIRO_COLOR_TRANSPARENT);
++						CAIRO_COLOR_TRANSPARENT,
++						NULL);
+ }
+ slim_hidden_def (cairo_surface_create_similar);
+ 
+@@ -297,7 +298,8 @@ _cairo_surface_create_similar_solid (cai
+ 				     cairo_content_t	  content,
+ 				     int		  width,
+ 				     int		  height,
+-				     const cairo_color_t *color)
++				     const cairo_color_t *color,
++				     cairo_pattern_t     *pattern)
+ {
+     cairo_status_t status;
+     cairo_surface_t *surface;
+@@ -310,19 +312,23 @@ _cairo_surface_create_similar_solid (cai
+ 	return (cairo_surface_t*) &_cairo_surface_nil;
+     }
+ 
+-    source = _cairo_pattern_create_solid (color);
+-    if (source->status) {
+-	cairo_surface_destroy (surface);
+-	_cairo_error (CAIRO_STATUS_NO_MEMORY);
+-	return (cairo_surface_t*) &_cairo_surface_nil;
+-    }
++    if (pattern == NULL) {
++	source = _cairo_pattern_create_solid (color);
++	if (source->status) {
++	    cairo_surface_destroy (surface);
++	    _cairo_error (CAIRO_STATUS_NO_MEMORY);
++	    return (cairo_surface_t*) &_cairo_surface_nil;
++	}
++    } else
++	source = pattern;
+ 
+     status = _cairo_surface_paint (surface,
+ 				   color == CAIRO_COLOR_TRANSPARENT ?
+ 				   CAIRO_OPERATOR_CLEAR :
+ 				   CAIRO_OPERATOR_SOURCE, source);
+ 
+-    cairo_pattern_destroy (source);
++    if (source != pattern)
++	cairo_pattern_destroy (source);
+ 
+     if (status) {
+ 	cairo_surface_destroy (surface);
+@@ -1056,6 +1062,32 @@ _cairo_surface_snapshot (cairo_surface_t
+     return _cairo_surface_fallback_snapshot (surface);
+ }
+ 
++/**
++ * _cairo_surface_is_compatible
++ * @surface_a: a #cairo_surface_t
++ * @surface_b: a #cairo_surface_t
++ *
++ * Find out whether the given surfaces share the same backend,
++ * and if so, whether they can be considered compatible.
++ *
++ * The definition of "compatible" depends on the backend. In the
++ * xlib case, it means the surface share the same display.
++ *
++ * Return value: TRUE if the surfaces are compatible.
++ **/
++cairo_bool_t
++_cairo_surface_is_compatible (cairo_surface_t *surface_a,
++	                      cairo_surface_t *surface_b)
++{
++    if (surface_a->backend != surface_b->backend)
++	return FALSE;
++
++    if (surface_a->backend->is_compatible != NULL)
++	return surface_a->backend->is_compatible (surface_a, surface_b);
++
++    return TRUE;
++}
++
+ cairo_status_t
+ _cairo_surface_composite (cairo_operator_t	op,
+ 			  cairo_pattern_t	*src,
+--- a/src/cairo-win32-surface.c
++++ b/src/cairo-win32-surface.c
+@@ -1854,6 +1854,16 @@ cairo_win32_surface_get_image (cairo_sur
+     return ((cairo_win32_surface_t*)surface)->image;
+ }
+ 
++static cairo_bool_t
++_cairo_win32_surface_is_compatible (void *surface_a,
++	                            void *surface_b)
++{
++    cairo_win32_surface_t *a = (cairo_win32_surface_t *) surface_a;
++    cairo_win32_surface_t *b = (cairo_win32_surface_t *) surface_b;
++
++    return a->dc == b->dc;
++}
++
+ static const cairo_surface_backend_t cairo_win32_surface_backend = {
+     CAIRO_SURFACE_TYPE_WIN32,
+     _cairo_win32_surface_create_similar,
+@@ -1884,7 +1894,8 @@ static const cairo_surface_backend_t cai
+     NULL, /* fill */
+     _cairo_win32_surface_show_glyphs,
+ 
+-    NULL  /* snapshot */
++    NULL,  /* snapshot */
++    _cairo_win32_surface_is_compatible
+ };
+ 
+ /* Notes:
+--- a/src/cairo-xcb-surface.c
++++ b/src/cairo-xcb-surface.c
+@@ -1577,6 +1577,16 @@ _cairo_xcb_surface_show_glyphs (void    
+ 				 int		      num_glyphs,
+ 				 cairo_scaled_font_t *scaled_font);
+ 
++static cairo_bool_t
++_cairo_xcb_surface_is_compatible (void *surface_a,
++	                          void *surface_b)
++{
++    cairo_xcb_surface_t *a = (cairo_xcb_surface_t *) surface_a;
++    cairo_xcb_surface_t *b = (cairo_xcb_surface_t *) surface_b;
++
++    return _cairo_xcb_surface_same_screen (dst, src);
++}
++
+ /* XXX: move this to the bottom of the file, XCB and Xlib */
+ 
+ static const cairo_surface_backend_t cairo_xcb_surface_backend = {
+@@ -1608,7 +1618,8 @@ static const cairo_surface_backend_t cai
+     NULL, /* stroke */
+     NULL, /* fill */
+     _cairo_xcb_surface_show_glyphs,
+-    NULL  /* snapshot */
++    NULL,  /* snapshot */
++    _cairo_xcb_surface_is_compatible
+ };
+ 
+ /**
+--- /dev/null
++++ b/src/cairo-xlib-display.c
+@@ -0,0 +1,490 @@
++/* Cairo - a vector graphics library with display and print output
++ *
++ * Copyright © 2007 Chris Wilson
++ *
++ * 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 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 "Licen%s
>>> DIFF TRUNCATED @ 16K






More information about the Openembedded-commits mailing list