/*
 * Create an xa format from a PICT format.
 */
enum xa_formats
to_xa_format(enum _PictFormatShort format)
{
	uint32_t ptype = PICT_FORMAT_TYPE(format);

	if ((ptype >= ARRAY_SIZE(stype_map)) ||
			(stype_map[ptype] == 0) ||
			(stype_map[ptype] == xa_type_other))
		return xa_format_unknown;

	return xa_format(PICT_FORMAT_BPP(format),
			stype_map[ptype],
			PICT_FORMAT_A(format),
			PICT_FORMAT_R(format),
			PICT_FORMAT_G(format),
			PICT_FORMAT_B(format));
}
Exemple #2
0
static Bool
uxa_get_pixel_from_rgba(CARD32 * pixel,
			CARD16 red,
			CARD16 green,
			CARD16 blue,
			CARD16 alpha,
			CARD32 format)
{
	int rbits, bbits, gbits, abits;
	int rshift, bshift, gshift, ashift;

	rbits = PICT_FORMAT_R(format);
	gbits = PICT_FORMAT_G(format);
	bbits = PICT_FORMAT_B(format);
	abits = PICT_FORMAT_A(format);
	if (abits == 0)
	    abits = PICT_FORMAT_BPP(format) - (rbits+gbits+bbits);

	if (PICT_FORMAT_TYPE(format) == PICT_TYPE_A) {
		*pixel = alpha >> (16 - abits);
		return TRUE;
	}