Skip to content

Cairo in GTK

marksvc edited this page Jun 17, 2021 · 1 revision

Note: This page contains old documentation from 2006, but may still be helpful. And it would still be okay to update, correct, and add to this page.

Cairo surfaces in GTK can have a limited lifetime. This can lead to unexpected problems when drawing. More specifically, the drawable surface used in an expose event is used for double buffering and is discarded at the end of the event. This means that the target of any Cairo context created using the drawable from an expose event will become invalid after the end of the event and cannot be used across multiple events. To avoid problems, gdk_cairo_create (for gtk) or create_cairo_context (for gtkmm 2.10+) must be used on every expose event. This information was obtained from this newsgroup thread

Cairo is a vector graphics library designed to provide high-quality display and print output.

Clone this wiki locally