From b37c515320dc8df2b1d160cc3f37d6bfac109b91 Mon Sep 17 00:00:00 2001 From: Keith Packard Date: Wed, 19 Apr 2006 21:56:13 +0000 Subject: [PATCH] Add support for x4a4 format (depth 4 at 8bpp). Bug #6325. --- ChangeLog | 8 ++++++++ fb/fbcompose.c | 27 +++++++++++++++++++++++++-- render/picture.c | 8 ++++++-- render/picture.h | 9 +++++++++ 4 files changed, 48 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 36147cbeb..1328fd9d2 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,11 @@ +2006-04-19 Keith Packard + + * fb/fbcompose.c: (fbFetch_x4a4), (fetchProcForPicture), + (fbStore_x4a4), (storeProcForPicture): + * render/picture.c: (PictureCreateDefaultFormats): + * render/picture.h: + Add support for x4a4 format (depth 4 at 8bpp). Bug #6325. + 2006-04-18 Eric Anholt * exa/exa.c: (exaDriverInit): diff --git a/fb/fbcompose.c b/fb/fbcompose.c index f8e0139f0..88a7c4512 100644 --- a/fb/fbcompose.c +++ b/fb/fbcompose.c @@ -1,5 +1,5 @@ /* - * $XdotOrg: xserver/xorg/fb/fbcompose.c,v 1.26 2005/12/09 18:35:20 ajax Exp $ + * $XdotOrg: xserver/xorg/fb/fbcompose.c,v 1.27 2006-02-10 22:00:21 anholt Exp $ * $XFree86: xc/programs/Xserver/fb/fbcompose.c,v 1.17tsi Exp $ * * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. @@ -385,6 +385,17 @@ fbFetch_c8 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr i } } +static FASTCALL void +fbFetch_x4a4 (const FbBits *bits, int x, int width, CARD32 *buffer, miIndexedPtr indexed) +{ + const CARD8 *pixel = (const CARD8 *)bits + x; + const CARD8 *end = pixel + width; + while (pixel < end) { + CARD8 p = (*pixel++) & 0xf; + *buffer++ = (p | (p << 4)) << 24; + } +} + #define Fetch8(l,o) (((CARD8 *) (l))[(o) >> 2]) #if IMAGE_BYTE_ORDER == MSBFirst #define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4) @@ -548,7 +559,8 @@ static fetchProc fetchProcForPicture (PicturePtr pict) case PICT_a2b2g2r2: return fbFetch_a2b2g2r2; case PICT_c8: return fbFetch_c8; case PICT_g8: return fbFetch_c8; - + case PICT_x4a4: return fbFetch_x4a4; + /* 4bpp formats */ case PICT_a4: return fbFetch_a4; case PICT_r1g2b1: return fbFetch_r1g2b1; @@ -1261,6 +1273,16 @@ fbStore_c8 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr i } } +static FASTCALL void +fbStore_x4a4 (FbBits *bits, const CARD32 *values, int x, int width, miIndexedPtr indexed) +{ + int i; + CARD8 *pixel = ((CARD8 *) bits) + x; + for (i = 0; i < width; ++i) { + *pixel++ = values[i] >> 28; + } +} + #define Store8(l,o,v) (((CARD8 *) l)[(o) >> 3] = (v)) #if IMAGE_BYTE_ORDER == MSBFirst #define Store4(l,o,v) Store8(l,o,((o) & 4 ? \ @@ -1412,6 +1434,7 @@ static storeProc storeProcForPicture (PicturePtr pict) case PICT_a2r2g2b2: return fbStore_a2r2g2b2; case PICT_c8: return fbStore_c8; case PICT_g8: return fbStore_c8; + case PICT_x4a4: return fbStore_x4a4; /* 4bpp formats */ case PICT_a4: return fbStore_a4; diff --git a/render/picture.c b/render/picture.c index 8d4d77e36..ee385e56b 100644 --- a/render/picture.c +++ b/render/picture.c @@ -234,10 +234,14 @@ PictureCreateDefaultFormats (ScreenPtr pScreen, int *nformatp) formats[nformats].format = PICT_a1; formats[nformats].depth = 1; nformats++; - formats[nformats].format = PICT_a8; + formats[nformats].format = PICT_FORMAT(BitsPerPixel(8), + PICT_TYPE_A, + 8, 0, 0, 0); formats[nformats].depth = 8; nformats++; - formats[nformats].format = PICT_a4; + formats[nformats].format = PICT_FORMAT(BitsPerPixel(4), + PICT_TYPE_A, + 4, 0, 0, 0); formats[nformats].depth = 4; nformats++; formats[nformats].format = PICT_a8r8g8b8; diff --git a/render/picture.h b/render/picture.h index b09d9aac2..778eb5c4c 100644 --- a/render/picture.h +++ b/render/picture.h @@ -100,6 +100,15 @@ typedef struct _Picture *PicturePtr; #define PICT_c8 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0) #define PICT_g8 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0) +#define PICT_x4a4 PICT_FORMAT(8,PICT_TYPE_A,4,0,0,0) +#define PICT_x4r1g2b1 PICT_FORMAT(8,PICT_TYPE_ARGB,0,1,2,1) +#define PICT_x4b1g2r1 PICT_FORMAT(8,PICT_TYPE_ABGR,0,1,2,1) +#define PICT_x4a1r1g1b1 PICT_FORMAT(8,PICT_TYPE_ARGB,1,1,1,1) +#define PICT_x4a1b1g1r1 PICT_FORMAT(8,PICT_TYPE_ABGR,1,1,1,1) + +#define PICT_x4c4 PICT_FORMAT(8,PICT_TYPE_COLOR,0,0,0,0) +#define PICT_x4g4 PICT_FORMAT(8,PICT_TYPE_GRAY,0,0,0,0) + /* 4bpp formats */ #define PICT_a4 PICT_FORMAT(4,PICT_TYPE_A,4,0,0,0) #define PICT_r1g2b1 PICT_FORMAT(4,PICT_TYPE_ARGB,0,1,2,1)