GNOME Bugzilla – Bug 441853
Add gdk_image_get_shared_pixmap()
Last modified: 2010-08-11 03:48:12 UTC
Add support for MIT-SHM GdkPixmaps (to be returned by GdkImage facilities).
Created attachment 88949 [details] [review] Add gdk_image_get_shared_pixmap() Here's a patch against the gtk-2-10 branch (which is what I've been working with), I'm expecting it to apply cleanly against trunk as is but will ofcourse go on to test it... just submitting right away for review... - Adds gdk_image_get_shared_pixmap() for x11 & win32 platforms o win32 always uses a gdkpixmap in gdkimages so in this case we just return a reference. o on x11, we use gdk_pixmap_foreign_new() once if the GdkImage is shared and then return a reference to the internal GdkPixmap (the image owns the pixmap and releases it when destroyed) - Adds gdk_display_supports_shared_pixmaps(): returns TRUE if MIT-SHM pixmaps are available on that display.
I'd like to see this support in Gdk. You have my vote. Btw, the patch should be split: one for gdk_display_supports_shared_pixmaps() and another one for the gdk_image_get_shared_pixmap().
With my hat on as a cairo developer, I'd prefer to reduce the exposure of GdkPixmaps (and even GdkPixbuf) and encourage the adoption of cairo_surface_t throughout the gtk+ (and clients) code base. What is the current use case for GdkPixmaps, as opposed to caching a similar cairo_surface_t?
(In reply to comment #3) > With my hat on as a cairo developer, I'd prefer to reduce the exposure of > GdkPixmaps (and even GdkPixbuf) and encourage the adoption of cairo_surface_t > throughout the gtk+ (and clients) code base. What is the current use case for > GdkPixmaps, as opposed to caching a similar cairo_surface_t? > In all other case, I'm OK for using Cairo, with the x11 shm surface: http://www.ericbutler.net/blog/2008/06/cairo-xlib-and-the-shared-memory-extension/ In my case, I need a GdkPixmap (in fact a GdkBitmap, which is also a GdkDrawable :), for gdk_window_shape_combine_mask(). See bug #562958 I only need a way to create an X11 Shm Pixmap usable with GDK without the burden of: - detecting SystemV IPC - detecting MIT-SHM extension - calling XShmCreateImage() - calling shmget(), shmat() - attaching the shared memory region in the serveur with XShmAttach() - creating a Pixmap with XShmCreatePixmap() - creating a GdkPixmap with gdk_pixmap_foreign_new() Since there is already code to do this in GDK.
FWIW, I wrote that a long time ago, but the reasoning was a.) to let us load image data into pixmap with reduced server round trips. b.) to allow us to free large quantities of pixmaps. Using shared pixmaps instead of server allocated pixmaps meant that when we freed the pixmaps, the shared memory would immediately be freed, freeing lots of pixmaps in the server results in a highly fragmented memory region belonging to the X server (that memory will be reused next time we allocate hundreds more little album cover images to browse the other music selection...)
GdkImage is gone in gtk3