/* what follows is a long-winded way, avoiding any possibility of integer
* overflows, of saying:
- * stride = ((width * bpp + FB_MASK) >> FB_SHIFT) * sizeof (uint32_t);
+ * stride = ((width * bpp + 0x1f) >> 5) * sizeof (uint32_t);
*/
bpp = PIXMAN_FORMAT_BPP (format);
return NULL;
stride = width * bpp;
- if (pixman_addition_overflows_int (stride, FB_MASK))
+ if (pixman_addition_overflows_int (stride, 0x1f))
return NULL;
- stride += FB_MASK;
- stride >>= FB_SHIFT;
+ stride += 0x1f;
+ stride >>= 5;
-#if FB_SHIFT < 2
- if (pixman_multiply_overflows_int (stride, sizeof (uint32_t)))
- return NULL;
-#endif
stride *= sizeof (uint32_t);
if (pixman_multiply_overflows_int (height, stride))
#if N_BITS == 1
{
+
+#ifdef WORDS_BIGENDIAN
+# define FbScrLeft(x,n) ((x) << (n))
+# define FbScrRight(x,n) ((x) >> (n))
+#else
+# define FbScrLeft(x,n) ((x) >> (n))
+# define FbScrRight(x,n) ((x) << (n))
+#endif
+
+#define FbLeftMask(x) \
+ (((x) & 0x1f) ? \
+ FbScrRight (0xffffffff, (x) & 0x1f) : 0)
+#define FbRightMask(x) \
+ (((32 - (x)) & 0x1f) ? \
+ FbScrLeft (0xffffffff, (32 - (x)) & 0x1f) : 0)
+
+#define FbMaskBits(x,w,l,n,r) { \
+ n = (w); \
+ r = FbRightMask ((x) + n); \
+ l = FbLeftMask (x); \
+ if (l) { \
+ n -= 32 - ((x) & 0x1f); \
+ if (n < 0) { \
+ n = 0; \
+ l &= r; \
+ r = 0; \
+ } \
+ } \
+ n >>= 5; \
+ }
+
uint32_t *a = line;
uint32_t startmask;
uint32_t endmask;
int nmiddle;
int width = rxi - lxi;
int x = lxi;
-
- a += x >> FB_SHIFT;
- x &= FB_MASK;
-
+
+ a += x >> 5;
+ x &= 0x1f;
+
FbMaskBits (x, width, startmask, nmiddle, endmask);
- if (startmask) {
- WRITE(image, a, READ(image, a) | startmask);
- a++;
- }
- while (nmiddle--)
- WRITE(image, a++, FB_ALLONES);
- if (endmask)
- WRITE(image, a, READ(image, a) | endmask);
+
+ if (startmask) {
+ WRITE(image, a, READ(image, a) | startmask);
+ a++;
+ }
+ while (nmiddle--)
+ WRITE(image, a++, FB_ALLONES);
+ if (endmask)
+ WRITE(image, a, READ(image, a) | endmask);
}
#else
{
#undef DEBUG
#define DEBUG 0
-#define FB_SHIFT 5
-#define FB_UNIT (1 << FB_SHIFT)
-#define FB_HALFUNIT (1 << (FB_SHIFT-1))
-#define FB_MASK (FB_UNIT - 1)
+#define FB_MASK (0x1f)
#define FB_ALLONES ((uint32_t) -1)
/* Memory allocation helpers */
-#define LOG2_BITMAP_PAD 5
-#define FB_STIP_SHIFT LOG2_BITMAP_PAD
-#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
-#define FB_STIP_MASK (FB_STIP_UNIT - 1)
-#define FB_STIP_ALLONES ((uint32_t) -1)
-
-#ifdef WORDS_BIGENDIAN
-#define FbScrLeft(x,n) ((x) << (n))
-#define FbScrRight(x,n) ((x) >> (n))
-#define FbLeftStipBits(x,n) ((x) >> (FB_STIP_UNIT - (n)))
-#else
-#define FbScrLeft(x,n) ((x) >> (n))
-#define FbScrRight(x,n) ((x) << (n))
-#define FbLeftStipBits(x,n) ((x) & ((((uint32_t) 1) << (n)) - 1))
-#endif
-
-#define FbStipLeft(x,n) FbScrLeft(x,n)
-#define FbStipRight(x,n) FbScrRight(x,n)
-#define FbLeftMask(x) ( ((x) & FB_MASK) ? \
- FbScrRight(FB_ALLONES,(x) & FB_MASK) : 0)
-#define FbRightMask(x) ( ((FB_UNIT - (x)) & FB_MASK) ? \
- FbScrLeft(FB_ALLONES,(FB_UNIT - (x)) & FB_MASK) : 0)
-
-#define FbMaskBits(x,w,l,n,r) { \
- n = (w); \
- r = FbRightMask((x)+n); \
- l = FbLeftMask(x); \
- if (l) { \
- n -= FB_UNIT - ((x) & FB_MASK); \
- if (n < 0) { \
- n = 0; \
- l &= r; \
- r = 0; \
- } \
- } \
- n >>= FB_SHIFT; \
- }
-
#ifdef WORDS_BIGENDIAN
#define Fetch24(img, a) ((unsigned long) (a) & 1 ? \
((READ(img, a) << 16) | READ(img, (uint16_t *) ((a)+1))) : \