diff options
author | Chris Wilson <chris@chris-wilson.co.uk> | 2010-05-14 23:30:21 +0100 |
---|---|---|
committer | Owain G. Ainsworth <oga@openbsd.org> | 2010-09-04 00:22:51 +0100 |
commit | d0d4797cde81165c98e21675eab6405753b62df8 (patch) | |
tree | 61d874f768f4e9494b3f405de687cd0249a9c264 /uxa | |
parent | 646fdc43be44cd255f21f790655d32bbb4a55516 (diff) |
uxa: Parse BGRA pixel formats.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
(cherry picked from commit a7c318d21c9035f6cab48c16e734b9ecb6f4b238)
Signed-off-by: Owain G. Ainsworth <oga@openbsd.org>
Diffstat (limited to 'uxa')
-rw-r--r-- | uxa/uxa-render.c | 53 |
1 files changed, 45 insertions, 8 deletions
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c index 0c61146c..4e301516 100644 --- a/uxa/uxa-render.c +++ b/uxa/uxa-render.c @@ -200,7 +200,10 @@ Bool uxa_op_reads_destination(CARD8 op) static Bool uxa_get_pixel_from_rgba(CARD32 * pixel, CARD16 red, - CARD16 green, CARD16 blue, CARD16 alpha, CARD32 format) + CARD16 green, + CARD16 blue, + CARD16 alpha, + CARD32 format) { int rbits, bbits, gbits, abits; int rshift, bshift, gshift, ashift; @@ -225,17 +228,24 @@ uxa_get_pixel_from_rgba(CARD32 * pixel, gshift = bbits; rshift = gshift + gbits; ashift = rshift + rbits; - } else { /* PICT_TYPE_ABGR */ + } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_ABGR) { rshift = 0; gshift = rbits; bshift = gshift + gbits; ashift = bshift + bbits; + } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) { + ashift = 0; + rshift = abits; + gshift = rshift + rbits; + bshift = gshift + gbits; + } else { + return FALSE; } *pixel = 0; - *pixel |= (blue >> (16 - bbits)) << bshift; - *pixel |= (red >> (16 - rbits)) << rshift; + *pixel |= (blue >> (16 - bbits)) << bshift; *pixel |= (green >> (16 - gbits)) << gshift; + *pixel |= (red >> (16 - rbits)) << rshift; *pixel |= (alpha >> (16 - abits)) << ashift; return TRUE; @@ -245,7 +255,9 @@ Bool uxa_get_rgba_from_pixel(CARD32 pixel, CARD16 * red, CARD16 * green, - CARD16 * blue, CARD16 * alpha, CARD32 format) + CARD16 * blue, + CARD16 * alpha, + CARD32 format) { int rbits, bbits, gbits, abits; int rshift, bshift, gshift, ashift; @@ -267,6 +279,13 @@ uxa_get_rgba_from_pixel(CARD32 pixel, gshift = rbits; bshift = gshift + gbits; ashift = bshift + bbits; + } else if (PICT_FORMAT_TYPE(format) == PICT_TYPE_BGRA) { + ashift = 0; + rshift = abits; + if (abits == 0) + rshift = PICT_FORMAT_BPP(format) - (rbits+gbits+bbits); + gshift = rshift + rbits; + bshift = gshift + gbits; } else { return FALSE; } @@ -322,11 +341,13 @@ uxa_get_color_for_pixmap (PixmapPtr pixmap, *pixel = uxa_get_pixmap_first_pixel(pixmap); if (src_format != dst_format) { - if (!uxa_get_rgba_from_pixel(*pixel, &red, &green, &blue, &alpha, + if (!uxa_get_rgba_from_pixel(*pixel, + &red, &green, &blue, &alpha, src_format)) return FALSE; - if (!uxa_get_pixel_from_rgba(pixel, red, green, blue, alpha, + if (!uxa_get_pixel_from_rgba(pixel, + red, green, blue, alpha, dst_format)) return FALSE; } @@ -384,7 +405,23 @@ uxa_try_driver_solid_fill(PicturePtr pSrc, return -1; } - pixel = solid->color; + if (pDst->format == PICT_a8r8g8b8) { + pixel = solid->color; + } else if (pDst->format == PICT_x8r8g8b8) { + pixel = solid->color | 0xff000000; + } else { + CARD16 red, green, blue, alpha; + + if (!uxa_get_rgba_from_pixel(solid->color, + &red, &green, &blue, &alpha, + PICT_a8r8g8b8) || + !uxa_get_pixel_from_rgba(&pixel, + red, green, blue, alpha, + pDst->format)) { + REGION_UNINIT(pDst->pDrawable->pScreen, ®ion); + return -1; + } + } } if (!(*uxa_screen->info->prepare_solid) |