[cairo] iccompose.c/fbccompose.c merge part 2

Billy Biggs vektor at dumbterm.net
Thu Aug 4 21:02:31 PDT 2005


  I discussed my last patch with Jeff Muizelaar on IRC and cleaned it
up.  This is what I intend to commit if there are no objections.  For
easier review, I split the patch up into two parts:

  1. Header file cleanups:
     - Add fbpict.h which almost matches fbpict.h from xserver CVS
     - Fix some of the 4 bit per channel PICT definitions
     - Fix fbGetDrawable
     - Add some more pixman/mi/Fb typedefs.

  2. iccompose.c patch:
     - Update to the latest from xserver.

  I've also attached the diff between pixman's iccompose.c and xserver's
fbcompose.c so you can actually see what's changed.  Would anyone mind
if I just removed iccompose.c and added this as fbcompose.c in pixman?

  This change will cause three cairo test failures, however all three
are reproducable with the latest code from Xserver, so I don't think
they're caused by my merge.

  -Billy

-------------- next part --------------
Index: src/Makefile.am
===================================================================
RCS file: /cvs/cairo/libpixman/src/Makefile.am,v
retrieving revision 1.9
diff -p -u -r1.9 Makefile.am
--- src/Makefile.am	21 Jan 2005 18:59:33 -0000	1.9
+++ src/Makefile.am	5 Aug 2005 03:50:55 -0000
@@ -6,6 +6,7 @@ libpixman_la_SOURCES = \
 	pixman-xserver-compat.h \
 	pixregion.c \
 	pixregionint.h \
+	fbpict.h \
 	ic.c \
 	icblt.c \
 	icbltone.c \
