Re: cairo drawing commands to gdk_invalidate_region



On Tue, 2010-08-17 at 10:35 +0300, Dov Grobgeld wrote:
> Assume I have a routine:
> 
>     int draw(cairo_t *cr)
> 
> used to draw an overlay in a GdkWindow. 
> 
> In order to minimize redrawing, I would like to get the minimal (up to
> some accuracy to be determined) set of GdkRegion's that encompasses
> all the drawing of draw(). 
> 
> I thought of doing this by creating a low resolution cairo image
> surface that I pass to draw() and check if pixels are "dirty" in which
> case it indicates that the corresponding rectangle in the source
> GdkWindow needs to redrawn.
> 
> Is there a better method?

Just call

  gdk_cairo_region (cr, event->region);
  cairo_clip (cr);

right after creating the context, and after that, draw as if you didn't
need to care about the dirty regions at all. The clipping will take care
of the rest. This assumes that you only draw as a response to your
expose-event handler, of course.

Claudio


-- 
Claudio Saavedra <csaavedra gnome org>



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