third_party/cairo/src/cairo-mesh-pattern-rasterizer.c
static inline void
draw_pixel (unsigned char *data, int width, int height, int stride,
	    int x, int y, uint16_t r, uint16_t g, uint16_t b, uint16_t a)
{
    if (likely (0 <= x && 0 <= y && x < width && y < height)) {
	uint32_t tr, tg, tb, ta;

	/* Premultiply and round */
	ta = a;
	tr = r * ta + 0x8000;
	tg = g * ta + 0x8000;
	tb = b * ta + 0x8000;

	tr += tr >> 16;
	tg += tg >> 16;
	tb += tb >> 16;

	*((uint32_t*) (data + y*(ptrdiff_t)stride + 4*x)) = ((ta << 16) & 0xff000000) |
	    ((tr >> 8) & 0xff0000) | ((tg >> 16) & 0xff00) | (tb >> 24);
    }
}
/*
 * Set the color of a pixel.
 *
 * 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
 *        x, y are the coordinates of the pixel to be colored
 *        r,g,b,a are the color components of the color to be set
 *
 * Output: the (x,y) pixel in data has the (r,g,b,a) color
 *
 * 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).
 *
 * If the pixel to be set is outside the image, this function does
 * nothing.
 */
Set the color of a pixel.
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
x, y are the coordinates of the pixel to be colored
r,g,b,a are the color components of the color to be set

the (x,y) pixel in data has the (r,g,b,a) color

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).

If the pixel to be set is outside the image, this function does
nothing.
Set the color of a pixel . 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 x y are the coordinates of the pixel to be colored r g b a are the color components of the color to be set the ( x y ) pixel in data has the ( r g b a ) color 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 ) . If the pixel to be set is outside the image this function does nothing .
static inline void
draw_pixel (unsigned char *data, int width, int height, int stride,
	    int x, int y, uint16_t r, uint16_t g, uint16_t b, uint16_t a)
{
    if (likely (0 <= x && 0 <= y && x < width && y < height)) {
	uint32_t tr, tg, tb, ta;
	ta = a;
	tr = r * ta + 0x8000;
	tg = g * ta + 0x8000;
	tb = b * ta + 0x8000;
	tr += tr >> 16;
	tg += tg >> 16;
	tb += tb >> 16;
	*((uint32_t*) (data + y*(ptrdiff_t)stride + 4*x)) = ((ta << 16) & 0xff000000) |
	    ((tr >> 8) & 0xff0000) | ((tg >> 16) & 0xff00) | (tb >> 24);
    }
}
static inline void draw_pixel ( unsigned char * data , int width , int height , int stride , int x , int y , uint16_t r , uint16_t g , uint16_t b , uint16_t a ) { if ( likely ( 0 <= x && 0 <= y && x < width && y < height ) ) { uint32_t tr , tg , tb , ta ; ta = a ; tr = r * ta + 0x8000 ; tg = g * ta + 0x8000 ; tb = b * ta + 0x8000 ; tr += tr >> 16 ; tg += tg >> 16 ; tb += tb >> 16 ; * ( ( uint32_t * ) ( data + y * ( ptrdiff_t ) stride + 4 * x ) ) = ( ( ta << 16 ) & 0xff000000 ) | ( ( tr >> 8 ) & 0xff0000 ) | ( ( tg >> 16 ) & 0xff00 ) | ( tb >> 24 ) ; } }
Set the color of a pixel.
Set the color of a pixel .
/* Premultiply and round */