[cairo] Wanted features in Cairo.

Carl Worth cworth at cworth.org
Wed Jun 27 13:20:38 PDT 2007


On Mon, 25 Jun 2007 14:10:57 -0400, Miguel de Icaza wrote:
>     As part of our effort to implement Silverlight in Linux we have run
> into a few things that would be nice to have in Cairo and Behdad
> suggested that I post these to the list.

Hi Miguel!

Thanks so much for bringing the discussion here. I had heard that you
Silverlight folks were thinking about using cairo, but I hadn't heard
any discussion here so I didn't know if that was going forward, or if
you had run into any problems.

I'm glad to see a little of both here, now, and I hope we can help.

> * Line caps
>
>     A feature that we are currently missing is the ability to use
> different line caps for the beginning and end of a drawing.   Cairo
> currently only offers one option: cairo_set_line_cap and we would need
> to have separate versions for the beginning and end.

So it would be fairly simple to add new cairo_set_initial_line_cap and
cairo_set_final_line_cap functions, (and to define cairo_set_line_cap
to simply set both to the same value). As has been brought up earlier,
one question is whether you would want additional control for the
capping of the dashes.

And, meanwhile, something we've had on our TODO list for about forever
is a means to allow the user to provide custom caps of some form or
another, (for example, arrowheads). But I'm still not entirely sure
what that support might look like.

> 	set_source_rgb
> 	set_source_rgba    <- With alpha
>
> 	set_source	   <- from pattern
> 	set_source_surface <- from surface
>
>     We would like to have parity in set_source and set_source_surface in
> terms of using the pattern/surface with an alpha channel.

I'm not sure I'd describe that as missing parity. Both
cairo_set_source and cairo_set_source_surface will respect whatever
alpha values you have in the pattern or surface.

I don't think we want to start down a slippery slope of putting
arbitrary rendering within set_source calls. Patterns are for reading
_from_, and if you want to draw something new, that's what surfaces
are for.

>     It is not absolutely mandatory to have them, but it would clean up
> some of the code that we have right now and the creation of temporary
> buffers to get the painting on the screen with alpha transparency.

Well, cairo does provide things like the group interface to simplify
some of the pain of creating temporary buffers. For example, you might
get a "set surface+alpha as source" with something like:

	cairo_push_group (cr);
	cairo_set_source_surface (cr, x, y);
	cairo_paint_with_alpha (cr, alpha);
	cairo_pop_group_to_source (cr);

Would that approach help simplify your code? Also, you might preface
that with:

	cairo_rectangle (cr, x, y, surface_width, surface_height);
	cairo_clip (cr);

to make sure that group stuff doesn't create an intermediate surface
any larger than necessary, (we haven't yet optimized the group stuff
to be clever with using minimal intermediate surfaces).

> We will try to provide some more feedback as we get more solid data for
> you guys regarding performance.

I'll definitely look forward to that.

-Carl
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: not available
Url : http://cairographics.org/archives/cairo/attachments/20070627/4818e63b/attachment.pgp 


More information about the cairo mailing list