[cairo] Cairo, GtkDrawingArea, and buffer

Stefan Salewski mail at ssalewski.de
Sun Feb 27 05:32:00 PST 2011


On Sun, 2011-02-27 at 13:50 +0800, Xi Yang wrote:
> Hi, everyone!
> I want to have a customized widget, and I decided to use
> GtkDrawingArea and Cairo together. 
> 
> 
> However, each time the GtkDrawingArea is resized or uncovered, it
> needs to be redrawed. I don't want to perform the Cairo drawing at
> each exposure_event, as my drawing procedure is pretty complicated.
> 
> 
> I need a buffer which the cairo_t would build on. At each
> exposure_event, I just need to copy the buffer to the GtkDrawingArea.
> So how can I achieve that? Which classes should I use?
> 
> Thanks!
> 

I had a similar task and wrote a small demo in Ruby, followed by some
discussions on this list:

http://www.ssalewski.de/PetEd-Demo.html.en

http://comments.gmane.org/gmane.comp.lib.cairo/20967

Works not too bad, if we define a bounding box for each or at least the
complicated objects, and draw only these objects which overlap with the
visible area. Maybe that is a starting point for you -- I do use a
buffer. Based on this thread:

http://lists.cairographics.org/archives/cairo/2009-March/016756.html




More information about the cairo mailing list