Index: src/fbpict.h
===================================================================
RCS file: src/fbpict.h
diff -N src/fbpict.h
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ src/fbpict.h	5 Aug 2005 03:50:55 -0000
@@ -0,0 +1,352 @@
+/*
+ * $Id: fbpict.h,v 1.24 2005/07/12 09:57:00 lars Exp $
+ *
+ * Copyright ?? 2000 Keith Packard
+ *             2005 Lars Knoll & Zack Rusin, Trolltech
+ *
+ * Permission to use, copy, modify, distribute, and sell this software and its
+ * documentation for any purpose is hereby granted without fee, provided that
+ * the above copyright notice appear in all copies and that both that
+ * copyright notice and this permission notice appear in supporting
+ * documentation, and that the name of Keith Packard not be used in
+ * advertising or publicity pertaining to distribution of the software without
+ * specific, written prior permission.  Keith Packard makes no
+ * representations about the suitability of this software for any purpose.  It
+ * is provided "as is" without express or implied warranty.
+ *
+ * THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS
+ * SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND
+ * FITNESS, IN NO EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY
+ * SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+ * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN
+ * AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING
+ * OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
+ * SOFTWARE.
+ */
+
+#ifndef _FBPICT_H_
+#define _FBPICT_H_
+
+#include "pixman-xserver-compat.h"
+#include "renderedge.h"
+
+#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
+#define FbIntDiv(a,b)	 (((CARD16) (a) * 255) / (b))
+
+#define FbGet8(v,i)   ((CARD16) (CARD8) ((v) >> i))
+
+/*
+ * There are two ways of handling alpha -- either as a single unified value or
+ * a separate value for each component, hence each macro must have two
+ * versions.  The unified alpha version has a 'U' at the end of the name,
+ * the component version has a 'C'.  Similarly, functions which deal with
+ * this difference will have two versions using the same convention.
+ */
+
+#define FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i),\
+			   (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i),\
+			    (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+#define FbInU(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
+
+#define FbInC(x,i,a,t) ((CARD32) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
+
+#define FbGen(x,y,i,ax,ay,t,u,v) ((t) = (FbIntMult(FbGet8(y,i),ay,(u)) + \
+					 FbIntMult(FbGet8(x,i),ax,(v))),\
+				  (CARD32) ((CARD8) ((t) | \
+						     (0 - ((t) >> 8)))) << (i))
+
+#define FbAdd(x,y,i,t)	((t) = FbGet8(x,i) + FbGet8(y,i), \
+			 (CARD32) ((CARD8) ((t) | (0 - ((t) >> 8)))) << (i))
+
+
+#define Alpha(x) ((x) >> 24)
+#define Red(x) (((x) >> 16) & 0xff)
+#define Green(x) (((x) >> 8) & 0xff)
+#define Blue(x) ((x) & 0xff)
+
+#define fbComposeGetSolid(pict, bits) { \
+    FbBits	*__bits__; \
+    FbStride	__stride__; \
+    int		__bpp__; \
+    int		__xoff__,__yoff__; \
+\
+    fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
+    switch (__bpp__) { \
+    case 32: \
+	(bits) = *(CARD32 *) __bits__; \
+	break; \
+    case 24: \
+	(bits) = Fetch24 ((CARD8 *) __bits__); \
+	break; \
+    case 16: \
+	(bits) = *(CARD16 *) __bits__; \
+	(bits) = cvt0565to0888(bits); \
+	break; \
+    case 8: \
+	(bits) = *(CARD8 *) __bits__; \
+	(bits) = (bits) << 24; \
+	break; \
+    case 1: \
+	(bits) = *(CARD32 *) __bits__; \
+	(bits) = FbLeftStipBits((bits),1) ? 0xff000000 : 0x00000000;\
+	break; \
+    default: \
+	return; \
+    } \
+    /* manage missing src alpha */ \
+    if ((pict)->image_format.alphaMask == 0) \
+	(bits) |= 0xff000000; \
+}
+
+#define fbComposeGetStart(pict,x,y,type,stride,line,mul) {\
+    FbBits	*__bits__; \
+    FbStride	__stride__; \
+    int		__bpp__; \
+    int		__xoff__,__yoff__; \
+\
+    fbGetDrawable((pict)->pDrawable,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
+    (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
+    (line) = ((type *) __bits__) + (stride) * ((y) + __yoff__) + (mul) * ((x) + __xoff__); \
+}
+
+#define cvt8888to0565(s)    ((((s) >> 3) & 0x001f) | \
+			     (((s) >> 5) & 0x07e0) | \
+			     (((s) >> 8) & 0xf800))
+#define cvt0565to0888(s)    (((((s) << 3) & 0xf8) | (((s) >> 2) & 0x7)) | \
+			     ((((s) << 5) & 0xfc00) | (((s) >> 1) & 0x300)) | \
+			     ((((s) << 8) & 0xf80000) | (((s) << 3) & 0x70000)))
+
+#if IMAGE_BYTE_ORDER == MSBFirst
+#define Fetch24(a)  ((unsigned long) (a) & 1 ? \
+		     ((*(a) << 16) | *((CARD16 *) ((a)+1))) : \
+		     ((*((CARD16 *) (a)) << 8) | *((a)+2)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+		      ((*(a) = (CARD8) ((v) >> 16)), \
+		       (*((CARD16 *) ((a)+1)) = (CARD16) (v))) : \
+		      ((*((CARD16 *) (a)) = (CARD16) ((v) >> 8)), \
+		       (*((a)+2) = (CARD8) (v))))
+#else
+#define Fetch24(a)  ((unsigned long) (a) & 1 ? \
+		     ((*(a)) | (*((CARD16 *) ((a)+1)) << 8)) : \
+		     ((*((CARD16 *) (a))) | (*((a)+2) << 16)))
+#define Store24(a,v) ((unsigned long) (a) & 1 ? \
+		      ((*(a) = (CARD8) (v)), \
+		       (*((CARD16 *) ((a)+1)) = (CARD16) ((v) >> 8))) : \
+		      ((*((CARD16 *) (a)) = (CARD16) (v)),\
+		       (*((a)+2) = (CARD8) ((v) >> 16))))
+#endif
+		      
+/*
+  The methods below use some tricks to be able to do two color
+  components at the same time.
+*/
+
+/*
+  x_c = (x_c * a) / 255
+*/
+#define FbByteMul(x, a) do {                                      \
+        CARD32 t = (x & 0xff00ff) *a;                             \
+        t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;          \
+        t &= 0xff00ff;                                            \
+                                                                  \
+        x = ((x >> 8) & 0xff00ff) * a;                            \
+        x = (x + ((x >> 8) & 0xff00ff) + 0x800080);               \
+        x &= 0xff00ff00;                                          \
+        x += t;                                                   \
+    } while (0)
+
+/*
+  x_c = (x_c * a) / 255 + y
+*/
+#define FbByteMulAdd(x, a, y) do {                                \
+        CARD32 t = (x & 0xff00ff) * a;                            \
+        t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;          \
+        t &= 0xff00ff;                                            \
+        t += y & 0xff00ff;                                        \
+        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                   \
+        t &= 0xff00ff;                                            \
+                                                                  \
+        x = ((x >> 8) & 0xff00ff) * a;                              \
+        x = (x + ((x >> 8) & 0xff00ff) + 0x800080) >> 8;            \
+        x &= 0xff00ff;                                              \
+        x += (y >> 8) & 0xff00ff;                                   \
+        x |= 0x1000100 - ((t >> 8) & 0xff00ff);                     \
+        x &= 0xff00ff;                                              \
+        x <<= 8;                                                    \
+        x += t;                                                     \
+    } while (0)
+
+/*
+  x_c = (x_c * a + y_c * b) / 255
+*/
+#define FbByteAddMul(x, a, y, b) do {                                   \
+        CARD32 t;                                                       \
+        CARD32 r = (x >> 24) * a + (y >> 24) * b;                       \
+        r += (r >> 8) + 0x80;                                           \
+        r >>= 8;                                                        \
+                                                                        \
+        t = (x & 0xff00) * a + (y & 0xff00) * b;                        \
+        t += (t >> 8) + 0x8000;                                         \
+        t >>= 16;                                                       \
+                                                                        \
+        t |= r << 16;                                                   \
+        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                         \
+        t &= 0xff00ff;                                                  \
+        t <<= 8;                                                        \
+                                                                        \
+        r = ((x >> 16) & 0xff) * a + ((y >> 16) & 0xff) * b;            \
+        r += (r >> 8) + 0x80;                                           \
+        r >>= 8;                                                        \
+                                                                        \
+        x = (x & 0xff) * a + (y & 0xff) * b;                            \
+        x += (x >> 8) + 0x80;                                           \
+        x >>= 8;                                                        \
+        x |= r << 16;                                                   \
+        x |= 0x1000100 - ((x >> 8) & 0xff00ff);                         \
+        x &= 0xff00ff;                                                  \
+        x |= t;                                                         \
+} while (0)
+
+/*
+  x_c = (x_c * a + y_c *b) / 256
+*/
+#define FbByteAddMul_256(x, a, y, b) do {                               \
+        CARD32 t = (x & 0xff00ff) * a + (y & 0xff00ff) * b;             \
+        t >>= 8;                                                        \
+        t &= 0xff00ff;                                                  \
+                                                                        \
+        x = ((x >> 8) & 0xff00ff) * a + ((y >> 8) & 0xff00ff) * b;      \
+        x &= 0xff00ff00;                                                \
+        x += t;                                                         \
+} while (0)
+/*
+  x_c = (x_c * a_c) / 255
+*/
+#define FbByteMulC(x, a) do {                                   \
+        CARD32 t;                                               \
+        CARD32 r = (x & 0xff) * (a & 0xff);                     \
+        r |= (x & 0xff0000) * ((a >> 16) & 0xff);               \
+        r = (r + ((r >> 8) & 0xff00ff) + 0x800080) >> 8;        \
+        r &= 0xff00ff;                                          \
+                                                                \
+        x >>= 8;                                                \
+        t = (x & 0xff) * ((a >> 8) & 0xff);                     \
+        t |= (x & 0xff0000) * (a >> 24);                        \
+        t = (t + ((t >> 8) & 0xff00ff) + 0x800080);             \
+        x = r | (t & 0xff00ff00);                               \
+                                                                \
+    } while (0)
+
+/*
+  x_c = (x_c * a) / 255 + y
+*/
+#define FbByteMulAddC(x, a, y) do {                                \
+        CARD32 t;                                                  \
+        CARD32 r = (x & 0xff) * (a & 0xff);                        \
+        r |= (x & 0xff0000) * ((a >> 16) & 0xff);                  \
+        r = (r + ((r >> 8) & 0xff00ff) + 0x800080) >> 8;           \
+        r &= 0xff00ff;                                             \
+        r += y & 0xff00ff;                                         \
+        r |= 0x1000100 - ((r >> 8) & 0xff00ff);                    \
+        r &= 0xff00ff;                                             \
+                                                                   \
+        x >>= 8;                                                   \
+        t = (x & 0xff) * ((a >> 8) & 0xff);                        \
+        t |= (x & 0xff0000) * (a >> 24);                              \
+        t = (t + ((t >> 8) & 0xff00ff) + 0x800080) >> 8;              \
+        t &= 0xff00ff;                                                \
+        t += (y >> 8) & 0xff00ff;                                     \
+        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                       \
+        t &= 0xff00ff;                                                \
+        x = r | (t << 8);                                             \
+    } while (0)
+
+/*
+  x_c = (x_c * a_c + y_c * b) / 255
+*/
+#define FbByteAddMulC(x, a, y, b) do {                                  \
+        CARD32 t;                                                       \
+        CARD32 r = (x >> 24) * (a >> 24) + (y >> 24) * b;               \
+        r += (r >> 8) + 0x80;                                           \
+        r >>= 8;                                                        \
+                                                                        \
+        t = (x & 0xff00) * ((a >> 8) & 0xff) + (y & 0xff00) * b;        \
+        t += (t >> 8) + 0x8000;                                         \
+        t >>= 16;                                                       \
+                                                                        \
+        t |= r << 16;                                                   \
+        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                         \
+        t &= 0xff00ff;                                                  \
+        t <<= 8;                                                        \
+                                                                        \
+        r = ((x >> 16) & 0xff) * ((a >> 16) & 0xff) + ((y >> 16) & 0xff) * b; \
+        r += (r >> 8) + 0x80;                                           \
+        r >>= 8;                                                        \
+                                                                        \
+        x = (x & 0xff) * (a & 0xff) + (y & 0xff) * b;                   \
+        x += (x >> 8) + 0x80;                                           \
+        x >>= 8;                                                        \
+        x |= r << 16;                                                   \
+        x |= 0x1000100 - ((x >> 8) & 0xff00ff);                         \
+        x &= 0xff00ff;                                                  \
+        x |= t;                                                         \
+} while (0)
+
+/*
+  x_c = min(x_c + y_c, 255)
+*/
+#define FbByteAdd(x, y) do {                                            \
+        CARD32 t;                                                       \
+        CARD32 r = (x & 0xff00ff) + (y & 0xff00ff);                     \
+        r |= 0x1000100 - ((r >> 8) & 0xff00ff);                         \
+        r &= 0xff00ff;                                                  \
+                                                                        \
+        t = ((x >> 8) & 0xff00ff) + ((y >> 8) & 0xff00ff);              \
+        t |= 0x1000100 - ((t >> 8) & 0xff00ff);                         \
+        r |= (t & 0xff00ff) << 8;                                       \
+        x = r;                                                          \
+    } while (0)
+
+#define div_255(x) (((x) + ((x) >> 8) + 0x80) >> 8)
+
+#if defined(__i386__) && defined(__GNUC__)
+#define FASTCALL __attribute__((regparm(3)))
+#else
+#define FASTCALL
+#endif
+
+#if defined(__GNUC__)
+#define INLINE __inline__
+#else
+#define INLINE
+#endif
+
+typedef struct _FbComposeData {
+    CARD8	op;
+    PicturePtr	src;
+    PicturePtr	mask;
+    PicturePtr	dest;
+    INT16	xSrc;
+    INT16	ySrc;
+    INT16	xMask;
+    INT16	yMask;
+    INT16	xDest;
+    INT16	yDest;
+    CARD16	width;
+    CARD16	height;
+} FbComposeData;
+
+typedef FASTCALL void (*CombineMaskU) (CARD32 *src, const CARD32 *mask, int width);
+typedef FASTCALL void (*CombineFuncU) (CARD32 *dest, const CARD32 *src, int width);
+typedef FASTCALL void (*CombineFuncC) (CARD32 *dest, CARD32 *src, CARD32 *mask, int width);
+
+typedef struct _FbComposeFunctions {
+    CombineFuncU *combineU;
+    CombineFuncC *combineC;
+    CombineMaskU combineMaskU;
+} FbComposeFunctions;
+
+#endif /* _FBPICT_H_ */
Index: src/ic.c
===================================================================
RCS file: /cvs/cairo/libpixman/src/ic.c,v
retrieving revision 1.32
diff -p -u -r1.32 ic.c
--- src/ic.c	30 Jul 2005 17:23:21 -0000	1.32
+++ src/ic.c	5 Aug 2005 03:50:56 -0000
@@ -21,7 +21,7 @@
  * Author:  Keith Packard, SuSE, Inc.
  */
 
