[cairo] Crash with very large image surface

Alexander Larsson alexl at redhat.com
Tue May 23 04:29:39 PDT 2006


On Tue, 2006-05-23 at 01:20 -0400, Laszlo Pandy wrote:
> I am a developer with Jokosher (www.jokosher.org), an audio editing 
> application. We are currently using cairo to draw the (very beautiful) 
> waveforms, for which the image width depends on the length of the song. We 
> also want to have a zoom feature allowing the width to be increased almost 
> infinitely, to see the detailed levels in the audio. At first we drew 
> straight to the screen, but that was taking too long to redraw, so we are now 
> using an image surface which is redrawn periodically.
> 
> My problem is that any image surface with a width over 32000 pixels causes an 
> X server "BadAlloc" error. It complains that is it out of memory after 
> setting the source surface to the large image surface and calling 
> cairo_paint(). This also happens after using cairo_clip() on a small (100 by 
> 100) rectangle.

Why do you have to allocate such a large cairo image? You never need a
larger one than the width of the app window. Why don't you just allocate
one of that width and set the cairo matrix to shift it to the current
position. 

The clip doesn't really affect the size of the backing store for the
cairo surface. The clip can change at any time, and we have to remember
information outside the current clip region.

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
 Alexander Larsson                                            Red Hat, Inc 
                   alexl at redhat.com    alla at lysator.liu.se 
He's an obese day-dreaming assassin in a wheelchair. She's a man-hating 
hypochondriac queen of the dead fleeing from a Satanic cult. They fight crime! 



More information about the cairo mailing list