[cairo] Mesh gradients

Adrian Johnson ajohnson at redneon.com
Sun Sep 6 05:45:11 PDT 2009


I've updated the mesh gradient API on my mesh branch[1] to change the 
set corner color and set control point API to:

void
cairo_pattern_set_corner_color_rgb[a] (cairo_pattern_t *pattern,
				       int point_num,
				       double red, double green,
                                        double blue);
void
cairo_pattern_set_control_point (cairo_pattern_t *pattern,
				 int point_num,
    				 double x,
    				 double y);

I found this change to be easier and less confusing to use. The complete 
API is at the end of this message. The gtk-doc dcoumentation in the code 
documents the use of this API. The mesh branch also includes some 
patches from Andrea to fix some bugs.

I've updated the cairo backend of poppler to use cairo mesh gradients[2] 
for PDF Type 4,5,6, and 7 shadings. Some sample renderings of PDF files 
using this poppler-cairo branch are at:

http://people.freedesktop.org/~ajohnson/mesh/

monkey.png, rendered from monkey.pdf, is from laidout [3]. The others 
are from smooth shading samples [4] converted to PDF then rendered with 
poppler-cairo. Some of these have a few white pixels in them. I have not 
worked out what is causing that.

Any comments on this API and the implementation? Should the mesh 
gradient rasterizer be moved into pixman?


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

[2] http://cgit.freedesktop.org/~ajohnson/poppler/log/?h=mesh

[3] http://www.laidout.org/

[4]http://partners.adobe.com/public/developer/en/ps/sdk/sample/smooth.zip


Complete Mesh gradient API
--------------------------

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_set_corner_color_rgb (cairo_pattern_t *pattern,
				    int point_num,
				    double red, double green,
                                     double blue);

void
cairo_pattern_set_corner_color_rgba (cairo_pattern_t *pattern,
  				     int point_num,
				     double red, double green,
                                      double blue, double alpha);

void
cairo_pattern_set_control_point (cairo_pattern_t *pattern,
				 int point_num,
    				 double x,
    				 double y);

cairo_status_t
cairo_pattern_get_patch_count (cairo_pattern_t *pattern,
			       int *count);

cairo_path_t *
cairo_pattern_get_path (cairo_pattern_t *pattern,
			int patch_num);

cairo_status_t
cairo_pattern_get_corner_color_rgba (cairo_pattern_t *pattern,
			       int patch, int corner,
			       double *red, double *green,
			       double *blue, double *alpha);

cairo_status_t
cairo_pattern_get_control_point (cairo_pattern_t *pattern,
				 int patch, int point,
				 double *x, double *y);




More information about the cairo mailing list