-#include "pixman-xserver-compat.h"
+#include "fbpict.h"
 
 #define cvt8888to0565(s)    ((((s) >> 3) & 0x001f) | \
 			     (((s) >> 5) & 0x07e0) | \
@@ -105,51 +105,6 @@ fbIn24 (CARD32 x, CARD8 y)
     return m|n|o|p;
 }
 
-#define fbComposeGetSolid(image, bits) { \
-    FbBits	*__bits__; \
-    FbStride	__stride__; \
-    int		__bpp__; \
-    int		__xoff__,__yoff__; \
-\
-    FbGetPixels((image)->pixels,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
-    switch (__bpp__) { \
-    case 32: \
-	(bits) = *(CARD32 *) __bits__; \
-	break; \
-    case 24: \
-	(bits) = Fetch24 ((CARD8 *) __bits__); \
-	break; \
-    case 16: \
-	(bits) = *(CARD16 *) __bits__; \
-	(bits) = cvt0565to8888(bits); \
-	break; \
-    case 8: \
-	(bits) = *(CARD8 *) __bits__; \
-	(bits) = (bits) << 24; \
-	break; \
-    case 1: \
-	(bits) = *(CARD32 *) __bits__; \
-	(bits) = FbLeftStipBits((bits),1) ? 0xff000000 : 0x00000000;\
-	break; \
-    default: \
-	return; \
-    } \
-    /* manage missing src alpha */ \
-    if ((image)->image_format.alphaMask == 0) \
-	(bits) |= 0xff000000; \
-}
-
-#define fbComposeGetStart(image,x,y,type,stride,line,mul) {\
-    FbBits	*__bits__; \
-    FbStride	__stride__; \
-    int		__bpp__; \
-    int		__xoff__,__yoff__; \
-\
-    FbGetPixels((image)->pixels,__bits__,__stride__,__bpp__,__xoff__,__yoff__); \
-    (stride) = __stride__ * sizeof (FbBits) / sizeof (type); \
-    (line) = ((type *) __bits__) + (stride) * ((y) + __yoff__) + (mul) * ((x) + __xoff__); \
-}
-
 #define genericCombine24(a,b,c,d) (((a)*(c)+(b)*(d)))
 
 #define fastcombine32(alpha, source, destval, destptr) { \
