[cairo] API Shakeup: Making set_source consistent, (renaming cairo_set_rgb_color and cairo_set_pattern, eliminating cairo_set_alpha)

Carl Worth cworth at cworth.org
Thu Apr 14 13:56:13 PDT 2005


On Wed, 13 Apr 2005 22:35:14 +0200, David Reveman wrote:
> I haven't looked at your patch yet but color stop interpolation have to
> be done to unpre-multiplied colors. At least if we want to match other
> SVG renderers (I don't know what the SVG spec says about this). So for
> this to work my gradient code in cairo_pattern.c is pre-multiplying
> colors after interpolation so you'll need to give it unpre-multiplied
> color stops.

Yes, that is the issue here.

And I'm not really sure how to fix this. The interpolation as
currently implemented, (which also does agree with the W3C SVG test
suite), is quite intuitive. It allows gradients such as:

	opaque red -> transparent blue

to have the desired effect.

And this does require the colors to be available to the interpolator
in non-premultiplied form, (since otherwise a color stop with
alpha==0.0 such as "transparent blue" will have no color information
so the gradient above cannot be expressed).

So when I changed cairo_color_t to store its primary color information
in premultiplied form, (to allow cairo_set_source_rgba_premultiplied),
it broke the gradient interpolation.

I've now got a new cairo_set_source patch that fixes this bug, but
removes cairo_set_source_rgba_premultiplied and
cairo_pattern_add_color_stop_rgba_premultiplied in order to do so.

And I don't see an easy way to put them back. Well, doing just
cairo_set_source_rgba_premultiplied would be easy enough by having two
different color representations for premultiplied vs. not.

The hard part is trying to come up with gradient interpolation
semantics in the face of both pre-multiplied and non-pre-multiplied
colors. Anybody have any insight for me?

In the meantime, I think I'll land my patch without the premultiplied
variations so that I can move on to other issues.

-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/20050414/ad4133c2/attachment.pgp


More information about the cairo mailing list