Re: handling pixmaps




Tony Gale <gale@daedalus.dera.gov.uk> writes:

> Would some kind sole explain the mysteries of pixmaps to me. I
> basically want to plot position's onto a map. So, I have a contour
> map in xpm format, and have created a drawing area to plot it on and
> a backing pixmap to save on flicker.
> 
> So, the process (I think) would be to copy the map pixmap onto the
> backing pixmap, and then plot the positions (as circles or whatever)
> over the top - and then copy this backing pixmap to the drawing area
> (and handle expose event's).
> 
> Repeat when the positions change.
> 
> If someone could show me how to do this I would be most grateful.
> Also, the loading of the map pixmap takes an age (using both
> gdk_pixmap_create_from_xpm and gdk_pixmap_create_from_xpm_d), how can
> I speed this up?

1) Use imlib

2) Improve gdk_pixmap_create_from_xpm_d

My current hypothesis for the extreme slowness of this function
comes from two sources:

 - It calls XAllocColor at least once, and maybe more times for
   every color in the Pixmap
 
 - When a mask is present, it draws each run of transparent
   pixels in the mask with a separate XDrawLine.

The XAllocColor calls are probably a bigger hit, since they
involve round-trips to the server. But it is hard to solve
this without keeping some sort of preallocated palette within
GTK and doing color matching oneself.

GDK could improve things somewhat by checking for exact
matches itself, and keeping an internal reference count on
colors - so that XAllocColor calls could be avoided when
GDK had already allocated the same color out of the same
colormap. (That would help enormously with benchmarking - 
load the same pixmap 1000 times, but might not help that
much in real life)

Regards,
                                        Owen






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