[cairo] mime-surface

Benjamin Otte otte at gnome.org
Wed Nov 19 01:58:03 PST 2008


Yay, that was fast. And it looks pretty much perfect to me. Some tiny
nitpicks on the API:

> static cairo_status_t
> decode_png (cairo_surface_t *surface,
>            const char *mime_type,
>            cairo_surface_t *_image)
>
I don't think we need to pass the mime type here. And if you need it
you can cairo_surface_set_user_data() it beforehand.
I'm also not sure if passing an image surface or data/stride is better
here. I guess an image surface is preferrable, even though it allows
more nasty tricks by the decoding function (like creating a cairo_t on
it or acquiring a reference and using the image surface for other
nefarious purposes later).

You didn't investigate the idea of giving the decoder a rectangle of
the area of interest to decode?
I think the usefulness of this was one of the open points we still had.
But we can still add it later using
cairo_mime_surface_set_region_decode_function() or so.

>    if (mime_data == NULL)
>        return _cairo_error (CAIRO_STATUS_NULL_POINTER);
>
_cairo_error() is internal API, so you likely want to just return
CAIRO_STATUS_NULL_POINTER here and do an
if (status)
  _cairo_error(status);
after returning from the user-provided callback, right?

>   surface = cairo_mime_surface_create (content,
>                                        CAIRO_MIME_TYPE_PNG,decode_png,
>                                        width, height);
>
I think specifying width/height on surface creation is fine, but I'm
just one user - or two, if you count my gdk-pixbuf knowledge, where it
should be fine, too - You'd defer creating the surface until the size
of the image is known. But is there a use case for determining the
size using a callback and/or during the decode function?

> Is the simple interface both minimal and sufficient for expected users?
>
It's certainly minimal enough. I think other things could be added
later by extending the mime surface API if we figure out we need
something.

Cheers,
Benjamin


More information about the cairo mailing list