[Commit] libic/src ic.c, 1.9, 1.10 ic.h, 1.17, 1.18 icblt.c, 1.1.1.1, 1.2 icbltone.c, 1.3, 1.4 iccolor.c, 1.3, 1.4 iccompose.c, 1.9, 1.10 icformat.c, 1.4, 1.5 icimage.c, 1.10, 1.11 icimage.h, 1.12, 1.13 icint.h, 1.12, 1.13 icpixels.c, 1.3, 1.4 icrect.c, 1.4, 1.5 icrop.h, 1.3, 1.4 icstipple.c, 1.2, 1.3 ictransform.c, 1.2, 1.3 ictrap.c, 1.7, 1.8 ictri.c, 1.6, 1.7 icutil.c, 1.3, 1.4 libic.man, 1.1.1.1, 1.2

Carl Worth commit at keithp.com
Fri Sep 5 16:24:48 PDT 2003


Committed by: cworth

Update of /local/src/CVS/libic/src
In directory home.keithp.com:/tmp/cvs-serv798/src

Modified Files:
	ic.c ic.h icblt.c icbltone.c iccolor.c iccompose.c icformat.c 
	icimage.c icimage.h icint.h icpixels.c icrect.c icrop.h 
	icstipple.c ictransform.c ictrap.c ictri.c icutil.c libic.man 
Log Message:
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

Index: ic.c
===================================================================
RCS file: /local/src/CVS/libic/src/ic.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- ic.c	31 Jul 2003 17:00:09 -0000	1.9
+++ ic.c	5 Sep 2003 22:24:45 -0000	1.10
@@ -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 @@
 	return; \
     } \
     /* manage missing src alpha */ \
-    if ((image)->image_format->alphaMask == 0) \
+    if ((image)->image_format.alphaMask == 0) \
 	(bits) |= 0xff000000; \
 }
 
@@ -928,10 +926,10 @@
 		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 @@
 			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 @@
 			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 @@
 			}
 			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 @@
 	}
 	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 @@
 		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 @@
 		}
 		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 @@
     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;

Index: ic.h
===================================================================
RCS file: /local/src/CVS/libic/src/ic.h,v
retrieving revision 1.17
retrieving revision 1.18
diff -u -d -r1.17 -r1.18
--- ic.h	2 Sep 2003 20:36:17 -0000	1.17
+++ ic.h	5 Sep 2003 22:24:45 -0000	1.18
@@ -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 @@
 
 /* icformat.c */
 
-/* XXX: Change from int to enum for IcFormatName */
-typedef int IcFormatName;
+typedef enum _IcFormatName {
+    IcFormatNameARGB32,
+    IcFormatNameRGB24,
+    IcFormatNameA8,
+    IcFormatNameA1
+} IcFormatName;
 
-/* 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;
+typedef struct _IcFormat 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 */
 

Index: icblt.c
===================================================================
RCS file: /local/src/CVS/libic/src/icblt.c,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- icblt.c	21 Feb 2003 14:51:09 -0000	1.1.1.1
+++ icblt.c	5 Sep 2003 22:24:45 -0000	1.2
@@ -21,7 +21,6 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: $ */
 
 #include "icint.h"
 

Index: icbltone.c
===================================================================
RCS file: /local/src/CVS/libic/src/icbltone.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- icbltone.c	31 Jul 2003 09:11:33 -0000	1.3
+++ icbltone.c	5 Sep 2003 22:24:45 -0000	1.4
@@ -21,7 +21,6 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: $ */
 
 #include "icint.h"
 

Index: iccolor.c
===================================================================
RCS file: /local/src/CVS/libic/src/iccolor.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- iccolor.c	1 Aug 2003 03:46:21 -0000	1.3
+++ iccolor.c	5 Sep 2003 22:24:45 -0000	1.4
@@ -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 @@
 {
     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 @@
     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));
 }

Index: iccompose.c
===================================================================
RCS file: /local/src/CVS/libic/src/iccompose.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -d -r1.9 -r1.10
--- iccompose.c	31 Jul 2003 17:00:09 -0000	1.9
+++ iccompose.c	5 Sep 2003 22:24:45 -0000	1.10
@@ -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 @@
     }
 }
 
