After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 441853 - Add gdk_image_get_shared_pixmap()
Add gdk_image_get_shared_pixmap()
Status: RESOLVED OBSOLETE
Product: gtk+
Classification: Platform
Component: Backend: X11
unspecified
Other Linux
: Normal enhancement
: ---
Assigned To: gtk-bugs
gtk-bugs
Depends on:
Blocks: 562958
 
 
Reported: 2007-05-28 16:39 UTC by Tristan Van Berkom
Modified: 2010-08-11 03:48 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Add gdk_image_get_shared_pixmap() (5.65 KB, patch)
2007-05-28 16:50 UTC, Tristan Van Berkom
none Details | Review

Description Tristan Van Berkom 2007-05-28 16:39:08 UTC
Add support for MIT-SHM GdkPixmaps (to be returned by
GdkImage facilities).
Comment 1 Tristan Van Berkom 2007-05-28 16:50:38 UTC
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.
Comment 2 Yann Droneaud 2008-12-02 10:21:33 UTC
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().
Comment 3 Chris Wilson 2008-12-02 10:33:58 UTC
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?
Comment 4 Yann Droneaud 2008-12-02 11:02:29 UTC
(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.

Comment 5 Tristan Van Berkom 2008-12-02 15:12:41 UTC
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...)

Comment 6 Matthias Clasen 2010-08-11 03:48:12 UTC
GdkImage is gone in gtk3