third_party/cairo/src/cairo-mesh-pattern-rasterizer.c
void
_cairo_mesh_pattern_rasterize (const cairo_mesh_pattern_t *mesh,
			       void                       *data,
			       int                         width,
			       int                         height,
			       int                         stride,
			       double                      x_offset,
			       double                      y_offset)
{
    cairo_point_double_t nodes[4][4];
    double colors[4][4];
    cairo_matrix_t p2u;
    unsigned int i, j, k, n;
    cairo_status_t status;
    const cairo_mesh_patch_t *patch;
    const cairo_color_t *c;

    assert (mesh->base.status == CAIRO_STATUS_SUCCESS);
    assert (mesh->current_patch == NULL);

    p2u = mesh->base.matrix;
    status = cairo_matrix_invert (&p2u);
    assert (status == CAIRO_STATUS_SUCCESS);

    n = _cairo_array_num_elements (&mesh->patches);
    patch = _cairo_array_index_const (&mesh->patches, 0);
    for (i = 0; i < n; i++) {
	for (j = 0; j < 4; j++) {
	    for (k = 0; k < 4; k++) {
		nodes[j][k] = patch->points[j][k];
		cairo_matrix_transform_point (&p2u, &nodes[j][k].x, &nodes[j][k].y);
		nodes[j][k].x += x_offset;
		nodes[j][k].y += y_offset;
	    }
	}

	c = &patch->colors[0];
	colors[0][0] = c->red;
	colors[0][1] = c->green;
	colors[0][2] = c->blue;
	colors[0][3] = c->alpha;

	c = &patch->colors[3];
	colors[1][0] = c->red;
	colors[1][1] = c->green;
	colors[1][2] = c->blue;
	colors[1][3] = c->alpha;

	c = &patch->colors[1];
	colors[2][0] = c->red;
	colors[2][1] = c->green;
	colors[2][2] = c->blue;
	colors[2][3] = c->alpha;

	c = &patch->colors[2];
	colors[3][0] = c->red;
	colors[3][1] = c->green;
	colors[3][2] = c->blue;
	colors[3][3] = c->alpha;

	draw_bezier_patch (data, width, height, stride, nodes, colors);
	patch++;
    }
}
/*
 * Draw a tensor product shading pattern.
 *
 * Input: mesh is the mesh pattern
 *        data is the base pointer of the image
 *        width, height are the dimensions of the image
 *        stride is the stride in bytes between adjacent rows
 *
 * Output: data will be changed to have the pattern drawn on it
 *
 * data is assumed to be clear and its content is assumed to be in
 * CAIRO_FORMAT_ARGB32 (8 bpc, premultiplied).
 *
 * This function can be used to rasterize a PDF type 7 shading (see
 * http://www.adobe.com/devnet/pdf/pdf_reference.html).
 */
Draw a tensor product shading pattern.
Input: mesh is the mesh pattern
data is the base pointer of the image
width, height are the dimensions of the image
stride is the stride in bytes between adjacent rows

data will be changed to have the pattern drawn on it

data is assumed to be clear and its content is assumed to be in
CAIRO_FORMAT_ARGB32 (8 bpc, premultiplied).


