[cairo] API proposal: cairo_format_from_content and cairo_content_from_format

Behdad Esfahbod behdad at behdad.org
Mon Apr 23 14:32:39 PDT 2007


On Mon, 2007-04-23 at 13:32 -0700, Carl Worth wrote:
> On Thu, 19 Apr 2007 23:57:06 -0400, Behdad Esfahbod wrote:
> > I want to propose making the two functions public in 1.6.  They are
> > pretty well-defined, but I agree that they are not the most useful
> > functions for user programs.
> 
> I'm confused on both points.
> 
> 1. How is cairo_format_from_content well-defined?

It will return the format of an image surface created using
create_similar() with a specific content.

>    There's already not a one-to-one correspondence between formats and
>    content, (does CONTENT_ALPHA map to FORMAT_A8 or FORMAT_A1 ?), and
>    this will only get worse as we add more format types.

Given the definition above, it's apparently something image-surface
centric.  I was ignoring that until Max showed us how OO.o has the two
following functions implemented:

Format cairoHelperFormatFromContent(Content aContent);
int cairoHelperX11FormatFromContent(Content aContent);

Now that makes a lot more sense.

>    It was exactly for the reason that we expected to add more formats
>    in the future that we decided to separate the notions of content
>    and format.

The hinging point is that create_similar takes content, while other
surface constructors take some kind of format.  It's not hard to imagine
the conversion being needed.


> 2. Given "they are not the most useful functions for user programs",
>    what's the point of discussing this? Let's talk again when a user
>    has a need that can't be met with the current API, OK?

Of course it's totally possible to meet any need for these functions
with current cairo API: just copy the switch as OO.o did.  As for
myself, I saw three copies of that switch in cairo-boilerplate/, so
thought I write to the list while adding
cairo_boilerplate_format_from_content().


> -Carl
-- 
behdad
http://behdad.org/

"Those who would give up Essential Liberty to purchase a little
 Temporary Safety, deserve neither Liberty nor Safety."
        -- Benjamin Franklin, 1759





More information about the cairo mailing list