[cairo] surfaces and backends
Carl Worth
cworth at cworth.org
Fri Feb 24 13:36:13 PST 2006
On Fri, 24 Feb 2006 12:52:51 -0800, "Vladimir Vukicevic" wrote:
>
> I've been thinking about a cairo_surface_is_xlib()
> cairo_surface_is_win32() API instead...
Obviously, that's what exists internally already. And I've liked that
for the same reason you want it, (it makes the type advertising local
to a specific backend).
But, there are different uses that will find either of the two styles
much more convenient. For example, an assertion before calling a
backend-specific function is easiest with an is_of_type predicate,
while wrapper-creation in a language binding really wants the get_type
function.
And it's worth noting that implementing is_of_type on top of get_type
is trivial:
get_type() == TYPE_OF_INTEREST
while implementing get_type on top of is_of_type is extremely awkward:
if (is_xlib())
return TYPE_XLIB:
else if (is_image())
return TYPE_IMAGE;
else if (is_quartz())
return TYPE_QUARTZ;
...
as Owen pointed out in the bugzilla report.
> It also means that cairo.h ends up having
> backend-specific types/defines in there.
Yeah, that is ugly.
That's what makes Behdad's suggestion interesting. We can do get_type
but use the linker to get unique names, (not unlike
cairo_user_data_key_t in that sense), rather than an enumerated type.
That has the benefit of keeping backend-specific names outside of
cairo.h.
-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20060224/c721c6d6/attachment.pgp
More information about the cairo
mailing list