GNOME Bugzilla – Bug 659944
Add API to get the image surface
Last modified: 2021-06-10 11:17:49 UTC
Would be good if one could get the image surface from a GtkClutterActor to play with it using Cairo, e.g. to clip the corners. IRC discussion: 12:28 < pochu> can I somehow clip the corners of a GtkClutterActor using cairo instead of cogl? I've thought about creating a ClutterCairoTexture subclass, draw the GtkWidget onto the cairo surface and clip the corners with cairo, but then I'd have to forward the events myself 12:34 <@ ebassi> pochu: no idea 12:35 <@ ebassi> on x11 we use the X11 Pixmap and the texture_from_pixmap extension 12:35 <@ ebassi> and clipping could be performed by Cairo 12:35 <@ ebassi> but not without going deep into the guts of clutter-gtk 12:35 <@ ebassi> could be interesting to add API for that for 3.4 12:41 < pochu> what if there was another GtkClutterFoo similar to GtkClutterActor but that used cairo for drawing, e.g. by subclassing ClutterCairoTexture? 12:42 <@ ebassi> a) I wouldn't subclass CairoTexture *ever* 12:42 <@ ebassi> b) using an image surface would be the fallback path for GtkClutterActor on platforms without the texture_from_pixmap extension 12:43 <@ ebassi> I have code for b) but I need to clean that up and test it
just to clarify: GtkClutterActor does not use an image surface. right now, we're creating a GdkOffscreenWindow and using it as the parent of the widget's own window, so that rendering is performed inside a X11 Pixmap wrapped in a Cairo X11 surface. we extract the Pixmap and assign it to a ClutterX11TexturePixmap, which then handles everything for us. it might be possible to have a ::draw-like signal that gives you some degree of control, but it's not going to be pretty at all; plus it'll probably have a performance impact: right now, in the best case scenario, there is no copy going on between GTK painting the widget offscreen and Clutter rendering it (that's the whole point of using the GLX_EXT_texture_from_pixmap extension), but if you start by applying a clip mask then it might end up doing at least a copy. one option might be being able to retrieve the Cogl material used by the ClutterX11TexturePixmap wrapped by a GtkClutterActor, and use multi-texturing to apply some form of mask. another option is to do what Mutter does with the MetaShapedWindow class to paint the AA egdes.
GNOME is going to shut down bugzilla.gnome.org in favor of gitlab.gnome.org. As part of that, we are mass-closing older open tickets in bugzilla.gnome.org which have not seen updates for a longer time (resources are unfortunately quite limited so not every ticket can get handled). If you can still reproduce the situation described in this ticket in a recent and supported software version of clutter-gtk, then please follow https://wiki.gnome.org/GettingInTouch/BugReportingGuidelines and create a ticket at https://gitlab.gnome.org/GNOME/clutter-gtk/-/issues/ Thank you for your understanding and your help.