Index: src/icimage.h
===================================================================
RCS file: /cvs/cairo/libpixman/src/icimage.h,v
retrieving revision 1.26
diff -p -u -r1.26 icimage.h
--- src/icimage.h	25 Jun 2005 03:13:19 -0000	1.26
+++ src/icimage.h	5 Aug 2005 03:50:56 -0000
@@ -33,38 +33,6 @@
 #include "resource.h"
 */
 
-
-#define FbIntMult(a,b,t) ( (t) = (a) * (b) + 0x80, ( ( ( (t)>>8 ) + (t) )>>8 ) )
-#define FbIntDiv(a,b)	 (((uint16_t) (a) * 255) / (b))
-
-#define FbGet8(v,i)   ((uint16_t) (uint8_t) ((v) >> i))
-
-/*
- * There are two ways of handling alpha -- either as a single unified value or
- * a separate value for each component, hence each macro must have two
- * versions.  The unified alpha version has a 'U' at the end of the name,
- * the component version has a 'C'.  Similarly, functions which deal with
- * this difference will have two versions using the same convention.
- */
-
-#define FbOverU(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),(a),(t)) + FbGet8(x,i),\
-			   (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
-
-#define FbOverC(x,y,i,a,t) ((t) = FbIntMult(FbGet8(y,i),FbGet8(a,i),(t)) + FbGet8(x,i),\
-			    (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
-
-#define FbInU(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),(a),(t)) << (i))
-
-#define FbInC(x,i,a,t) ((uint32_t) FbIntMult(FbGet8(x,i),FbGet8(a,i),(t)) << (i))
-
-#define FbGen(x,y,i,ax,ay,t,u,v) ((t) = (FbIntMult(FbGet8(y,i),ay,(u)) + \
-					 FbIntMult(FbGet8(x,i),ax,(v))),\
-				  (uint32_t) ((uint8_t) ((t) | \
-						     (0 - ((t) >> 8)))) << (i))
-
-#define FbAdd(x,y,i,t)	((t) = FbGet8(x,i) + FbGet8(y,i), \
-			 (uint32_t) ((uint8_t) ((t) | (0 - ((t) >> 8)))) << (i))
-
 /*
 typedef struct _IndexFormat {
     VisualPtr	    pVisual; 
@@ -138,13 +106,12 @@ struct pixman_image {
 typedef uint8_t FbIndexType;
 #endif
 
-/* XXX: We're not supporting indexed operations, right?
+/* XXX: We're not supporting indexed operations, right? */
 typedef struct _FbIndexed {
     int	color;
     uint32_t	rgba[IC_MAX_INDEXED];
     FbIndexType	ent[32768];
 } FbIndexedRec, *FbIndexedPtr;