Draw a tensor product shading pattern . Input : mesh is the mesh pattern data is the base pointer of the image width height are the dimensions of the image stride is the stride in bytes between adjacent rows data will be changed to have the pattern drawn on it data is assumed to be clear and its content is assumed to be in CAIRO_FORMAT_ARGB32 ( 8 bpc premultiplied ) .
void
_cairo_mesh_pattern_rasterize (const cairo_mesh_pattern_t *mesh,
			       void                       *data,
			       int                         width,
			       int                         height,
			       int                         stride,
			       double                      x_offset,
			       double                      y_offset)
{
    cairo_point_double_t nodes[4][4];
    double colors[4][4];
    cairo_matrix_t p2u;
    unsigned int i, j, k, n;
    cairo_status_t status;
    const cairo_mesh_patch_t *patch;
    const cairo_color_t *c;
    assert (mesh->base.status == CAIRO_STATUS_SUCCESS);
    assert (mesh->current_patch == NULL);
    p2u = mesh->base.matrix;
    status = cairo_matrix_invert (&p2u);
    assert (status == CAIRO_STATUS_SUCCESS);
    n = _cairo_array_num_elements (&mesh->patches);
    patch = _cairo_array_index_const (&mesh->patches, 0);
    for (i = 0; i < n; i++) {
	for (j = 0; j < 4; j++) {
	    for (k = 0; k < 4; k++) {
		nodes[j][k] = patch->points[j][k];
		cairo_matrix_transform_point (&p2u, &nodes[j][k].x, &nodes[j][k].y);
		nodes[j][k].x += x_offset;
		nodes[j][k].y += y_offset;
	    }
	}
	c = &patch->colors[0];
	colors[0][0] = c->red;
	colors[0][1] = c->green;
	colors[0][2] = c->blue;
	colors[0][3] = c->alpha;
	c = &patch->colors[3];
	colors[1][0] = c->red;
	colors[1][1] = c->green;
	colors[1][2] = c->blue;
	colors[1][3] = c->alpha;
	c = &patch->colors[1];
	colors[2][0] = c->red;
	colors[2][1] = c->green;
	colors[2][2] = c->blue;
	colors[2][3] = c->alpha;
	c = &patch->colors[2];
	colors[3][0] = c->red;
	colors[3][1] = c->green;
	colors[3][2] = c->blue;
	colors[3][3] = c->alpha;
	draw_bezier_patch (data, width, height, stride, nodes, colors);
	patch++;
    }
}
void _cairo_mesh_pattern_rasterize ( const cairo_mesh_pattern_t * mesh , void * data , int width , int height , int stride , double x_offset , double y_offset ) { cairo_point_double_t nodes [ 4 ] [ 4 ] ; double colors [ 4 ] [ 4 ] ; cairo_matrix_t p2u ; unsigned int i , j , k , n ; cairo_status_t status ; const cairo_mesh_patch_t * patch ; const cairo_color_t * c ; assert ( mesh -> base . status == CAIRO_STATUS_SUCCESS ) ; assert ( mesh -> current_patch == NULL ) ; p2u = mesh -> base . matrix ; status = cairo_matrix_invert ( & p2u ) ; assert ( status == CAIRO_STATUS_SUCCESS ) ; n = _cairo_array_num_elements ( & mesh -> patches ) ; patch = _cairo_array_index_const ( & mesh -> patches , 0 ) ; for ( i = 0 ; i < n ; i ++ ) { for ( j = 0 ; j < 4 ; j ++ ) { for ( k = 0 ; k < 4 ; k ++ ) { nodes [ j ] [ k ] = patch -> points [ j ] [ k ] ; cairo_matrix_transform_point ( & p2u , & nodes [ j ] [ k ] . x , & nodes [ j ] [ k ] . y ) ; nodes [ j ] [ k ] . x += x_offset ; nodes [ j ] [ k ] . y += y_offset ; } } c = & patch -> colors [ 0 ] ; colors [ 0 ] [ 0 ] = c -> red ; colors [ 0 ] [ 1 ] = c -> green ; colors [ 0 ] [ 2 ] = c -> blue ; colors [ 0 ] [ 3 ] = c -> alpha ; c = & patch -> colors [ 3 ] ; colors [ 1 ] [ 0 ] = c -> red ; colors [ 1 ] [ 1 ] = c -> green ; colors [ 1 ] [ 2 ] = c -> blue ; colors [ 1 ] [ 3 ] = c -> alpha ; c = & patch -> colors [ 1 ] ; colors [ 2 ] [ 0 ] = c -> red ; colors [ 2 ] [ 1 ] = c -> green ; colors [ 2 ] [ 2 ] = c -> blue ; colors [ 2 ] [ 3 ] = c -> alpha ; c = & patch -> colors [ 2 ] ; colors [ 3 ] [ 0 ] = c -> red ; colors [ 3 ] [ 1 ] = c -> green ; colors [ 3 ] [ 2 ] = c -> blue ; colors [ 3 ] [ 3 ] = c -> alpha ; draw_bezier_patch ( data , width , height , stride , nodes , colors ) ; patch ++ ; } }
Draw a tensor product shading pattern.
Draw a tensor product shading pattern .