[cairo] Gradient mesh rasterizer

Adrian Johnson ajohnson at redneon.com
Thu Jul 30 06:14:53 PDT 2009


Andrea Canciani wrote:
> On Mon, Jul 27, 2009 at 10:31 PM, Andrea Canciani<ranma42 at gmail.com> wrote:
>> I updated my code to be pixel perfect when painting a square (the file
>> pattern.c does exactly this: it paints a 768 x 768 square tile and
>> reports for any incorrect pixel).
>> I also have this code as a patch against the mesh branch.

The mesh branch is at:

http://cgit.freedesktop.org/~ajohnson/cairo/log/?h=mesh

Currently the image, PDF, and PostScript backends are working. The new 
API is:

cairo_pattern_t *
cairo_pattern_create_mesh (void);

void
cairo_pattern_begin_patch (cairo_pattern_t *pattern);

void
cairo_pattern_end_patch (cairo_pattern_t *pattern);

void
cairo_pattern_curve_to (cairo_pattern_t *pattern,
			double x1,
  			double y1,
  			double x2,
  			double y2,
  			double x3,
  			double y3);

void
cairo_pattern_line_to (cairo_pattern_t *pattern,
  		       double x,
  		       double y);

void
cairo_pattern_move_to (cairo_pattern_t *pattern,
  		       double x,
  		       double y);

void
cairo_pattern_add_control_point (cairo_pattern_t *pattern,
  				 double x,
  				 double y);

Currently the the cairo_pattern_add_color_stop_rgb[a] functions are used 
for adding color stops. After each side of a patch is specified, using 
cairo_pattern_curve_to() or cairo_pattern_line_to(), 
cairo_pattern_add_color_stop_rgb[a] can be used to add one or more stops 
along the current side.

However at present both the gradient rasterizer and the PDF/PS backends 
only allow color stops on the corners of the patch. Only the first stop 
specified for each side is used and is assumed to be at offset 0.

I'm not sure if the API should be changed to allow only color stops on 
the corners, or if stops should be allowed anywhere on the sides and 
then subdivide the patch at the stops when rendering or embedding in PS/PDF.



More information about the cairo mailing list