Bug 34177

Summary: atomic refcounting required
Product: cairo Reporter: Jasper St. Pierre <jstpierre>
Component: image backendAssignee: Carl Worth <cworth>
Status: RESOLVED FIXED QA Contact: cairo-bugs mailing list <cairo-bugs>
Severity: enhancement    
Priority: medium    
Version: 1.10.3   
Hardware: Other   
OS: All   
Whiteboard:
i915 platform: i915 features:

Description Jasper St. Pierre 2011-02-11 05:50:39 UTC
talking in #cairo on IRC, sanooj came up with this patch:

http://people.freedesktop.org/~joonas/tmp/image-ref.patch

which fixed the problem
Comment 1 Søren Sandmann Pedersen 2011-02-11 08:44:57 UTC
This is a patch against cairo, although atomic ref counting would be useful in pixman too.
Comment 2 Chris Wilson 2011-02-11 08:55:54 UTC
Søren, the patch is irrelevant. It just highlights how Cairo needs atomic refcounting on pixman_image_t, without which the alternative is such a monstrosity.

The solution lies within pixman.
Comment 3 Søren Sandmann Pedersen 2011-02-11 09:11:27 UTC
whatever
Comment 4 M Joonas Pihlaja 2011-02-11 09:57:26 UTC
Here's a patch that removes the need for atomic pixman_image_ref()/unref() in cairo, mostly by dropping the global solid colour cache:

http://cgit.freedesktop.org/~joonas/cairo/commit/?h=no-pixman-ref&id=af403a204a88d882317a3e91abe8f0cc454852a4
Comment 5 Alessandro 2011-02-11 10:12:36 UTC
I really think the bug should be flagged as still open. 

Adding atomic refcounting would be fairly easy using GCC builtins. See http://gcc.gnu.org/onlinedocs/gcc-4.1.2/gcc/Atomic-Builtins.html
Comment 6 M Joonas Pihlaja 2011-02-19 08:06:04 UTC
Fixed in cairo master.

commit 71e8a4c23019b01aa43b334fcb2784c70daae9b5
Author: M Joonas Pihlaja <jpihlaja@cc.helsinki.fi>
Date:   Sat Feb 19 17:46:45 2011 +0200

    image: Avoid reusing pixman images for threadsafety.

Use of freedesktop.org services, including Bugzilla, is subject to our Code of Conduct. How we collect and use information is described in our Privacy Policy.