Smithay / smithay

A smithy for rusty wayland compositors
MIT License
1.85k stars 160 forks source link

`PixmanTexture` is not `Send` #1500

Open ids1024 opened 2 months ago

ids1024 commented 2 months ago

Might as well have an issue for this.

PixmanTexture not being Send makes it impossible to use with MemoryRenderBuffer (as I noticed in https://github.com/Smithay/smithay/pull/1497), and is otherwise awkward.

Looking at pixman's implementation, pixman_image_t is not thread safe since it is ref-counted. In a way that isn't thread-safe. pixman_image_ref isn't currently bound by the pixman crate. But it is used once internally in pixman: for pixman_image_set_alpha_map.

I think it should be safe to Send a pixman image that has a reference count of 1, and if it has an alpha map, that also has a reference count of 1.

I see a couple ways to achieve this:

ids1024 commented 2 months ago

It seems much cleaner to implement this in the pixman crate, if it's okay to have such a restriction there. So https://github.com/cmeissl/pixman-rs/pull/18 makes the changes I think are necessary for this.