[cairo] Cleaning up the PDF API

Kristian Høgsberg krh at bitplanet.net
Mon May 16 08:41:13 PDT 2005


On Thu, 2005-05-12 at 15:50 -0700, Carl Worth wrote:
> The interface in cairo-pdf.h needs a little bit of cleaning up. Some
> of this we've discussed before. Here are the issues I see:
> 
> 1) cairo_pdf_surface_create should accept a "const char *filename"
>    rather than a FILE*.

This change is still missing, I'll do that now.

> 5) Why does cairo_pdf_surface_create_for_callback require a
>    cairo_destroy_func_t? This adds extra pain in using the interface,
>    and couldn't the same result be achieved by means of
>    cairo_surface_set_user_data? If we eliminate that function, then
>    we'd have good consistency among the three current "for_stream"
>    functions, (all would accept either a cairo_write_func_t or a
>    cairo_read_func_t and then a void *closure).

No, this is different.  The cairo_destroy_func_t passed in here is
called when cairo_surface_finish() is called on the surface.  It's
responsible for e.g. flushing out any buffers and fclose()'ing FILE's at
the time we know that no more output will be going to the stream.  The
actual destruction of the surface may occur much later (because of e.g.
garbage collection taking place at a later time).

cheers,
Kristian





More information about the cairo mailing list