[cairo] Idle thoughts on error propagation
chris at chris-wilson.co.uk
Fri May 9 00:38:14 PDT 2008
On Thu, 2008-05-01 at 15:13 -0700, Carl Worth wrote:
> I can imagine a case where this could be wrong.
> The cairo_t context is conceptually transient for what could be a
> long-standing surface. For example, if I had an application creating a
> new context for the same surface on every expose event, would it be
> correct to force the surface to shutdown due to an error on the
I think we use surfaces in two entirely different ways and want
different error behaviour for each.
First, we have the long-lived surfaces that, for example, are bound to a
window and thus are used repeatedly as the target of multiple cairo_t.
As this is a destination, we don't care about error propagation and
having to rebuild the surface would be a hindrance (and error-prone).
The second case, we have short-lived surfaces that are used as
intermediate sources. These crucially require error propagation (or a
rigorous handling of errors by the application). However, I think this
could be satisfied by promoting this idiom:
_construct_source (cairo_surface_t *target)
surface = cairo_surface_create_similar (target, CAIRO_CONTENT_COLOUR, width, height);
cr = cairo_create (surface);
surface = cairo_surface_reference (cairo_get_target (cr));
More information about the cairo