[cairo-commit] cairo/pixman/src icrect.c,1.16,1.17

Billy Biggs commit at pdx.freedesktop.org
Thu Aug 11 21:07:28 PDT 2005


Committed by: vektor

Update of /cvs/cairo/cairo/pixman/src
In directory gabe:/tmp/cvs-serv12880/src

Modified Files:
	icrect.c 
Log Message:
	* src/icrect.c: (pixman_fill_rect_1bpp): Fix to be correct for
	arbitrary xDst values.



Index: icrect.c
===================================================================
RCS file: /cvs/cairo/cairo/pixman/src/icrect.c,v
retrieving revision 1.16
retrieving revision 1.17
diff -u -d -r1.16 -r1.17
--- icrect.c	11 Aug 2005 05:03:00 -0000	1.16
+++ icrect.c	12 Aug 2005 04:07:26 -0000	1.17
@@ -38,14 +38,66 @@
 		       uint16_t	       height,
 		       pixman_bits_t  *pixel)
 {
-    char value = *pixel ? 0xff : 0;
+    uint32_t value = *pixel ? 0xffffffff : 0;
     char *line;
 
-    line = (char *)dst->pixels->data +
-	xDst + yDst * dst->pixels->stride;
-    while (height-- > 0) {
-	memset (line, value, (width + 7) / 8);
-	line += dst->pixels->stride;
+    line = (char *)dst->pixels->data
+	   + yDst * dst->pixels->stride;
+
+    if ((width + xDst - 1) / 32 == xDst / 32) {
+        uint32_t mask = 0;
+        int pos = xDst / 32;
+        int i;
+
+        for (i = xDst; i < width; i++)
+#if BITMAP_BIT_ORDER == MSBFirst
+            mask |= 1 << (0x1f - i);
+#else
+            mask |= 1 << i;
+#endif
+
+        while (height-- > 0) {
+            uint32_t *cur = (uint32_t *) line;
+            cur [pos] = (cur [pos] & ~mask) | (value & mask);
+	    line += dst->pixels->stride;
+        }
+    } else {
+        uint32_t smask = 0, emask = 0;
+        int end = ((xDst + width) / 32);
+        int i;
+
+        if (xDst % 32)
+            for (i = (xDst % 32); i < 32; i++)
+#if BITMAP_BIT_ORDER == MSBFirst
+                smask |= 1 << (0x1f - i);
+#else
+                smask |= 1 << i;
+#endif
+
+        if ((width + xDst) % 32)
+            for (i = 0; i < (width + xDst) % 32; i++)
+#if BITMAP_BIT_ORDER == MSBFirst
+                emask |= 1 << (0x1f - i);
+#else
+                emask |= 1 << i;
+#endif
+
+        while (height-- > 0) {
+            uint32_t *cur = (uint32_t *) line;
+            int start = (xDst / 32);
+
+            if (smask) {
+                cur [start] = (cur [start] & ~smask) | (value & smask);
+                start++;
+            }
+
+            if (emask)
+                cur [end] = (cur [end] & ~emask) | (value & emask);
+
+            if (end > start)
+                memset (cur + start, value, (end - start) * 4);
+	    line += dst->pixels->stride;
+        }
     }
 }
 




More information about the cairo-commit mailing list