[cairo] API Shakeup: Eliminating cairo_surface_set_repeat/matrix/filter

David Reveman davidr at novell.com
Fri Feb 25 04:54:02 PST 2005


On Wed, 2005-02-23 at 10:43 -0500, Carl Worth wrote: 
> There has long been an API wart left over from before we had a
> distinct notion of a pattern separate from a surface. Now that we're
> doing this API shakeup, I propose finally acting on that comment in
> cairo.h and eliminating the following functions:
> 
> 	cairo_surface_set_repeat
> 	cairo_surface_set_matrix
> 	cairo_surface_get_matrix
> 	cairo_surface_set_filter
> 	cairo_surface_get_filter
> 
> I was going to propose replacement cairo_pattern functions for each of
> these, but I just realized we have had them since the pattern stuff
> landed, we've just been carrying the old surface cruft along this
> whole time.
> 
> One thing I do want to revisit during the shakeup is the mechanism for
> specifying the color values that patterns provide "outside" their core
> region, (eg. surface data or gradient within the [0..1] range of color
> stops). What we currently have in cairo is:
> 
> 	typedef enum {
> 	    CAIRO_EXTEND_NONE,
> 	    CAIRO_EXTEND_REPEAT,
> 	    CAIRO_EXTEND_REFLECT
> 	} cairo_extend_t;
> 
> Which is noticeably missing a value to indicate padding out with the
> border color, (or equivalently, that the nearest defined color should
> be chosen). Looking at glitz, it looks like it provides that extra
> value, and it also has a better name of TRANSPARENT instead of NONE.
> 
> So, I propose changing the enum to:
> 
> 	typedef enum {
> 	    CAIRO_EXTEND_TRANSPARENT,
> 	    CAIRO_EXTEND_NEAREST,
> 	    CAIRO_EXTEND_REPEAT,
> 	    CAIRO_EXTEND_REFLECT
> 	} cairo_extend_t;
> 
> -Carl

Good, I like that.

I've attached two libpixman patches that implements what we need to
fully support this:

libpixman-filter-update-1.diff - Filter updates I've committed to
xserver recently. Includes a few bug fixes, some minor optimizations and
convolution filter support.

libpixman-pad-reflect-1.diff - Implements extend types nearest and
reflect, so that all four of the above extend types can be used with
surface patterns.

This reminds me of a problem with Xrender/libpixman that needs to be
solved. If no convolution filter or transformation is set for a source
picture/image the composite clip is intersected by the bounds of this
surface. This means that non-repeating extend types won't work correctly
(e.g. when using SRC op and extend type TRANSPARENT). 
In libpixman, we could probably just change the implementation to not
intersect the composite clip by source image bounds. If we want to be
backward compatible, a flag that could be set with
pixman_image_restrict_composite_clip (image, bool) or something similar
would work.


And one cairo patch:

cairo-extend-type-update-1.diff - Add support for extend type
TRANSPARENT to gradients and minor changes to fully support these four
extend types for all patterns. This patch requires that all my pending
patches for cairo are first applied.

-David
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libpixman-filter-update-1.diff
Type: text/x-patch
Size: 11598 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050225/48a9c11f/libpixman-filter-update-1.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: libpixman-pad-reflect-1.diff
Type: text/x-patch
Size: 9866 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050225/48a9c11f/libpixman-pad-reflect-1.bin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: cairo-extend-type-update-1.diff
Type: text/x-patch
Size: 8628 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050225/48a9c11f/cairo-extend-type-update-1.bin


More information about the cairo mailing list