-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 @@
     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 @@
     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 @@
     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 @@
 	      ((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 @@
     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 @@
     *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 @@
     { 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 @@
     { 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 @@
 	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 @@
 	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 @@
 	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 @@
 		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,

Index: icformat.c
===================================================================
RCS file: /local/src/CVS/libic/src/icformat.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- icformat.c	31 Jul 2003 17:00:09 -0000	1.4
+++ icformat.c	5 Sep 2003 22:24:45 -0000	1.5
@@ -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);
 }

Index: icimage.c
===================================================================
RCS file: /local/src/CVS/libic/src/icimage.c,v
retrieving revision 1.10
retrieving revision 1.11
diff -u -d -r1.10 -r1.11
--- icimage.c	31 Jul 2003 17:00:09 -0000	1.10
+++ icimage.c	5 Sep 2003 22:24:45 -0000	1.11
@@ -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 @@
     }
 
     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)
     {

Index: icimage.h
===================================================================
RCS file: /local/src/CVS/libic/src/icimage.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- icimage.h	31 Jul 2003 17:00:09 -0000	1.12
+++ icimage.h	5 Sep 2003 22:24:45 -0000	1.13
@@ -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 @@
 
 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 @@
 			       IcCompositeOperand	*dst);
 
 typedef struct _IcAccessMap {
-    uint32_t		format;
+    uint32_t		format_code;
     IcCompositeFetch	fetch;
     IcCompositeFetch	fetcha;
     IcCompositeStore	store;

Index: icint.h
===================================================================
RCS file: /local/src/CVS/libic/src/icint.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- icint.h	31 Jul 2003 17:00:09 -0000	1.12
+++ icint.h	5 Sep 2003 22:24:45 -0000	1.13
@@ -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 @@
     (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 @@
 	   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 @@
 
 #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 */
 

Index: icpixels.c
===================================================================
RCS file: /local/src/CVS/libic/src/icpixels.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- icpixels.c	17 Apr 2003 15:48:22 -0000	1.3
+++ icpixels.c	5 Sep 2003 22:24:45 -0000	1.4
@@ -21,7 +21,6 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: $ */
 
 #include "icint.h"
 

Index: icrect.c
===================================================================
RCS file: /local/src/CVS/libic/src/icrect.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- icrect.c	31 Jul 2003 17:00:09 -0000	1.4
+++ icrect.c	5 Sep 2003 22:24:45 -0000	1.5
@@ -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

Index: icrop.h
===================================================================
RCS file: /local/src/CVS/libic/src/icrop.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- icrop.h	31 Jul 2003 17:00:09 -0000	1.3
+++ icrop.h	5 Sep 2003 22:24:45 -0000	1.4
@@ -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_

Index: icstipple.c
===================================================================
RCS file: /local/src/CVS/libic/src/icstipple.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- icstipple.c	21 Feb 2003 18:07:17 -0000	1.2
+++ icstipple.c	5 Sep 2003 22:24:45 -0000	1.3
@@ -21,7 +21,6 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: $ */
 
 #include "icint.h"
 

Index: ictransform.c
===================================================================
RCS file: /local/src/CVS/libic/src/ictransform.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- ictransform.c	15 May 2003 01:09:10 -0000	1.2
+++ ictransform.c	5 Sep 2003 22:24:45 -0000	1.3
@@ -1,6 +1,4 @@
 /*
- * $XFree86: $
- *
  * Copyright © 2000 SuSE, Inc.
  *
  * Permission to use, copy, modify, distribute, and sell this software and its

Index: ictrap.c
===================================================================
RCS file: /local/src/CVS/libic/src/ictrap.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- ictrap.c	5 May 2003 16:27:09 -0000	1.7
+++ ictrap.c	5 Sep 2003 22:24:45 -0000	1.8
@@ -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 @@
 		      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 @@
     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 @@
 	IcImageDestroy (image);
     }
 
-    _IcFormatDestroy (format);
+    IcFormatDestroy (format);
 }
 
 #ifdef DEBUG
@@ -1363,9 +1365,7 @@
 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.

Index: ictri.c
===================================================================
RCS file: /local/src/CVS/libic/src/ictri.c,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -d -r1.6 -r1.7
--- ictri.c	31 Jul 2003 17:00:09 -0000	1.6
+++ ictri.c	5 Sep 2003 22:24:45 -0000	1.7
@@ -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 @@
     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 @@
 	IcImageDestroy (image);
     }
 
-    _IcFormatDestroy (format);
+    IcFormatDestroy (format);
 }
 
 void
@@ -226,7 +224,7 @@
     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 @@
 	IcImageDestroy (image);
     }
 
-    _IcFormatDestroy (format);
+    IcFormatDestroy (format);
 }
 
 void
@@ -303,7 +301,7 @@
     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 @@
 	IcImageDestroy (image);
     }
 
-    _IcFormatDestroy (format);
+    IcFormatDestroy (format);
 }
 

Index: icutil.c
===================================================================
RCS file: /local/src/CVS/libic/src/icutil.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- icutil.c	31 Jul 2003 09:11:34 -0000	1.3
+++ icutil.c	5 Sep 2003 22:24:45 -0000	1.4
@@ -21,7 +21,6 @@
  * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  * PERFORMANCE OF THIS SOFTWARE.
  */
-/* $XFree86: $ */
 
 #include "icint.h"
 

Index: libic.man
===================================================================
RCS file: /local/src/CVS/libic/src/libic.man,v
retrieving revision 1.1.1.1
retrieving revision 1.2
diff -u -d -r1.1.1.1 -r1.2
--- libic.man	21 Feb 2003 14:51:13 -0000	1.1.1.1
+++ libic.man	5 Sep 2003 22:24:45 -0000	1.2
@@ -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
@@ -27,7 +25,7 @@
 .TP
 \\$1
 ..
-.TH IC 3 "Version 1.0" "XFree86"
+.TH IC 3 "Version 1.0"
 
 .SH NAME
 Ic \- Image compositing library
@@ -44,4 +42,4 @@
 
 .SH AUTHOR
 Carl Worth, USC/Information Sciences Institute
-Keith Packard, member of the XFree86 Project, Inc.
+Keith Packard




More information about the Commit mailing list