Re: XShmPixmap for GdkPixmap



On Wed, 2007-05-23 at 12:20 -0400, Tristan Van Berkom wrote:

> I'm currently considering a hack where I will simply do:
>      - load pixbuf
>      - put the pixbuf in a GdkImage (GdkImage already uses XShmPixmap)
>      - use gdk_pixmap_foreign_new() on _gdk_x11_image_get_shm_pixmap()
> 
> When it struck me, would it not be a good thing if all GdkPixmaps used
> XShmPixmap where possible ? (i.e. server extention available && running
> locally)

No:

 A) Shared memory is a limited resource, though less so these days
    (Solaris used to have really low per-process and system limits)
 B) There is a lot of overhead setting up a shared memory segment 
 C) Many, many pixmaps are created temporarily for only a few
    drawing operations.
 D) Shared pixmaps can't be put into video card memory, so drawing
    to them is never accelerated.
 E) If you use shmpixmaps *shared*, the synchronization can be more
    costly then the performance gain.

It would probably make sense to have a way of creating a GdkImage /
GdkPixmap pair as a might-fail operation; it's particularly useful
for fetching data *from* the server, for one thing, and sometimes
you have a good reason for wanting to keep a pixmap out of video
memory.

Probably should even be cross-platform since the same thing makes
sense on Windows.

					- Owen

A) _gdk_x11_image_get_shm_pixmap() will not be accessible from
your app. That's what the _ means

B) I'm not of the generally opinion that keeping around pixmaps for
images you want to draw repeatedly is a good idea. 

It *does* produce some performance wins for big images ... the basic
conclusion of the measurements in:
http://lists.freedesktop.org/archives/xorg/2006-September/017897.html
is that if your images are bigger than your memory cache size,
then the number of times that the image data is touched when drawing
is important ... but just keeping the data in the client isn't
noticeably slow, and pushing application data either into the X server
or into shared memory segments just isn't being a good citizen of
the overall system.





[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]