summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-05-14 23:30:21 +0100
committerChris Wilson <chris@chris-wilson.co.uk>2010-05-14 23:32:44 +0100
commita7c318d21c9035f6cab48c16e734b9ecb6f4b238 (patch)
tree7017bba1045527a2195f4ee91e10de74b8155ad4
parentf7bbcc492a05f0801c64ee884798cf1a7ebb71c2 (diff)
uxa: Parse BGRA pixel formats.
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
-rw-r--r--uxa/uxa-render.c53
1 files changed, 45 insertions, 8 deletions
diff --git a/uxa/uxa-render.c b/uxa/uxa-render.c
index 883145f2..8b6d4c7b 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 @@ static 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;
}
@@ -386,7 +407,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, &region);
+ return -1;
+ }
+ }
}
if (!(*uxa_screen->info->prepare_solid)