[cairo] newbie clipping question

Owen Taylor otaylor at redhat.com
Sun Oct 15 11:45:32 PDT 2006


On Sun, 2006-10-15 at 11:32 -0700, David L wrote:
> I'm writing a gtk+ app with cairo that has a zoom function.
> When I zoom way in on the cairo drawing area, the redraws
> become extremely slow.  There's an example application below
> that demonstrates my problem.  It draws a line from (0,0) to
> (10*zoom, 10*zoom), where zoom is variable and controled
> by the mouse wheel.  When the zoom level is high (most of
> the line is outside the clipping rectangle), redraws are really
> slow and my whole X-windows environment is not very responsive.
> 
> Am I doing something wrong, or is it just not possible to have
> the clipping rectangle be a very small fraction of the drawn
> image?

I think things will be much better if you confine yourself
to drawing in your expose handler. GTK+ will provide cairo
with a good idea of what it needs to draw and doesn't in that
case.

(See gdk_window_invalidate_rect() for how to trigger exposes
on application content changes.)

Still, cairo isn't very smart about clipping out geometry
early the rendering pipeline ... I'd expect big lines to be
OK, but big curves or complex geometry are going to be slow.

					- Owen




More information about the cairo mailing list