[java-gnome-hackers] Cairo Contexts clipped to expose region
Brought to you by:
afcowie
From: Andrew C. <an...@op...> - 2010-09-09 02:22:38
|
I've introduced a new [org.freedesktop.cairo] Context constructor, taking an [org.gnome.gdk] EventExpose as obtained during a Widget.ExposeEvent signal handler. Before you did: d.connect(new Widget.ExposeEvent() { public boolean onExposeEvent(Widget source, EventExpose event) { final Window underlying; final Context cr; underlying = source.getWindow(); cr = new Context(source); ... Now you can do d.connect(new Widget.ExposeEvent() { public boolean onExposeEvent(Widget source, EventExpose event) { final Context cr; cr = new Context(event); ... (it turns out GtkEventExpose has the needed GdkWindow in it, hence making it possible for this to be even simpler) Down in the C code this calls gdk_cairo_region() and then cairo_clip(), meaning that Cairo will only actually draw that which is actually damaged and exposed, not the entire XWindow. yeay. Thanks to Benjamin Otte for his help, notably in this thread http://lists.cairographics.org/archives/cairo/2010-August/020596.html and on IRC. AfC Sydney |