third_party/cairo/src/cairo-mesh-pattern-rasterizer.c
static inline void
rasterize_bezier_curve (unsigned char *data, int width, int height, int stride,
			int ushift, double dxu[4], double dyu[4],
			uint16_t r0, uint16_t g0, uint16_t b0, uint16_t a0,
			uint16_t r3, uint16_t g3, uint16_t b3, uint16_t a3)
{
    int32_t xu[4], yu[4];
    int x0, y0, u, usteps = 1 << ushift;

    uint16_t r = r0, g = g0, b = b0, a = a0;
    int16_t dr = _color_delta_to_shifted_short (r0, r3, ushift);
    int16_t dg = _color_delta_to_shifted_short (g0, g3, ushift);
    int16_t db = _color_delta_to_shifted_short (b0, b3, ushift);
    int16_t da = _color_delta_to_shifted_short (a0, a3, ushift);

    fd_fixed (dxu, xu);
    fd_fixed (dyu, yu);

    /*
     * Use (dxu[0],dyu[0]) as origin for the forward differences.
     *
     * This makes it possible to handle much larger coordinates (the
     * ones that can be represented as cairo_fixed_t)
     */
    x0 = _cairo_fixed_from_double (dxu[0]);
    y0 = _cairo_fixed_from_double (dyu[0]);
    xu[0] = 0;
    yu[0] = 0;

    for (u = 0; u <= usteps; ++u) {
	/*
	 * This rasterizer assumes that pixels are integer aligned
	 * squares, so a generic (x,y) point belongs to the pixel with
	 * top-left coordinates (floor(x), floor(y))
	 */

	int x = _cairo_fixed_integer_floor (x0 + (xu[0] >> 15) + ((xu[0] >> 14) & 1));
	int y = _cairo_fixed_integer_floor (y0 + (yu[0] >> 15) + ((yu[0] >> 14) & 1));

	draw_pixel (data, width, height, stride, x, y, r, g, b, a);

	fd_fixed_fwd (xu);
	fd_fixed_fwd (yu);
	r += dr;
	g += dg;
	b += db;
	a += da;
    }
}
/*
 * Forward-rasterize a cubic curve using forward differences.
 *
 * Input: 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
 *        ushift is log2(n) if n is the number of desired steps
 *        dxu[i], dyu[i] are the x,y forward differences of the curve
 *        r0,g0,b0,a0 are the color components of the start point
 *        r3,g3,b3,a3 are the color components of the end point
 *
 * Output: data will be changed to have the requested curve drawn in
 *         the specified colors
 *
 * The input color components are not premultiplied, but the data
 * stored in the image is assumed to be in CAIRO_FORMAT_ARGB32 (8 bpc,
 * premultiplied).
 *
 * The function draws n+1 pixels, that is from the point at step 0 to
 * the point at step n, both included. This is the discrete equivalent
 * to drawing the curve for values of the interpolation parameter in
 * [0,1] (including both extremes).
 */
Forward-rasterize a cubic curve using forward differences.
Input: 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
ushift is log2(n) if n is the number of desired steps
dxu[i], dyu[i] are the x,y forward differences of the curve
r0,g0,b0,a0 are the color components of the start point
r3,g3,b3,a3 are the color components of the end point

data will be changed to have the requested curve drawn in
the specified colors

The input color components are not premultiplied, but the data
stored in the image is assumed to be in CAIRO_FORMAT_ARGB32 (8 bpc,
premultiplied).