-*/
 
 #define FbCvtR8G8B8to15(s) ((((s) >> 3) & 0x001f) | \
 			     (((s) >> 6) & 0x03e0) | \
Index: src/icint.h
===================================================================
RCS file: /cvs/cairo/libpixman/src/icint.h,v
retrieving revision 1.36
diff -p -u -r1.36 icint.h
--- src/icint.h	2 Aug 2005 01:01:24 -0000	1.36
+++ src/icint.h	5 Aug 2005 03:50:56 -0000
@@ -929,9 +929,9 @@ typedef struct _PictFormat	*PictFormatPt
 #define PICT_a1b5g5r5	PICT_FORMAT(16,PICT_TYPE_ABGR,1,5,5,5)
 #define PICT_x1b5g5r5	PICT_FORMAT(16,PICT_TYPE_ABGR,0,5,5,5)
 #define PICT_a4r4g4b4	PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
-#define PICT_x4r4g4b4	PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
-#define PICT_a4b4g4r4	PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
-#define PICT_x4b4g4r4	PICT_FORMAT(16,PICT_TYPE_ARGB,4,4,4,4)
+#define PICT_x4r4g4b4	PICT_FORMAT(16,PICT_TYPE_ARGB,0,4,4,4)
+#define PICT_a4b4g4r4	PICT_FORMAT(16,PICT_TYPE_ABGR,4,4,4,4)
+#define PICT_x4b4g4r4	PICT_FORMAT(16,PICT_TYPE_ABGR,0,4,4,4)
 
 /* 8bpp formats */
 #define PICT_a8		PICT_FORMAT(8,PICT_TYPE_A,8,0,0,0)
Index: src/pixman-xserver-compat.h
===================================================================
RCS file: /cvs/cairo/libpixman/src/pixman-xserver-compat.h,v
retrieving revision 1.6
diff -p -u -r1.6 pixman-xserver-compat.h
--- src/pixman-xserver-compat.h	25 Jun 2005 22:03:17 -0000	1.6
+++ src/pixman-xserver-compat.h	5 Aug 2005 03:50:56 -0000
@@ -78,14 +78,30 @@ typedef pixman_triangle_t	xTriangle;
 /* XXX: We changed some function and field names which makes for some
  * ugly hacks... */
 #define pDrawable pixels
-#define fbGetDrawable(pDrawable, pointer, stride, bpp, xoff, yoff) { \
+#define fbGetDrawable(pDrawable, buf, outstride, outbpp, xoff, yoff) { \
     (buf) = (pDrawable)->data; \
-    (stride) = ((int) pDrawable->stride) / sizeof (pixman_bits_t); \
-    (bpp) = (pDrawable)->bpp; \
+    (outstride) = ((int) pDrawable->stride) / sizeof (pixman_bits_t); \
+    (outbpp) = (pDrawable)->bpp; \
     (xoff) = 0; \
     (yoff) = 0; \
 }
 
+/* Extended repeat attributes included in 0.10 */
+#define RepeatNone                          0
+#define RepeatNormal                        1
+#define RepeatPad                           2
+#define RepeatReflect                       3
+
+typedef pixman_vector_t PictVector;
+typedef pixman_vector_t* PictVectorPtr;
+
+#define miIndexedPtr FbIndexedPtr
+#define miIndexToEnt24 FbIndexToEnt24
+#define miIndexToEntY24 FbIndexToEntY24
+
+#define MAX_FIXED_48_16	    ((xFixed_48_16) 0x7fffffff)
+#define MIN_FIXED_48_16	    (-((xFixed_48_16) 1 << 31))
+
 /* Then, include any header files that have been copied directly
  * from xserver. */
 
-------------- next part --------------
--- ../libpixman-tmp/src/fb2/fbcompose.c	2005-08-01 15:51:42.000000000 -0400
+++ src/iccompose.c	2005-08-04 23:45:12.763647728 -0400
@@ -26,13 +26,45 @@
 #ifdef HAVE_CONFIG_H
 #include <config.h>
 #endif
-#include "fb.h"
+#include <stdio.h>
+#include "pixman-xserver-compat.h"
+#include "fbpict.h"
 
 #ifdef RENDER
 
-#include "picturestr.h"
-#include "mipict.h"
-#include "fbpict.h"
+#include "pixregionint.h"
+
+// #define PIXMAN_CONVOLUTION
+// #define PIXMAN_GRADIENTS
+// #define PIXMAN_INDEXED_FORMATS
+
+static Bool
+PictureTransformPoint3d (pixman_transform_t *transform,
+                         PictVector *vector)
+{
+    PictVector	    result;
+    int		    i, j;
+    xFixed_32_32    partial;
+    xFixed_48_16    v;
+
+    for (j = 0; j < 3; j++)
+    {
+	v = 0;
+	for (i = 0; i < 3; i++)
+	{
+	    partial = ((xFixed_48_16) transform->matrix[j][i] *
+		       (xFixed_48_16) vector->vector[i]);
+	    v += partial >> 16;
+	}
+	if (v > MAX_FIXED_48_16 || v < MIN_FIXED_48_16)
+	    return FALSE;
+	result.vector[j] = (xFixed) v;
+    }
+    if (!result.vector[2])
+	return FALSE;
+    *vector = result;
+    return TRUE;
+}
 
 #define mod(a,b)	((b) == 1 ? 0 : (a) >= 0 ? (a) % (b) : (b) - (-a) % (b))
 
