[cairo] Subject: ImageSurfacePattern disappears with a large enough scale factor
Michel Iwaniec
michel_iwaniec at yahoo.com
Thu Oct 30 15:02:47 PDT 2008
I seem to have run into some bug/precision limit in Cairo when trying to upscale an ImageSurfacePattern too much.
My application renders grayscale images from vector data by clipping the polygons to each pixel of the image and performing area sampling. It then displays the original vector data, pixel gradients, and a pixel grid layered on top of the grayscale image. By doing this, it provides an evaluation framework for comparing approximate area sampling methods on a GPU. It is therefore very important to be able to zoom in closely on each grayscale pixel. To do this, I'm using an ImageSurfacePattern which is tied to an ImageSurface and is transformed by a matrix.
I recently tried to speed up the handling of window expose events by drawing to a Cairo ImageSurface instead, but this work led to a dead end since drawing to an ImageSurface instead of directly to a GtkDrawingArea would make my image disappear when zooming in too much.
So today, I upgraded from Ubuntu 8.04 to Ubuntu 8.10, hoping the bug would be fixed in the newer Cairo libraries that followed with it. But instead of being fixed, the bug now appears when I draw directly to a GtkDrawingArea as well!
Here are some images of what happens:
http://www.student.itn.liu.se/~miciw347/cairo_bug_1.png - At this zoom level, things still look ok
http://www.student.itn.liu.se/~miciw347/cairo_bug_2.png - When zooming in more, the ImageSurfacePattern starts being misaligned with the grid.
http://www.student.itn.liu.se/~miciw347/cairo_bug_3.png - And when zooming in yet some more, the ImageSurfacePattern disappears completely.
As a side note, I had a similar problem earlier with my grid lines disappearing when zooming in too much on them. The solution was to clip them manually in software before drawing them. So it seems this is some general precision limit in Cairo. A wild guess of mine is that it might be due to hardware acceleration? In that case, is there some easy way to make Cairo use software rendering and still let the rest of my application use OpenGL?
Regards,
Michel Iwaniec
More information about the cairo
mailing list