The function draws n+1 pixels, that is from the point at step 0 to
the point at step n, both included. This is the discrete equivalent
to drawing the curve for values of the interpolation parameter in
[0,1] (including both extremes).
Forward - rasterize a cubic curve using forward differences . Input : 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 ushift is log2 ( n ) if n is the number of desired steps dxu [ i ] dyu [ i ] are the x y forward differences of the curve r0 g0 b0 a0 are the color components of the start point r3 g3 b3 a3 are the color components of the end point data will be changed to have the requested curve drawn in the specified colors The input color components are not premultiplied but the data stored in the image is assumed to be in CAIRO_FORMAT_ARGB32 ( 8 bpc premultiplied ) . The function draws n + 1 pixels that is from the point at step 0 to the point at step n both included . This is the discrete equivalent to drawing the curve for values of the interpolation parameter in [ 0 1 ] ( including both extremes ) .
static inline void
rasterize_bezier_curve (unsigned char *data, int width, int height, int stride,
			int ushift, double dxu[4], double dyu[4],
			uint16_t r0, uint16_t g0, uint16_t b0, uint16_t a0,
			uint16_t r3, uint16_t g3, uint16_t b3, uint16_t a3)
{
    int32_t xu[4], yu[4];
    int x0, y0, u, usteps = 1 << ushift;
    uint16_t r = r0, g = g0, b = b0, a = a0;
    int16_t dr = _color_delta_to_shifted_short (r0, r3, ushift);
    int16_t dg = _color_delta_to_shifted_short (g0, g3, ushift);
    int16_t db = _color_delta_to_shifted_short (b0, b3, ushift);
    int16_t da = _color_delta_to_shifted_short (a0, a3, ushift);
    fd_fixed (dxu, xu);
    fd_fixed (dyu, yu);
    x0 = _cairo_fixed_from_double (dxu[0]);
    y0 = _cairo_fixed_from_double (dyu[0]);
    xu[0] = 0;
    yu[0] = 0;
    for (u = 0; u <= usteps; ++u) {
	int x = _cairo_fixed_integer_floor (x0 + (xu[0] >> 15) + ((xu[0] >> 14) & 1));
	int y = _cairo_fixed_integer_floor (y0 + (yu[0] >> 15) + ((yu[0] >> 14) & 1));
	draw_pixel (data, width, height, stride, x, y, r, g, b, a);
	fd_fixed_fwd (xu);
	fd_fixed_fwd (yu);
	r += dr;
	g += dg;
	b += db;
	a += da;
    }
}
static inline void rasterize_bezier_curve ( unsigned char * data , int width , int height , int stride , int ushift , double dxu [ 4 ] , double dyu [ 4 ] , uint16_t r0 , uint16_t g0 , uint16_t b0 , uint16_t a0 , uint16_t r3 , uint16_t g3 , uint16_t b3 , uint16_t a3 ) { int32_t xu [ 4 ] , yu [ 4 ] ; int x0 , y0 , u , usteps = 1 << ushift ; uint16_t r = r0 , g = g0 , b = b0 , a = a0 ; int16_t dr = _color_delta_to_shifted_short ( r0 , r3 , ushift ) ; int16_t dg = _color_delta_to_shifted_short ( g0 , g3 , ushift ) ; int16_t db = _color_delta_to_shifted_short ( b0 , b3 , ushift ) ; int16_t da = _color_delta_to_shifted_short ( a0 , a3 , ushift ) ; fd_fixed ( dxu , xu ) ; fd_fixed ( dyu , yu ) ; x0 = _cairo_fixed_from_double ( dxu [ 0 ] ) ; y0 = _cairo_fixed_from_double ( dyu [ 0 ] ) ; xu [ 0 ] = 0 ; yu [ 0 ] = 0 ; for ( u = 0 ; u <= usteps ; ++ u ) { int x = _cairo_fixed_integer_floor ( x0 + ( xu [ 0 ] >> 15 ) + ( ( xu [ 0 ] >> 14 ) & 1 ) ) ; int y = _cairo_fixed_integer_floor ( y0 + ( yu [ 0 ] >> 15 ) + ( ( yu [ 0 ] >> 14 ) & 1 ) ) ; draw_pixel ( data , width , height , stride , x , y , r , g , b , a ) ; fd_fixed_fwd ( xu ) ; fd_fixed_fwd ( yu ) ; r += dr ; g += dg ; b += db ; a += da ; } }
Forward-rasterize a cubic curve using forward differences.
Forward - rasterize a cubic curve using forward differences .
/*
     * Use (dxu[0],dyu[0]) as origin for the forward differences.
     *
     * This makes it possible to handle much larger coordinates (the
     * ones that can be represented as cairo_fixed_t)
     */ /*
	 * This rasterizer assumes that pixels are integer aligned
	 * squares, so a generic (x,y) point belongs to the pixel with
	 * top-left coordinates (floor(x), floor(y))
	 */