@@ -509,7 +541,7 @@
 
 static fetchProc fetchProcForPicture (PicturePtr pict)
 {
-    switch(pict->format) {
+    switch(pict->format_code) {
     case PICT_a8r8g8b8: return fbFetch_a8r8g8b8;
     case PICT_x8r8g8b8: return fbFetch_x8r8g8b8;
     case PICT_a8b8g8r8: return fbFetch_a8b8g8r8;
@@ -937,7 +969,7 @@
 
 static fetchPixelProc fetchPixelProcForPicture (PicturePtr pict)
 {
-    switch(pict->format) {
+    switch(pict->format_code) {
     case PICT_a8r8g8b8: return fbFetchPixel_a8r8g8b8;
     case PICT_x8r8g8b8: return fbFetchPixel_x8r8g8b8;
     case PICT_a8b8g8r8: return fbFetchPixel_a8b8g8r8;
@@ -1374,7 +1406,7 @@
 
 static storeProc storeProcForPicture (PicturePtr pict)
 {
-    switch(pict->format) {
+    switch(pict->format_code) {
     case PICT_a8r8g8b8: return fbStore_a8r8g8b8;
     case PICT_x8r8g8b8: return fbStore_x8r8g8b8;
     case PICT_a8b8g8r8: return fbStore_a8b8g8r8;
@@ -2604,7 +2636,11 @@
     CARD32 color;
     CARD32 *end;
     fetchPixelProc fetch = fetchPixelProcForPicture(pict);
+#ifdef PIXMAN_INDEXED_FORMATS
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+#else
+    miIndexedPtr indexed = 0;
+#endif
 
     fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
     bits += yoff*stride + (xoff*bpp >> FB_SHIFT);
@@ -2623,7 +2659,11 @@
     int bpp;
     int xoff, yoff;
     fetchProc fetch = fetchProcForPicture(pict);
+#ifdef PIXMAN_INDEXED_FORMATS
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+#else
+    miIndexedPtr indexed = 0;
+#endif
 
     fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
     x += xoff;
@@ -2634,11 +2674,10 @@
     fetch(bits, x, width, buffer, indexed);
 }
 
-#define MOD(a,b) ((a) < 0 ? ((b) - ((-(a) - 1) % (b))) - 1 : (a) % (b))
 #define DIV(a,b) ((((a) < 0) == ((b) < 0)) ? (a) / (b) :\
         ((a) - (b) + 1 - (((b) < 0) << 1)) / (b))
 
-
+#ifdef PIXMAN_GRADIENTS
 static CARD32 gradientPixel(const SourcePictPtr pGradient, xFixed_48_16 pos, unsigned int spread)
 {
     int ipos = (pos * PICT_GRADIENT_STOPTABLE_SIZE - 1) >> 16;
@@ -2848,7 +2887,7 @@
         }
     }
 }
-
+#endif /* PIXMAN_GRADIENTS */
 
 
 static void fbFetchTransformed(PicturePtr pict, int x, int y, int width, CARD32 *buffer)
@@ -2862,7 +2901,11 @@
     PictVector  unit;
     int         i;
     BoxRec	box;
+#ifdef PIXMAN_INDEXED_FORMATS
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+#else
+    miIndexedPtr indexed = 0;
+#endif
 
     fetch = fetchPixelProcForPicture(pict);
 
@@ -2887,10 +2930,10 @@
         unit.vector[2] = 0;
     }
 
-    if (pict->filter == PictFilterNearest)
+    if (pict->filter == PIXMAN_FILTER_NEAREST || pict->filter == PIXMAN_FILTER_FAST)
     {
         if (pict->repeat == RepeatNormal) {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+            if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 box = pict->pCompositeClip->extents;
                 for (i = 0; i < width; ++i) {
                     if (!v.vector[2]) {
@@ -2911,7 +2954,7 @@
                     } else {
                         y = MOD(DIV(v.vector[1],v.vector[2]), pict->pDrawable->height);
                         x = MOD(DIV(v.vector[0],v.vector[2]), pict->pDrawable->width);
-                        if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
+                        if (pixman_region_contains_point (pict->pCompositeClip, x, y, &box))
                             buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
                         else
                             buffer[i] = 0;
@@ -2922,7 +2965,7 @@
                 }
             }
         } else {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+            if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 box = pict->pCompositeClip->extents;
                 for (i = 0; i < width; ++i) {
                     if (!v.vector[2]) {
@@ -2944,7 +2987,7 @@
                     } else {
                         y = DIV(v.vector[1],v.vector[2]);
                         x = DIV(v.vector[0],v.vector[2]);
-                        if (POINT_IN_REGION (0, pict->pCompositeClip, x, y, &box))
+                        if (pixman_region_contains_point (pict->pCompositeClip, x, y, &box))
                             buffer[i] = fetch(bits + (y + pict->pDrawable->y)*stride, x + pict->pDrawable->x, indexed);
                         else
                             buffer[i] = 0;
@@ -2955,9 +2998,9 @@
                 }
             }
         }
-    } else if (pict->filter == PictFilterBilinear) {
+    } else if (pict->filter == PIXMAN_FILTER_BILINEAR || pict->filter == PIXMAN_FILTER_GOOD || pict->filter == PIXMAN_FILTER_BEST) {
         if (pict->repeat == RepeatNormal) {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+            if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 box = pict->pCompositeClip->extents;
                 for (i = 0; i < width; ++i) {
                     if (!v.vector[2]) {
@@ -3031,14 +3074,14 @@
 
                         b = bits + (y1 + pict->pDrawable->y)*stride;
 
-                        tl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y1, &box)
+                        tl = pixman_region_contains_point(pict->pCompositeClip, x1, y1, &box)
                              ? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
-                        tr = POINT_IN_REGION(0, pict->pCompositeClip, x2, y1, &box)
+                        tr = pixman_region_contains_point(pict->pCompositeClip, x2, y1, &box)
                              ? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
                         b = bits + (y2 + pict->pDrawable->y)*stride;
-                        bl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y2, &box)
+                        bl = pixman_region_contains_point(pict->pCompositeClip, x1, y2, &box)
                              ? fetch(b, x1 + pict->pDrawable->x, indexed) : 0;
-                        br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
+                        br = pixman_region_contains_point(pict->pCompositeClip, x2, y2, &box)
                              ? fetch(b, x2 + pict->pDrawable->x, indexed) : 0;
 
                         FbByteAddMul_256(tl, idistx, tr, distx);
@@ -3052,7 +3095,7 @@
                 }
             }
         } else {
-            if (REGION_NUM_RECTS(pict->pCompositeClip) == 1) {
+            if (PIXREGION_NUM_RECTS(pict->pCompositeClip) == 1) {
                 box = pict->pCompositeClip->extents;
                 for (i = 0; i < width; ++i) {
                     if (!v.vector[2]) {
@@ -3124,14 +3167,14 @@
                         b = bits + (y1 + pict->pDrawable->y)*stride;
                         x_off = x1 + pict->pDrawable->x;
 
-                        tl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y1, &box)
+                        tl = pixman_region_contains_point(pict->pCompositeClip, x1, y1, &box)
                              ? fetch(b, x_off, indexed) : 0;
-                        tr = POINT_IN_REGION(0, pict->pCompositeClip, x2, y1, &box)
+                        tr = pixman_region_contains_point(pict->pCompositeClip, x2, y1, &box)
                              ? fetch(b, x_off + 1, indexed) : 0;
                         b += stride;
-                        bl = POINT_IN_REGION(0, pict->pCompositeClip, x1, y2, &box)
+                        bl = pixman_region_contains_point(pict->pCompositeClip, x1, y2, &box)
                              ? fetch(b, x_off, indexed) : 0;
-                        br = POINT_IN_REGION(0, pict->pCompositeClip, x2, y2, &box)
+                        br = pixman_region_contains_point(pict->pCompositeClip, x2, y2, &box)
                              ? fetch(b, x_off + 1, indexed) : 0;
 
                         FbByteAddMul_256(tl, idistx, tr, distx);
@@ -3145,6 +3188,7 @@
                 }
             }
         }
+#ifdef PIXMAN_CONVOLUTION
     } else if (pict->filter == PictFilterConvolution) {
         xFixed *params = pict->filter_params;
         INT32 cwidth = xFixedToInt(params[0]);
@@ -3174,7 +3218,7 @@
                     for (x = x1; x < x2; x++) {
                         if (*p) {
                             int tx = (pict->repeat == RepeatNormal) ? MOD (x, pict->pDrawable->width) : x;
-                            if (POINT_IN_REGION (0, pict->pCompositeClip, tx, ty, &box)) {
+                            if (pixman_region_contains_point (pict->pCompositeClip, tx, ty, &box)) {
                                 FbBits *b = bits + (ty + pict->pDrawable->y)*stride;
                                 CARD32 c = fetch(b, tx + pict->pDrawable->x, indexed);
 
@@ -3202,6 +3246,7 @@
             v.vector[1] += unit.vector[1];
             v.vector[2] += unit.vector[2];
         }
+#endif
     }
 }
 
@@ -3241,7 +3286,11 @@
     int bpp;
     int xoff, yoff;
     storeProc store = storeProcForPicture(pict);
+#ifdef PIXMAN_INDEXED_FORMATS
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+#else
+    miIndexedPtr indexed = 0;
+#endif
 
     fbGetDrawable (pict->pDrawable, bits, stride, bpp, xoff, yoff);
     x += xoff;
@@ -3260,7 +3309,11 @@
     int ax, ay;
     storeProc store;
     storeProc astore;
+#ifdef PIXMAN_INDEXED_FORMATS
     miIndexedPtr indexed = (miIndexedPtr) pict->pFormat->index.devPrivate;
+#else
+    miIndexedPtr indexed = 0;
+#endif
     miIndexedPtr aindexed;
 
     if (!pict->alphaMap) {
@@ -3270,7 +3323,11 @@
 
     store = storeProcForPicture(pict);
     astore = storeProcForPicture(pict->alphaMap);
+#ifdef PIXMAN_INDEXED_FORMATS
     aindexed = (miIndexedPtr) pict->alphaMap->pFormat->index.devPrivate;
+#else
+    aindexed = 0;
+#endif
 
     ax = x;
     ay = y;
@@ -3302,32 +3359,46 @@
     scanStoreProc store;
     scanFetchProc fetchSrc = 0, fetchMask = 0, fetchDest = 0;
 
-    if (data->op == PictOpClear)
+    if (data->op == PIXMAN_OPERATOR_CLEAR)
         fetchSrc = 0;
     else if (!data->src->pDrawable) {
+#ifdef PIXMAN_GRADIENTS
         if (data->src->pSourcePict)
             fetchSrc = fbFetchSourcePict;
+#endif
     } else if (data->src->alphaMap)
         fetchSrc = fbFetchExternalAlpha;
     else if (data->src->repeat == RepeatNormal &&
              data->src->pDrawable->width == 1 && data->src->pDrawable->height == 1)
         fetchSrc = fbFetchSolid;
+#ifdef PIXMAN_CONVOLUTION
     else if (!data->src->transform && data->src->filter != PictFilterConvolution)
         fetchSrc = fbFetch;
+#else
+    else if (!data->src->transform)
+        fetchSrc = fbFetch;
+#endif
     else
         fetchSrc = fbFetchTransformed;
 
-    if (data->mask && data->op != PictOpClear) {
+    if (data->mask && data->op != PIXMAN_OPERATOR_CLEAR) {
         if (!data->mask->pDrawable) {
+#ifdef PIXMAN_GRADIENTS
             if (data->mask->pSourcePict)
                 fetchMask = fbFetchSourcePict;
+#endif
         } else if (data->mask->alphaMap)
             fetchMask = fbFetchExternalAlpha;
         else if (data->mask->repeat == RepeatNormal
                  && data->mask->pDrawable->width == 1 && data->mask->pDrawable->height == 1)
             fetchMask = fbFetchSolid;
+#ifdef PIXMAN_CONVOLUTION
         else if (!data->mask->transform && data->mask->filter != PictFilterConvolution)
             fetchMask = fbFetch;
+#else
+        else if (!data->mask->transform)
+            fetchMask = fbFetch;
+#endif
         else
             fetchMask = fbFetchTransformed;
     } else {
@@ -3341,10 +3412,10 @@
         fetchDest = fbFetch;
         store = fbStore;
     }
-    if (data->op == PictOpClear || data->op == PictOpSrc)
+    if (data->op == PIXMAN_OPERATOR_CLEAR || data->op == PIXMAN_OPERATOR_SRC)
         fetchDest = 0;
 
-    if (fetchSrc && fetchMask && data->mask && data->mask->componentAlpha && PICT_FORMAT_RGB(data->mask->format)) {
+    if (fetchSrc && fetchMask && data->mask && data->mask->componentAlpha && PICT_FORMAT_RGB(data->mask->format_code)) {
         CARD32 *mask_buffer = dest_buffer + data->width;
         CombineFuncC compose = composeFunctions.combineC[data->op];
         if (!compose)
@@ -3408,7 +3479,7 @@
 }
 
 void
-fbCompositeGeneral (CARD8	op,
+pixman_compositeGeneral (pixman_operator_t	op,
 		    PicturePtr	pSrc,
 		    PicturePtr	pMask,
 		    PicturePtr	pDst,
@@ -3421,7 +3492,7 @@
 		    CARD16	width,
 		    CARD16	height)
 {
-    RegionRec	    region;
+    pixman_region16_t *region;
     int		    n;
     BoxPtr	    pbox;
     Bool	    srcRepeat = FALSE;
@@ -3439,10 +3510,13 @@
 	maskRepeat = pMask->repeat == RepeatNormal && !pMask->transform
                      && (pMask->pDrawable->width != 1 || pMask->pDrawable->height != 1);
 
-    if (op == PictOpOver && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format) && !pSrc->alphaMap)
-        op = PictOpSrc;
+    if (op == PIXMAN_OPERATOR_OVER && !pMask && !pSrc->transform && !PICT_FORMAT_A(pSrc->format_code) && !pSrc->alphaMap)
+        op = PIXMAN_OPERATOR_SRC;
+
+    region = pixman_region_create();
+    pixman_region_union_rect (region, region, xDst, yDst, width, height);
 
-    if (!miComputeCompositeRegion (&region,
+    if (!FbComputeCompositeRegion (region,
 				   pSrc,
 				   pMask,
 				   pDst,
@@ -3463,8 +3537,8 @@
     if (width > SCANLINE_BUFFER_LENGTH)
         scanline_buffer = (CARD32 *) malloc(width * 3 * sizeof(CARD32));
 
-    n = REGION_NUM_RECTS (&region);
-    pbox = REGION_RECTS (&region);
+    n = pixman_region_num_rects (region);
+    pbox = pixman_region_rects (region);
     while (n--)
     {
 	h = pbox->y2 - pbox->y1;
@@ -3518,7 +3592,7 @@
 	}
 	pbox++;
     }
-    REGION_UNINIT (pDst->pDrawable->pScreen, &region);
+    pixman_region_destroy (region);
 
     if (scanline_buffer != _scanline_buffer)
         free(scanline_buffer);
-------------- next part --------------
A non-text attachment was scrubbed...
Name: iccompose-patch.diff.gz
Type: application/x-gunzip
Size: 22149 bytes
Desc: not available
Url : http://lists.freedesktop.org/archives/cairo/attachments/20050804/b715f198/iccompose-patch.diff.bin


More information about the cairo mailing list