diff options
author | Carl Worth <cworth@cworth.org> | 2003-09-05 15:24:45 +0000 |
---|---|---|
committer | Carl Worth <cworth@cworth.org> | 2003-09-05 15:24:45 +0000 |
commit | 4551d78c8f5579a563a446ee745a04472d372823 (patch) | |
tree | a648c13eb06b47630824a0c03fc382b4b8e9eeac /pixman | |
parent | 7e9a0f9cf30f507b50cbf3fc97c387bd05b534cd (diff) |
Expose functions for creating IcFormat based on IcFormatName or masks. The actual IcFormat struct is no longer exposed. Bump version number to 0.1.1
Diffstat (limited to 'pixman')
-rw-r--r-- | pixman/ChangeLog.libic | 22 | ||||
-rw-r--r-- | pixman/src/ic.c | 36 | ||||
-rw-r--r-- | pixman/src/ic.h | 33 | ||||
-rw-r--r-- | pixman/src/icblt.c | 1 | ||||
-rw-r--r-- | pixman/src/icbltone.c | 1 | ||||
-rw-r--r-- | pixman/src/iccolor.c | 36 | ||||
-rw-r--r-- | pixman/src/iccompose.c | 222 | ||||
-rw-r--r-- | pixman/src/icformat.c | 117 | ||||
-rw-r--r-- | pixman/src/icimage.c | 6 | ||||
-rw-r--r-- | pixman/src/icimage.h | 11 | ||||
-rw-r--r-- | pixman/src/icint.h | 49 | ||||
-rw-r--r-- | pixman/src/icpixels.c | 3 | ||||
-rw-r--r-- | pixman/src/icrect.c | 4 | ||||
-rw-r--r-- | pixman/src/icrop.h | 1 | ||||
-rw-r--r-- | pixman/src/icstipple.c | 1 | ||||
-rw-r--r-- | pixman/src/ictransform.c | 2 | ||||
-rw-r--r-- | pixman/src/ictrap.c | 20 | ||||
-rw-r--r-- | pixman/src/ictri.c | 16 | ||||
-rw-r--r-- | pixman/src/icutil.c | 1 |
19 files changed, 208 insertions, 374 deletions
diff --git a/pixman/ChangeLog.libic b/pixman/ChangeLog.libic index 62468861..35792ecc 100644 --- a/pixman/ChangeLog.libic +++ b/pixman/ChangeLog.libic @@ -1,3 +1,25 @@ +2003-09-05 Carl Worth <cworth@isi.edu> + + * configure.in (LIBIC_VERSION): Bumped version to 0.1.1. + + * src/ictrap.c (IcCreateAlphaPicture): Fixed memory leak. + + * src/icimage.h: icimage->image_format now a struct not a + pointer. Rename integral format_name to format_code. + + * src/iccompose.c: Remove unused functions: IcCombineSaturateU, + IcCombineSaturateC, IcFetch_a2b2g2r2, IcFetch_c8, IcFetch_c4, + IcFetch_g1, IcStore_c8, IcStore_g8, IcStore_c4, IcStore_g4, + IcStore_g1. + + * src/iccolor.c (_IcOnes): Rename Ones to _IcOnes and expose it + for internal use. + + * src/ic.h: Changed IcFormatName from an int to an enum. + Changed IcFormat from an exposed struct to an opaque type. + Now expose IcFormatCreate, IcFormatCreateMasks, and + IcFormatDestroy. + 2003-09-02 Carl Worth <cworth@isi.edu> * src/ic.h: Include inttypes.h rather than stdint.h on OpenBSD, diff --git a/pixman/src/ic.c b/pixman/src/ic.c index bd4fbc5a..7971d5a6 100644 --- a/pixman/src/ic.c +++ b/pixman/src/ic.c @@ -1,6 +1,4 @@ /* - * $XFree86: $ - * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -120,7 +118,7 @@ IcIn (uint32_t x, uint8_t y) return; \ } \ /* manage missing src alpha */ \ - if ((image)->image_format->alphaMask == 0) \ + if ((image)->image_format.alphaMask == 0) \ (bits) |= 0xff000000; \ } @@ -928,10 +926,10 @@ IcComposite (char op, iSrc->pixels->height == 1) { srcRepeat = FALSE; - if (PICT_FORMAT_COLOR(iSrc->format_name)) { - switch (iMask->format_name) { + if (PICT_FORMAT_COLOR(iSrc->format_code)) { + switch (iMask->format_code) { case PICT_a8: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_r5g6b5: case PICT_b5g6r5: func = IcCompositeSolidMask_nx8x0565; @@ -950,7 +948,7 @@ IcComposite (char op, break; case PICT_a8r8g8b8: if (iMask->componentAlpha) { - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a8r8g8b8: case PICT_x8r8g8b8: func = IcCompositeSolidMask_nx8888x8888C; @@ -963,7 +961,7 @@ IcComposite (char op, break; case PICT_a8b8g8r8: if (iMask->componentAlpha) { - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a8b8g8r8: case PICT_x8b8g8r8: func = IcCompositeSolidMask_nx8888x8888C; @@ -975,7 +973,7 @@ IcComposite (char op, } break; case PICT_a1: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_r5g6b5: case PICT_b5g6r5: case PICT_r8g8b8: @@ -993,10 +991,10 @@ IcComposite (char op, } else { - switch (iSrc->format_name) { + switch (iSrc->format_code) { case PICT_a8r8g8b8: case PICT_x8r8g8b8: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a8r8g8b8: case PICT_x8r8g8b8: func = IcCompositeSrc_8888x8888; @@ -1011,7 +1009,7 @@ IcComposite (char op, break; case PICT_a8b8g8r8: case PICT_x8b8g8r8: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a8b8g8r8: case PICT_x8b8g8r8: func = IcCompositeSrc_8888x8888; @@ -1025,14 +1023,14 @@ IcComposite (char op, } break; case PICT_r5g6b5: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_r5g6b5: func = IcCompositeSrc_0565x0565; break; } break; case PICT_b5g6r5: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_b5g6r5: func = IcCompositeSrc_0565x0565; break; @@ -1044,30 +1042,30 @@ IcComposite (char op, case PictOpAdd: if (iMask == 0) { - switch (iSrc->format_name) { + switch (iSrc->format_code) { case PICT_a8r8g8b8: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a8r8g8b8: func = IcCompositeSrcAdd_8888x8888; break; } break; case PICT_a8b8g8r8: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a8b8g8r8: func = IcCompositeSrcAdd_8888x8888; break; } break; case PICT_a8: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a8: func = IcCompositeSrcAdd_8000x8000; break; } break; case PICT_a1: - switch (iDst->format_name) { + switch (iDst->format_code) { case PICT_a1: func = IcCompositeSrcAdd_1000x1000; break; diff --git a/pixman/src/ic.h b/pixman/src/ic.h index db6946cb..4dd09a03 100644 --- a/pixman/src/ic.h +++ b/pixman/src/ic.h @@ -1,6 +1,4 @@ /* - * $XFree86: $ - * * Copyright © 1998 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its @@ -54,22 +52,27 @@ extern "C" { /* icformat.c */ -/* XXX: Change from int to enum for IcFormatName */ -typedef int IcFormatName; +typedef enum _IcFormatName { + IcFormatNameARGB32, + IcFormatNameRGB24, + IcFormatNameA8, + IcFormatNameA1 +} IcFormatName; + +typedef struct _IcFormat IcFormat; -/* XXX: Is depth redundant here? */ -typedef struct _IcFormat { - /* XXX: Should switch from int to an IcFormatName enum */ - int format_name; - int depth; - int red, redMask; - int green, greenMask; - int blue, blueMask; - int alpha, alphaMask; -} IcFormat; +extern IcFormat * __external_linkage +IcFormatCreate (IcFormatName name); + +extern IcFormat * __external_linkage +IcFormatCreateMasks (int bpp, + int alpha_mask, + int red_mask, + int green_mask, + int blue_mask); extern void __external_linkage -IcFormatInit (IcFormat *format, IcFormatName name); +IcFormatDestroy (IcFormat *format); /* icimage.c */ diff --git a/pixman/src/icblt.c b/pixman/src/icblt.c index a3def7d3..960ba95c 100644 --- a/pixman/src/icblt.c +++ b/pixman/src/icblt.c @@ -21,7 +21,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: $ */ #include "icint.h" diff --git a/pixman/src/icbltone.c b/pixman/src/icbltone.c index 6488d6f8..aca87e65 100644 --- a/pixman/src/icbltone.c +++ b/pixman/src/icbltone.c @@ -21,7 +21,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: $ */ #include "icint.h" diff --git a/pixman/src/iccolor.c b/pixman/src/iccolor.c index aa1e72ba..fb2312ac 100644 --- a/pixman/src/iccolor.c +++ b/pixman/src/iccolor.c @@ -1,6 +1,4 @@ /* - * $XFree86: $ - * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -25,20 +23,10 @@ #include "icint.h" -/* GCC 3.4 supports a "population count" builtin, which on many targets is - implemented with a single instruction. There is a fallback definition - in libgcc in case a target does not have one, which should be just as - good as the static function below. */ -#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) -# if __INT_MIN__ == 0x7fffffff -# define Ones(mask) __builtin_popcount(mask) -# else -# define Ones(mask) __builtin_popcountl((mask) & 0xffffffff) -# endif -#else -/* Otherwise fall back on HACKMEM 169. */ -static int -Ones(unsigned long mask) +#ifdef ICINT_NEED_IC_ONES +/* Fall back on HACKMEM 169. */ +int +_IcOnes (unsigned long mask) { register unsigned long y; @@ -55,10 +43,10 @@ IcColorToPixel (const IcFormat *format, { CARD32 r, g, b, a; - r = color->red >> (16 - Ones (format->redMask)); - g = color->green >> (16 - Ones (format->greenMask)); - b = color->blue >> (16 - Ones (format->blueMask)); - a = color->alpha >> (16 - Ones (format->alphaMask)); + r = color->red >> (16 - _IcOnes (format->redMask)); + g = color->green >> (16 - _IcOnes (format->greenMask)); + b = color->blue >> (16 - _IcOnes (format->blueMask)); + a = color->alpha >> (16 - _IcOnes (format->alphaMask)); r = r << format->red; g = g << format->green; b = b << format->blue; @@ -89,8 +77,8 @@ IcPixelToColor (const IcFormat *format, g = (pixel >> format->green) & format->greenMask; b = (pixel >> format->blue) & format->blueMask; a = (pixel >> format->alpha) & format->alphaMask; - color->red = IcFillColor (r, Ones (format->redMask)); - color->green = IcFillColor (r, Ones (format->greenMask)); - color->blue = IcFillColor (r, Ones (format->blueMask)); - color->alpha = IcFillColor (r, Ones (format->alphaMask)); + color->red = IcFillColor (r, _IcOnes (format->redMask)); + color->green = IcFillColor (r, _IcOnes (format->greenMask)); + color->blue = IcFillColor (r, _IcOnes (format->blueMask)); + color->alpha = IcFillColor (r, _IcOnes (format->alphaMask)); } diff --git a/pixman/src/iccompose.c b/pixman/src/iccompose.c index 87098a37..ddf5a94e 100644 --- a/pixman/src/iccompose.c +++ b/pixman/src/iccompose.c @@ -1,7 +1,5 @@ /* - * $XFree86: $ - * - * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * Copyright © 2000 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -754,93 +752,6 @@ IcCombineAddC (IcCompositeOperand *src, } } -static void -IcCombineSaturateU (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - uint32_t s = IcCombineMaskU (src, msk), d; -#if 0 - uint16_t sa, da; - uint16_t ad, as; - uint16_t t; - uint32_t m,n,o,p; - - d = (*dst->fetch) (dst); - sa = s >> 24; - da = ~d >> 24; - if (sa <= da) - { - m = IcAdd(s,d,0,t); - n = IcAdd(s,d,8,t); - o = IcAdd(s,d,16,t); - p = IcAdd(s,d,24,t); - } - else - { - as = (da << 8) / sa; - ad = 0xff; - m = IcGen(s,d,0,as,ad,t,u,v); - n = IcGen(s,d,8,as,ad,t,u,v); - o = IcGen(s,d,16,as,ad,t,u,v); - p = IcGen(s,d,24,as,ad,t,u,v); - } - (*dst->store) (dst, m|n|o|p); -#else - if ((s >> 24) == 0xff) - (*dst->store) (dst, s); - else - { - d = (*dst->fetch) (dst); - if ((s >> 24) > (d >> 24)) - (*dst->store) (dst, s); - } -#endif -} - -static void -IcCombineSaturateC (IcCompositeOperand *src, - IcCompositeOperand *msk, - IcCompositeOperand *dst) -{ - IcCompSrc cs; - uint32_t s, d; - uint16_t sa, sr, sg, sb, da; - uint16_t t, u, v; - uint32_t m,n,o,p; - - cs = IcCombineMaskC (src, msk); - d = (*dst->fetch) (dst); - s = cs.value; - sa = (cs.alpha >> 24) & 0xff; - sr = (cs.alpha >> 16) & 0xff; - sg = (cs.alpha >> 8) & 0xff; - sb = (cs.alpha ) & 0xff; - da = ~d >> 24; - - if (sb <= da) - m = IcAdd(s,d,0,t); - else - m = IcGen (s, d, 0, (da << 8) / sb, 0xff, t, u, v); - - if (sg <= da) - n = IcAdd(s,d,8,t); - else - n = IcGen (s, d, 8, (da << 8) / sg, 0xff, t, u, v); - - if (sr < da) - o = IcAdd(s,d,16,t); - else - o = IcGen (s, d, 16, (da << 8) / sr, 0xff, t, u, v); - - if (sa <= da) - p = IcAdd(s,d,24,t); - else - p = IcGen (s, d, 24, (da << 8) / sa, 0xff, t, u, v); - - (*dst->store) (dst, m|n|o|p); -} - /* * All of the disjoint composing functions @@ -1876,31 +1787,6 @@ IcFetch_a2r2g2b2 (IcCompositeOperand *op) return a|r|g|b; } -static uint32_t -IcFetch_a2b2g2r2 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint8_t *) line)[offset>>3]; - uint32_t a,r,g,b; - - a = ((pixel & 0xc0) * 0x55) << 18; - b = ((pixel & 0x30) * 0x55) >> 6; - g = ((pixel & 0x0c) * 0x55) << 6; - r = ((pixel & 0x03) * 0x55) << 16; - return a|r|g|b; -} - -/* XXX: We're not supporting indexed formats, right? -static uint32_t -IcFetch_c8 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint8_t *) line)[offset>>3]; - - return op->indexed->rgba[pixel]; -} -*/ - #define Fetch8(l,o) (((uint8_t *) (l))[(o) >> 3]) #if IMAGE_BYTE_ORDER == MSBFirst #define Fetch4(l,o) ((o) & 2 ? Fetch8(l,o) & 0xf : Fetch8(l,o) >> 4) @@ -1984,17 +1870,6 @@ IcFetch_a1b1g1r1 (IcCompositeOperand *op) return a|r|g|b; } -/* XXX: We're not supporting indexed formats, right? -static uint32_t -IcFetch_c4 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = Fetch4(line, offset); - - return op->indexed->rgba[pixel]; -} -*/ - static uint32_t IcFetcha_a1 (IcCompositeOperand *op) { @@ -2033,23 +1908,6 @@ IcFetch_a1 (IcCompositeOperand *op) return a << 24; } -/* XXX: We're not supporting indexed formats, right? -static uint32_t -IcFetch_g1 (IcCompositeOperand *op) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel = ((uint32_t *)line)[offset >> 5]; - uint32_t a; -#if BITMAP_BIT_ORDER == MSBFirst - a = pixel >> (0x1f - (offset & 0x1f)); -#else - a = pixel >> (offset & 0x1f); -#endif - a = a & 1; - return op->indexed->rgba[a]; -} -*/ - /* * All the store functions */ @@ -2277,24 +2135,6 @@ IcStore_a2r2g2b2 (IcCompositeOperand *op, uint32_t value) ((b >> 6) )); } -/* XXX: We're not supporting indexed formats, right? -static void -IcStore_c8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - *pixel = IcIndexToEnt24(op->indexed,value); -} - -static void -IcStore_g8 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint8_t *pixel = ((uint8_t *) line) + (offset >> 3); - *pixel = IcIndexToEntY24(op->indexed,value); -} -*/ - #define Store8(l,o,v) (((uint8_t *) l)[(o) >> 3] = (v)) #if IMAGE_BYTE_ORDER == MSBFirst #define Store4(l,o,v) Store8(l,o,((o) & 4 ? \ @@ -2365,28 +2205,6 @@ IcStore_a1b1g1r1 (IcCompositeOperand *op, uint32_t value) Store4(line,offset,pixel); } -/* XXX: We're not supporting indexed formats, right? -static void -IcStore_c4 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel; - - pixel = IcIndexToEnt24(op->indexed,value); - Store4(line,offset,pixel); -} - -static void -IcStore_g4 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t pixel; - - pixel = IcIndexToEntY24(op->indexed,value); - Store4(line,offset,pixel); -} -*/ - static void IcStore_a1 (IcCompositeOperand *op, uint32_t value) { @@ -2398,19 +2216,6 @@ IcStore_a1 (IcCompositeOperand *op, uint32_t value) *pixel = (*pixel & ~mask) | value; } -/* XXX: We're not supporting indexed formats, right? -static void -IcStore_g1 (IcCompositeOperand *op, uint32_t value) -{ - IcBits *line = op->u.drawable.line; uint32_t offset = op->u.drawable.offset; - uint32_t *pixel = ((uint32_t *) line) + (offset >> 5); - uint32_t mask = IcStipMask(offset & 0x1f, 1); - - value = IcIndexToEntY24(op->indexed,value) ? mask : 0; - *pixel = (*pixel & ~mask) | value; -} -*/ - static uint32_t IcFetch_external (IcCompositeOperand *op) { @@ -2635,10 +2440,6 @@ static IcAccessMap const icAccessMap[] = { { PICT_r3g3b2, IcFetch_r3g3b2, IcFetch_r3g3b2, IcStore_r3g3b2 }, { PICT_b2g3r3, IcFetch_b2g3r3, IcFetch_b2g3r3, IcStore_b2g3r3 }, { PICT_a2r2g2b2, IcFetch_a2r2g2b2, IcFetch_a2r2g2b2, IcStore_a2r2g2b2 }, -/* XXX: We're not supporting indexed formats, right? - { PICT_c8, IcFetch_c8, IcFetch_c8, IcStore_c8 }, - { PICT_g8, IcFetch_c8, IcFetch_c8, IcStore_g8 }, -*/ /* 4bpp formats */ { PICT_a4, IcFetch_a4, IcFetcha_a4, IcStore_a4 }, @@ -2646,16 +2447,9 @@ static IcAccessMap const icAccessMap[] = { { PICT_b1g2r1, IcFetch_b1g2r1, IcFetch_b1g2r1, IcStore_b1g2r1 }, { PICT_a1r1g1b1, IcFetch_a1r1g1b1, IcFetch_a1r1g1b1, IcStore_a1r1g1b1 }, { PICT_a1b1g1r1, IcFetch_a1b1g1r1, IcFetch_a1b1g1r1, IcStore_a1b1g1r1 }, -/* XXX: We're not supporting indexed formats, right? - { PICT_c4, IcFetch_c4, IcFetch_c4, IcStore_c4 }, - { PICT_g4, IcFetch_c4, IcFetch_c4, IcStore_g4 }, -*/ /* 1bpp formats */ { PICT_a1, IcFetch_a1, IcFetcha_a1, IcStore_a1 }, -/* XXX: We're not supporting indexed formats, right? - { PICT_g1, IcFetch_g1, IcFetch_g1, IcStore_g1 }, -*/ }; #define NumAccessMap (sizeof icAccessMap / sizeof icAccessMap[0]) @@ -2752,9 +2546,7 @@ IcBuildCompositeOperand (IcImage *image, op->over = IcStepOver_transform; op->down = IcStepDown_transform; op->set = IcSet_transform; -/* XXX: We're not supporting indexed formats, right? - op->indexed = (IcIndexedPtr) image->image_format->index.devPrivate; -*/ + op->clip = op[1].clip; return TRUE; @@ -2778,9 +2570,7 @@ IcBuildCompositeOperand (IcImage *image, op->over = IcStepOver_external; op->down = IcStepDown_external; op->set = IcSet_external; -/* XXX: We're not supporting indexed formats, right? - op->indexed = (IcIndexedPtr) image->image_format->index.devPrivate; -*/ + op->clip = op[1].clip; return TRUE; @@ -2792,7 +2582,7 @@ IcBuildCompositeOperand (IcImage *image, int xoff, yoff; for (i = 0; i < NumAccessMap; i++) - if (icAccessMap[i].format == image->format_name) + if (icAccessMap[i].format_code == image->format_code) { IcBits *bits; IcStride stride; @@ -2804,9 +2594,7 @@ IcBuildCompositeOperand (IcImage *image, op->over = IcStepOver; op->down = IcStepDown; op->set = IcSet; -/* XXX: We're not supporting indexed formats, right? - op->indexed = (IcIndexedPtr) image->image_format->index.devPrivate; -*/ + op->clip = image->pCompositeClip; IcGetPixels (image->pixels, bits, stride, bpp, diff --git a/pixman/src/icformat.c b/pixman/src/icformat.c index 2c86697a..a9fbd8d7 100644 --- a/pixman/src/icformat.c +++ b/pixman/src/icformat.c @@ -1,6 +1,4 @@ /* - * $XFree86: $ - * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -28,88 +26,131 @@ #define Mask(n) ((n) == 32 ? 0xffffffff : ((1 << (n))-1)) IcFormat * -_IcFormatCreate (IcFormatName name) +IcFormatCreate (IcFormatName name) +{ + switch (name) { + case IcFormatNameARGB32: + return IcFormatCreateMasks (32, + 0xff000000, + 0x00ff0000, + 0x0000ff00, + 0x000000ff); + case IcFormatNameRGB24: + return IcFormatCreateMasks (32, + 0x0, + 0xff0000, + 0x00ff00, + 0x0000ff); + case IcFormatNameA8: + return IcFormatCreateMasks (8, 0xff, + 0, 0, 0); + case IcFormatNameA1: + return IcFormatCreateMasks (1, 0x1, + 0, 0, 0); + } + + return NULL; +} + +/* XXX: There's some nonsense going on here. The macros above help + IcFormatCreateMasks to encode a format into an int, while + immediately afterwards IcFormatInit goes through the effort of + decoding it. This should all be disentagled, (it's probably + possible to just eliminate the encoding macros altogether). */ +IcFormat * +IcFormatCreateMasks (int bpp, + int alpha_mask, + int red_mask, + int green_mask, + int blue_mask) { + int type; + int format_code; IcFormat *format; + if (red_mask == 0 && green_mask == 0 && blue_mask == 0) + type = PICT_TYPE_A; + else if (red_mask > blue_mask) + type = PICT_TYPE_ARGB; + else + type = PICT_TYPE_ABGR; + + format_code = PICT_FORMAT (bpp, type, + _IcOnes (alpha_mask), + _IcOnes (red_mask), + _IcOnes (green_mask), + _IcOnes (blue_mask)); + format = malloc (sizeof (IcFormat)); if (format == NULL) return NULL; - IcFormatInit (format, name); + IcFormatInit (format, format_code); return format; } void -IcFormatInit (IcFormat *format, IcFormatName name) +IcFormatInit (IcFormat *format, int format_code) { /* XXX: What do we want to lodge in here? format->id = FakeClientID (0); */ - format->format_name = name; - format->depth = PICT_FORMAT_BPP(name); + format->format_code = format_code; + format->depth = PICT_FORMAT_BPP(format_code); - switch (PICT_FORMAT_TYPE(name)) { + switch (PICT_FORMAT_TYPE(format_code)) { case PICT_TYPE_ARGB: - format->alphaMask = Mask(PICT_FORMAT_A(name)); + format->alphaMask = Mask(PICT_FORMAT_A(format_code)); if (format->alphaMask) - format->alpha = (PICT_FORMAT_R(name) + - PICT_FORMAT_G(name) + - PICT_FORMAT_B(name)); + format->alpha = (PICT_FORMAT_R(format_code) + + PICT_FORMAT_G(format_code) + + PICT_FORMAT_B(format_code)); - format->redMask = Mask(PICT_FORMAT_R(name)); - format->red = (PICT_FORMAT_G(name) + - PICT_FORMAT_B(name)); + format->redMask = Mask(PICT_FORMAT_R(format_code)); + format->red = (PICT_FORMAT_G(format_code) + + PICT_FORMAT_B(format_code)); - format->greenMask = Mask(PICT_FORMAT_G(name)); - format->green = PICT_FORMAT_B(name); + format->greenMask = Mask(PICT_FORMAT_G(format_code)); + format->green = PICT_FORMAT_B(format_code); - format->blueMask = Mask(PICT_FORMAT_B(name)); + format->blueMask = Mask(PICT_FORMAT_B(format_code)); format->blue = 0; break; case PICT_TYPE_ABGR: - format->alphaMask = Mask(PICT_FORMAT_A(name)); + format->alphaMask = Mask(PICT_FORMAT_A(format_code)); if (format->alphaMask) - format->alpha = (PICT_FORMAT_B(name) + - PICT_FORMAT_G(name) + - PICT_FORMAT_R(name)); + format->alpha = (PICT_FORMAT_B(format_code) + + PICT_FORMAT_G(format_code) + + PICT_FORMAT_R(format_code)); - format->blueMask = Mask(PICT_FORMAT_B(name)); - format->blue = (PICT_FORMAT_G(name) + - PICT_FORMAT_R(name)); + format->blueMask = Mask(PICT_FORMAT_B(format_code)); + format->blue = (PICT_FORMAT_G(format_code) + + PICT_FORMAT_R(format_code)); - format->greenMask = Mask(PICT_FORMAT_G(name)); - format->green = PICT_FORMAT_R(name); + format->greenMask = Mask(PICT_FORMAT_G(format_code)); + format->green = PICT_FORMAT_R(format_code); - format->redMask = Mask(PICT_FORMAT_R(name)); + format->redMask = Mask(PICT_FORMAT_R(format_code)); format->red = 0; break; case PICT_TYPE_A: format->alpha = 0; - format->alphaMask = Mask(PICT_FORMAT_A(name)); + format->alphaMask = Mask(PICT_FORMAT_A(format_code)); /* remaining fields already set to zero */ break; - -/* XXX: We're not supporting indexed formats, right? - case PICT_TYPE_COLOR: - case PICT_TYPE_GRAY: - format->type = PictTypeIndexed; - format->index.pVisual = &pScreen->visuals[PICT_FORMAT_VIS(name)]; - break; -*/ } } slim_hidden_def(IcFormatInit) void -_IcFormatDestroy (IcFormat *format) +IcFormatDestroy (IcFormat *format) { free (format); } diff --git a/pixman/src/icimage.c b/pixman/src/icimage.c index 8b2dd08a..38d00f54 100644 --- a/pixman/src/icimage.c +++ b/pixman/src/icimage.c @@ -1,6 +1,4 @@ /* - * $XFree86: $ - * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its @@ -83,8 +81,8 @@ IcImageCreateForPixels (IcPixels *pixels, } image->pixels = pixels; - image->image_format = format; - image->format_name = format->format_name; + image->image_format = *format; + image->format_code = format->format_code; /* XXX: What's all this about? if (pDrawable->type == DRAWABLE_PIXMAP) { diff --git a/pixman/src/icimage.h b/pixman/src/icimage.h index 9329d84d..679376ef 100644 --- a/pixman/src/icimage.h +++ b/pixman/src/icimage.h @@ -1,7 +1,5 @@ /* - * $XFree86: $ - * - * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * Copyright © 2000 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -107,9 +105,8 @@ typedef struct _IcFormat { struct _IcImage { IcPixels *pixels; - IcFormat *image_format; - /* XXX: Should switch from int to an IcFormatName enum */ - int format_name; + IcFormat image_format; + int format_code; int refcnt; unsigned int repeat : 1; @@ -318,7 +315,7 @@ typedef void (*IcCombineFunc) (IcCompositeOperand *src, IcCompositeOperand *dst); typedef struct _IcAccessMap { - uint32_t format; + uint32_t format_code; IcCompositeFetch fetch; IcCompositeFetch fetcha; IcCompositeStore store; diff --git a/pixman/src/icint.h b/pixman/src/icint.h index 289a58a0..54453cba 100644 --- a/pixman/src/icint.h +++ b/pixman/src/icint.h @@ -1,5 +1,4 @@ -/* $XFree86: $ - * +/* * Copyright © 2003 Carl Worth * * Permission to use, copy, modify, distribute, and sell this software and its @@ -498,19 +497,6 @@ extern void IcSetBits (IcStip *bits, int stride, IcStip data); (yoff) = icpixels->y; \ } -/* - * XFree86 empties the root BorderClip when the VT is inactive, - * here's a macro which uses that to disable GetImage and GetSpans - */ - -#define IcWindowEnabled(pWin) \ - REGION_NOTEMPTY((pWin)->drawable.pScreen, \ - &WindowTable[(pWin)->drawable.pScreen->myNum]->borderClip) - -#define IcDrawableEnabled(pDrawable) \ - ((pDrawable)->type == DRAWABLE_PIXMAP ? \ - TRUE : IcWindowEnabled((WindowPtr) pDrawable)) - #ifdef IC_OLD_SCREEN #define BitsPerPixel(d) (\ ((1 << PixmapWidthPaddingInfo[d].padBytesLog2) * 8 / \ @@ -699,6 +685,16 @@ IcStipple (IcBits *dst, int xRot, int yRot); +/* XXX: Is depth redundant here? */ +struct _IcFormat { + int format_code; + int depth; + int red, redMask; + int green, greenMask; + int blue, blueMask; + int alpha, alphaMask; +}; + typedef struct _IcPixels { IcBits *data; unsigned int width; @@ -730,13 +726,28 @@ IcReplicatePixel (Pixel p, int bpp); #include "icimage.h" -/* icformat.c */ +/* iccolor.c */ -extern IcFormat * __internal_linkage -_IcFormatCreate (IcFormatName name); +/* GCC 3.4 supports a "population count" builtin, which on many targets is + implemented with a single instruction. There is a fallback definition + in libgcc in case a target does not have one, which should be just as + good as the static function below. */ +#if __GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4) +# if __INT_MIN__ == 0x7fffffff +# define _IcOnes(mask) __builtin_popcount(mask) +# else +# define _IcOnes(mask) __builtin_popcountl((mask) & 0xffffffff) +# endif +#else +# define ICINT_NEED_IC_ONES +int +_IcOnes(unsigned long mask); +#endif + +/* icformat.c */ extern void __internal_linkage -_IcFormatDestroy (IcFormat *format); +IcFormatInit (IcFormat *format, int format_code); /* icimage.c */ diff --git a/pixman/src/icpixels.c b/pixman/src/icpixels.c index 9b1277ea..0215b657 100644 --- a/pixman/src/icpixels.c +++ b/pixman/src/icpixels.c @@ -1,5 +1,5 @@ /* - * $Id: icpixels.c,v 1.3 2003-04-17 15:48:22 cworth Exp $ + * $Id: icpixels.c,v 1.4 2003-09-05 22:24:45 cworth Exp $ * * Copyright © 1998 Keith Packard * @@ -21,7 +21,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: $ */ #include "icint.h" diff --git a/pixman/src/icrect.c b/pixman/src/icrect.c index 3b54c15a..238d775d 100644 --- a/pixman/src/icrect.c +++ b/pixman/src/icrect.c @@ -1,7 +1,5 @@ /* - * $XFree86: $ - * - * Copyright © 2000 Keith Packard, member of The XFree86 Project, Inc. + * Copyright © 2000 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that diff --git a/pixman/src/icrop.h b/pixman/src/icrop.h index 564c4f33..d04095d2 100644 --- a/pixman/src/icrop.h +++ b/pixman/src/icrop.h @@ -21,7 +21,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: $ */ #ifndef _ICROP_H_ #define _ICROP_H_ diff --git a/pixman/src/icstipple.c b/pixman/src/icstipple.c index c9b2c826..9dc3cc79 100644 --- a/pixman/src/icstipple.c +++ b/pixman/src/icstipple.c @@ -21,7 +21,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: $ */ #include "icint.h" diff --git a/pixman/src/ictransform.c b/pixman/src/ictransform.c index 506b1ef6..0edd4312 100644 --- a/pixman/src/ictransform.c +++ b/pixman/src/ictransform.c @@ -1,6 +1,4 @@ /* - * $XFree86: $ - * * Copyright © 2000 SuSE, Inc. * * Permission to use, copy, modify, distribute, and sell this software and its diff --git a/pixman/src/ictrap.c b/pixman/src/ictrap.c index c6216c28..852fd828 100644 --- a/pixman/src/ictrap.c +++ b/pixman/src/ictrap.c @@ -1,6 +1,4 @@ /* - * $XFree86: $ - * * Copyright © 2002 University of Southern California * * Permission to use, copy, modify, distribute, and sell this software @@ -38,23 +36,27 @@ IcCreateAlphaPicture (IcImage *dst, CARD16 height) { IcImage *image; + int own_format = 0; if (width > 32767 || height > 32767) return 0; if (!format) { - /* XXX: Is the memory from this IcFormatCreate leaking? */ + own_format = 1; if (dst->polyEdge == PolyEdgeSharp) - format = _IcFormatCreate (PICT_a1); + format = IcFormatCreate (IcFormatNameA1); else - format = _IcFormatCreate (PICT_a8); + format = IcFormatCreate (IcFormatNameA8); if (!format) return 0; } image = IcImageCreate (format, width, height); + if (own_format) + IcFormatDestroy (format); + /* XXX: Is this a reasonable way to clear the image? Would probably be preferable to use IcImageFillRectangle once such a beast exists. */ @@ -128,7 +130,7 @@ IcCompositeTrapezoids (char op, xDst = traps[0].left.p1.x >> 16; yDst = traps[0].left.p1.y >> 16; - format = _IcFormatCreate (PICT_a8); + format = IcFormatCreate (IcFormatNameA8); if (format) { @@ -180,7 +182,7 @@ IcCompositeTrapezoids (char op, IcImageDestroy (image); } - _IcFormatDestroy (format); + IcFormatDestroy (format); } #ifdef DEBUG @@ -1363,9 +1365,7 @@ So, if you know y1 and want to know x1: A similar operation moves to a known y1. Note that this computation (in general) requires 64 bit arithmetic. I suggest just using the available 64 bit datatype for now, we can optimize the common cases with a few -conditionals. There's some cpp code in fb/fb.h that selects a 64 bit type -for machines that XFree86 builds on; there aren't any machines missing a -64 bit datatype that I know of. +conditionals. */ /* Here's a large-step Bresenham for jogging my memory. diff --git a/pixman/src/ictri.c b/pixman/src/ictri.c index d943a129..663635b7 100644 --- a/pixman/src/ictri.c +++ b/pixman/src/ictri.c @@ -1,7 +1,5 @@ /* - * $XFree86: $ - * - * Copyright © 2002 Keith Packard, member of The XFree86 Project, Inc. + * Copyright © 2002 Keith Packard * * Permission to use, copy, modify, distribute, and sell this software and its * documentation for any purpose is hereby granted without fee, provided that @@ -154,7 +152,7 @@ IcCompositeTriangles (char op, xDst = tris[0].p1.x >> 16; yDst = tris[0].p1.y >> 16; - format = _IcFormatCreate (PICT_a8); + format = IcFormatCreate (IcFormatNameA8); if (format) { @@ -204,7 +202,7 @@ IcCompositeTriangles (char op, IcImageDestroy (image); } - _IcFormatDestroy (format); + IcFormatDestroy (format); } void @@ -226,7 +224,7 @@ IcCompositeTriStrip (char op, xDst = points[0].x >> 16; yDst = points[0].y >> 16; - format = _IcFormatCreate (PICT_a8); + format = IcFormatCreate (IcFormatNameA8); if (npoints < 3) return; @@ -280,7 +278,7 @@ IcCompositeTriStrip (char op, IcImageDestroy (image); } - _IcFormatDestroy (format); + IcFormatDestroy (format); } void @@ -303,7 +301,7 @@ IcCompositeTriFan (char op, xDst = points[0].x >> 16; yDst = points[0].y >> 16; - format = _IcFormatCreate (PICT_a8); + format = IcFormatCreate (IcFormatNameA8); if (npoints < 3) return; @@ -359,6 +357,6 @@ IcCompositeTriFan (char op, IcImageDestroy (image); } - _IcFormatDestroy (format); + IcFormatDestroy (format); } diff --git a/pixman/src/icutil.c b/pixman/src/icutil.c index 748a8f8b..718fcecd 100644 --- a/pixman/src/icutil.c +++ b/pixman/src/icutil.c @@ -21,7 +21,6 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $XFree86: $ */ #include "icint.h" |