Cairo, Gtk+, Gdk & GdkPixbuf -- making a pixel-based backing store for vector graphics



I would like to be able to make a code that draws some (possibly very
complex) vector graphics, copies it to an off-screen backing store and
then when an expose-event (Gtk2) or draw signal (Gtk3) is received,
the backing store is copied to the screen rather than doing a complete
redraw of all the vectors which could potentially take several
seconds. Unfortunately all the potential model codes I've been able to
find use the obsolete Gdk Pixmap as backing store.

Likewise the routine that looks promising
gdk_pixbuf_render_to_drawable () is marked as deprecated (since 2.4)
and suggests gdk_draw_pixbuf () as an alternative. However that is
also marked deprecated (since 2.22) and recommends
gdk_cairo_set_source_pixbuf() and cairo_paint() or cairo_rectangle()
and cairo_fill() but it is not at all clear how to combine those
routines to produce the required effect.

I have searched many times for suitable examples and come up empty. So
does anybody here have any suggestions, examples or link that provide
pointers to the following operations?:

1) Getting cairo to draw to a pixmap or pixbuf, or draw to a window
and then copy the resulting window contents to an in-memory storage.

2) Making the expose handler copy that pixbuf (or whatever) to the
visible window (while only copying the affected region  would be the
best option I can live with copying the whole window).

3) (Less important for now) Adding new material to the plot and
updating the backing store -- my guess is that once I crack 1 & 2 then
3 will be fairly obvious.

James



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