aboutsummaryrefslogtreecommitdiff
path: root/xorg-server
diff options
context:
space:
mode:
authormarha <marha@users.sourceforge.net>2011-04-01 12:04:34 +0000
committermarha <marha@users.sourceforge.net>2011-04-01 12:04:34 +0000
commit0fd309bfed8f9f61a8ea8bbbe7628d0af471c070 (patch)
tree97a335ffb903e9cf159322f3906f9cb71d660d9c /xorg-server
parentdab40e0df33e80dab53b4ca20760c1fb4388649b (diff)
parent5d8e1ad0cd01de0bd0b43dc916c1d39fd293e79d (diff)
downloadvcxsrv-0fd309bfed8f9f61a8ea8bbbe7628d0af471c070.tar.gz
vcxsrv-0fd309bfed8f9f61a8ea8bbbe7628d0af471c070.tar.bz2
vcxsrv-0fd309bfed8f9f61a8ea8bbbe7628d0af471c070.zip
svn merge ^/branches/released .
Diffstat (limited to 'xorg-server')
-rw-r--r--xorg-server/fb/fb.h34
-rw-r--r--xorg-server/fb/fballpriv.c4
-rw-r--r--xorg-server/fb/fbarc.c4
-rw-r--r--xorg-server/fb/fbbits.c350
-rw-r--r--xorg-server/fb/fbblt.c1894
-rw-r--r--xorg-server/fb/fbbltone.c1736
-rw-r--r--xorg-server/fb/fbcopy.c2
-rw-r--r--xorg-server/fb/fbgc.c2
-rw-r--r--xorg-server/fb/fbgetsp.c172
-rw-r--r--xorg-server/fb/fbglyph.c18
-rw-r--r--xorg-server/fb/fbimage.c4
-rw-r--r--xorg-server/fb/fbline.c8
-rw-r--r--xorg-server/fb/fboverlay.c8
-rw-r--r--xorg-server/fb/fbpixmap.c2
-rw-r--r--xorg-server/fb/fbpoint.c6
-rw-r--r--xorg-server/fb/fbscreen.c6
-rw-r--r--xorg-server/fb/fbseg.c14
-rw-r--r--xorg-server/fb/fbsetsp.c2
-rw-r--r--xorg-server/fb/fbsolid.c422
-rw-r--r--xorg-server/fb/fbstipple.c620
-rw-r--r--xorg-server/fb/fbwindow.c61
21 files changed, 2598 insertions, 2771 deletions
diff --git a/xorg-server/fb/fb.h b/xorg-server/fb/fb.h
index 29eecadb3..b2f238e44 100644
--- a/xorg-server/fb/fb.h
+++ b/xorg-server/fb/fb.h
@@ -97,21 +97,10 @@
#if GLYPHPADBYTES != 4
#error "GLYPHPADBYTES must be 4"
#endif
-/* whether to bother to include 24bpp support */
-#ifndef FBNO24BIT
-#define FB_24BIT
-#endif
-
-/*
- * Unless otherwise instructed, fb includes code to advertise 24bpp
- * windows with 32bpp image format for application compatibility
- */
-#ifdef FB_24BIT
-#ifndef FBNO24_32
+/* for driver compat - intel UXA needs the second one at least */
+#define FB_24BIT
#define FB_24_32BIT
-#endif
-#endif
#define FB_STIP_SHIFT LOG2_BITMAP_PAD
#define FB_STIP_UNIT (1 << FB_STIP_SHIFT)
@@ -234,15 +223,6 @@ extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
n >>= FB_SHIFT; \
}
-#ifdef FBNOPIXADDR
-#define FbMaskBitsBytes(x,w,copy,l,lb,n,r,rb) FbMaskBits(x,w,l,n,r)
-#define FbDoLeftMaskByteRRop(dst,lb,l,and,xor) { \
- *dst = FbDoMaskRRop(*dst,and,xor,l); \
-}
-#define FbDoRightMaskByteRRop(dst,rb,r,and,xor) { \
- *dst = FbDoMaskRRop(*dst,and,xor,r); \
-}
-#else
#define FbByteMaskInvalid 0x10
@@ -454,7 +434,6 @@ extern _X_EXPORT void fbSetBits (FbStip *bits, int stride, FbStip data);
WRITE(dst, FbDoMaskRRop (READ(dst), and, xor, r)); \
} \
}
-#endif
#define FbMaskStip(x,w,l,n,r) { \
n = (w); \
@@ -612,9 +591,6 @@ fbGetWinPrivateKey (void);
extern _X_EXPORT const GCOps fbGCOps;
extern _X_EXPORT const GCFuncs fbGCFuncs;
-#ifdef FB_24_32BIT
-#define FB_SCREEN_PRIVATE
-#endif
/* Framebuffer access wrapper */
typedef FbBits (*ReadMemoryProcPtr)(const void *src, int size);
@@ -642,7 +618,6 @@ typedef void (*FinishWrapProcPtr)(DrawablePtr pDraw);
#endif
-#ifdef FB_SCREEN_PRIVATE
extern _X_EXPORT DevPrivateKey
fbGetScreenPrivateKey(void);
@@ -658,7 +633,6 @@ typedef struct {
#define fbGetScreenPrivate(pScreen) ((FbScreenPrivPtr) \
dixLookupPrivate(&(pScreen)->devPrivates, fbGetScreenPrivateKey()))
-#endif
/* private field of GC */
typedef struct {
@@ -1223,7 +1197,6 @@ fbBltOne (FbStip *src,
FbBits bgand,
FbBits bgxor);
-#ifdef FB_24BIT
extern _X_EXPORT void
fbBltOne24 (FbStip *src,
FbStride srcStride, /* FbStip units per scanline */
@@ -1240,7 +1213,6 @@ fbBltOne24 (FbStip *src,
FbBits fgxor,
FbBits bgand,
FbBits bgxor);
-#endif
extern _X_EXPORT void
fbBltPlane (FbBits *src,
@@ -1841,7 +1813,6 @@ fbSolid (FbBits *dst,
FbBits and,
FbBits xor);
-#ifdef FB_24BIT
extern _X_EXPORT void
fbSolid24 (FbBits *dst,
FbStride dstStride,
@@ -1852,7 +1823,6 @@ fbSolid24 (FbBits *dst,
FbBits and,
FbBits xor);
-#endif
/*
* fbstipple.c
diff --git a/xorg-server/fb/fballpriv.c b/xorg-server/fb/fballpriv.c
index b4fcb1f4a..1fe3a6934 100644
--- a/xorg-server/fb/fballpriv.c
+++ b/xorg-server/fb/fballpriv.c
@@ -26,11 +26,9 @@
#include "fb.h"
-#ifdef FB_SCREEN_PRIVATE
static DevPrivateKeyRec fbScreenPrivateKeyRec;
DevPrivateKey
fbGetScreenPrivateKey(void) { return &fbScreenPrivateKeyRec; }
-#endif
static DevPrivateKeyRec fbGCPrivateKeyRec;
DevPrivateKey
@@ -48,10 +46,8 @@ fbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
if (!dixRegisterPrivateKey(&fbGCPrivateKeyRec, PRIVATE_GC, sizeof(FbGCPrivRec)))
return FALSE;
-#ifdef FB_SCREEN_PRIVATE
if (!dixRegisterPrivateKey(&fbScreenPrivateKeyRec, PRIVATE_SCREEN, sizeof (FbScreenPrivRec)))
return FALSE;
-#endif
if (!dixRegisterPrivateKey(&fbWinPrivateKeyRec, PRIVATE_WINDOW, 0))
return FALSE;
diff --git a/xorg-server/fb/fbarc.c b/xorg-server/fb/fbarc.c
index 1da980255..07fb70c4e 100644
--- a/xorg-server/fb/fbarc.c
+++ b/xorg-server/fb/fbarc.c
@@ -47,7 +47,6 @@ fbPolyArc (DrawablePtr pDrawable,
if (pGC->lineWidth == 0)
{
-#ifndef FBNOPIXADDR
arc = 0;
if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
{
@@ -55,9 +54,7 @@ fbPolyArc (DrawablePtr pDrawable,
{
case 8: arc = fbArc8; break;
case 16: arc = fbArc16; break;
-#ifdef FB_24BIT
case 24: arc = fbArc24; break;
-#endif
case 32: arc = fbArc32; break;
}
}
@@ -141,7 +138,6 @@ fbPolyArc (DrawablePtr pDrawable,
#endif
}
else
-#endif
miZeroPolyArc (pDrawable, pGC, narcs, parcs);
}
else
diff --git a/xorg-server/fb/fbbits.c b/xorg-server/fb/fbbits.c
index 808374309..7cc4d24fe 100644
--- a/xorg-server/fb/fbbits.c
+++ b/xorg-server/fb/fbbits.c
@@ -1,176 +1,174 @@
-/*
- * Copyright © 1998 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
- * 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.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-#include "miline.h"
-#include "mizerarc.h"
-
-#undef BRESSOLID
-#undef BRESDASH
-#undef DOTS
-#undef ARC
-#undef GLYPH
-#undef BITS
-#undef BITS2
-#undef BITS4
-
-#define BRESSOLID fbBresSolid8
-#define BRESDASH fbBresDash8
-#define DOTS fbDots8
-#define ARC fbArc8
-#define GLYPH fbGlyph8
-#define POLYLINE fbPolyline8
-#define POLYSEGMENT fbPolySegment8
-#define BITS BYTE
-#define BITS2 CARD16
-#define BITS4 CARD32
-
-#include "fbbits.h"
-
-#undef BRESSOLID
-#undef BRESDASH
-#undef DOTS
-#undef ARC
-#undef GLYPH
-#undef POLYLINE
-#undef POLYSEGMENT
-#undef BITS
-#undef BITS2
-#undef BITS4
-
-#define BRESSOLID fbBresSolid16
-#define BRESDASH fbBresDash16
-#define DOTS fbDots16
-#define ARC fbArc16
-#define GLYPH fbGlyph16
-#define POLYLINE fbPolyline16
-#define POLYSEGMENT fbPolySegment16
-#define BITS CARD16
-#define BITS2 CARD32
-#if FB_SHIFT == 6
-#define BITS4 FbBits
-#endif
-
-#include "fbbits.h"
-
-#undef BRESSOLID
-#undef BRESDASH
-#undef DOTS
-#undef ARC
-#undef GLYPH
-#undef POLYLINE
-#undef POLYSEGMENT
-#undef BITS
-#undef BITS2
-#if FB_SHIFT == 6
-#undef BITS4
-#endif
-
-#ifdef FB_24BIT
-#define BRESSOLID fbBresSolid24
-#define BRESDASH fbBresDash24
-#define DOTS fbDots24
-#define ARC fbArc24
-#define POLYLINE fbPolyline24
-#define POLYSEGMENT fbPolySegment24
-
-#define BITS CARD32
-#define BITSUNIT BYTE
-#define BITSMUL 3
-
-#define FbDoTypeStore(b,t,x,s) WRITE(((t *) (b)), (x) >> (s))
-#define FbDoTypeRRop(b,t,a,x,s) WRITE((t *) (b), FbDoRRop(READ((t *) (b)),\
- (a) >> (s), \
- (x) >> (s)))
-#define FbDoTypeMaskRRop(b,t,a,x,m,s) WRITE((t *) (b), FbDoMaskRRop(READ((t *) (b)),\
- (a) >> (s), \
- (x) >> (s), \
- (m) >> (s)))
-#if BITMAP_BIT_ORDER == LSBFirst
-#define BITSSTORE(b,x) ((unsigned long) (b) & 1 ? \
- (FbDoTypeStore (b, CARD8, x, 0), \
- FbDoTypeStore ((b) + 1, CARD16, x, 8)) : \
- (FbDoTypeStore (b, CARD16, x, 0), \
- FbDoTypeStore ((b) + 2, CARD8, x, 16)))
-#define BITSRROP(b,a,x) ((unsigned long) (b) & 1 ? \
- (FbDoTypeRRop(b,CARD8,a,x,0), \
- FbDoTypeRRop((b)+1,CARD16,a,x,8)) : \
- (FbDoTypeRRop(b,CARD16,a,x,0), \
- FbDoTypeRRop((b)+2,CARD8,a,x,16)))
-#else
-#define BITSSTORE(b,x) ((unsigned long) (b) & 1 ? \
- (FbDoTypeStore (b, CARD8, x, 16), \
- FbDoTypeStore ((b) + 1, CARD16, x, 0)) : \
- (FbDoTypeStore (b, CARD16, x, 8), \
- FbDoTypeStore ((b) + 2, CARD8, x, 0)))
-#define BITSRROP(b,a,x) ((unsigned long) (b) & 1 ? \
- (FbDoTypeRRop (b, CARD8, a, x, 16), \
- FbDoTypeRRop ((b) + 1, CARD16, a, x, 0)) : \
- (FbDoTypeRRop (b, CARD16, a, x, 8), \
- FbDoTypeRRop ((b) + 2, CARD8, a, x, 0)))
-#endif
-
-#include "fbbits.h"
-
-#undef BITSSTORE
-#undef BITSRROP
-#undef BITSMUL
-#undef BITSUNIT
-#undef BITS
-
-#undef BRESSOLID
-#undef BRESDASH
-#undef DOTS
-#undef ARC
-#undef POLYLINE
-#undef POLYSEGMENT
-#endif /* FB_24BIT */
-
-#define BRESSOLID fbBresSolid32
-#define BRESDASH fbBresDash32
-#define DOTS fbDots32
-#define ARC fbArc32
-#define GLYPH fbGlyph32
-#define POLYLINE fbPolyline32
-#define POLYSEGMENT fbPolySegment32
-#define BITS CARD32
-#if FB_SHIFT == 6
-#define BITS2 FbBits
-#endif
-
-#include "fbbits.h"
-
-#undef BRESSOLID
-#undef BRESDASH
-#undef DOTS
-#undef ARC
-#undef GLYPH
-#undef POLYLINE
-#undef POLYSEGMENT
-#undef BITS
-#if FB_SHIFT == 6
-#undef BITS2
-#endif
+/*
+ * Copyright © 1998 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
+ * 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.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+#include "miline.h"
+#include "mizerarc.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef BITS
+#undef BITS2
+#undef BITS4
+
+#define BRESSOLID fbBresSolid8
+#define BRESDASH fbBresDash8
+#define DOTS fbDots8
+#define ARC fbArc8
+#define GLYPH fbGlyph8
+#define POLYLINE fbPolyline8
+#define POLYSEGMENT fbPolySegment8
+#define BITS BYTE
+#define BITS2 CARD16
+#define BITS4 CARD32
+
+#include "fbbits.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef POLYLINE
+#undef POLYSEGMENT
+#undef BITS
+#undef BITS2
+#undef BITS4
+
+#define BRESSOLID fbBresSolid16
+#define BRESDASH fbBresDash16
+#define DOTS fbDots16
+#define ARC fbArc16
+#define GLYPH fbGlyph16
+#define POLYLINE fbPolyline16
+#define POLYSEGMENT fbPolySegment16
+#define BITS CARD16
+#define BITS2 CARD32
+#if FB_SHIFT == 6
+#define BITS4 FbBits
+#endif
+
+#include "fbbits.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef POLYLINE
+#undef POLYSEGMENT
+#undef BITS
+#undef BITS2
+#if FB_SHIFT == 6
+#undef BITS4
+#endif
+
+#define BRESSOLID fbBresSolid24
+#define BRESDASH fbBresDash24
+#define DOTS fbDots24
+#define ARC fbArc24
+#define POLYLINE fbPolyline24
+#define POLYSEGMENT fbPolySegment24
+
+#define BITS CARD32
+#define BITSUNIT BYTE
+#define BITSMUL 3
+
+#define FbDoTypeStore(b,t,x,s) WRITE(((t *) (b)), (x) >> (s))
+#define FbDoTypeRRop(b,t,a,x,s) WRITE((t *) (b), FbDoRRop(READ((t *) (b)),\
+ (a) >> (s), \
+ (x) >> (s)))
+#define FbDoTypeMaskRRop(b,t,a,x,m,s) WRITE((t *) (b), FbDoMaskRRop(READ((t *) (b)),\
+ (a) >> (s), \
+ (x) >> (s), \
+ (m) >> (s)))
+#if BITMAP_BIT_ORDER == LSBFirst
+#define BITSSTORE(b,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeStore (b, CARD8, x, 0), \
+ FbDoTypeStore ((b) + 1, CARD16, x, 8)) : \
+ (FbDoTypeStore (b, CARD16, x, 0), \
+ FbDoTypeStore ((b) + 2, CARD8, x, 16)))
+#define BITSRROP(b,a,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeRRop(b,CARD8,a,x,0), \
+ FbDoTypeRRop((b)+1,CARD16,a,x,8)) : \
+ (FbDoTypeRRop(b,CARD16,a,x,0), \
+ FbDoTypeRRop((b)+2,CARD8,a,x,16)))
+#else
+#define BITSSTORE(b,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeStore (b, CARD8, x, 16), \
+ FbDoTypeStore ((b) + 1, CARD16, x, 0)) : \
+ (FbDoTypeStore (b, CARD16, x, 8), \
+ FbDoTypeStore ((b) + 2, CARD8, x, 0)))
+#define BITSRROP(b,a,x) ((unsigned long) (b) & 1 ? \
+ (FbDoTypeRRop (b, CARD8, a, x, 16), \
+ FbDoTypeRRop ((b) + 1, CARD16, a, x, 0)) : \
+ (FbDoTypeRRop (b, CARD16, a, x, 8), \
+ FbDoTypeRRop ((b) + 2, CARD8, a, x, 0)))
+#endif
+
+#include "fbbits.h"
+
+#undef BITSSTORE
+#undef BITSRROP
+#undef BITSMUL
+#undef BITSUNIT
+#undef BITS
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef POLYLINE
+#undef POLYSEGMENT
+
+#define BRESSOLID fbBresSolid32
+#define BRESDASH fbBresDash32
+#define DOTS fbDots32
+#define ARC fbArc32
+#define GLYPH fbGlyph32
+#define POLYLINE fbPolyline32
+#define POLYSEGMENT fbPolySegment32
+#define BITS CARD32
+#if FB_SHIFT == 6
+#define BITS2 FbBits
+#endif
+
+#include "fbbits.h"
+
+#undef BRESSOLID
+#undef BRESDASH
+#undef DOTS
+#undef ARC
+#undef GLYPH
+#undef POLYLINE
+#undef POLYSEGMENT
+#undef BITS
+#if FB_SHIFT == 6
+#undef BITS2
+#endif
diff --git a/xorg-server/fb/fbblt.c b/xorg-server/fb/fbblt.c
index 38271c0c9..053b78ab2 100644
--- a/xorg-server/fb/fbblt.c
+++ b/xorg-server/fb/fbblt.c
@@ -1,951 +1,943 @@
-/*
- * Copyright © 1998 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
- * 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.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include <string.h>
-#include "fb.h"
-
-#define InitializeShifts(sx,dx,ls,rs) { \
- if (sx != dx) { \
- if (sx > dx) { \
- ls = sx - dx; \
- rs = FB_UNIT - ls; \
- } else { \
- rs = dx - sx; \
- ls = FB_UNIT - rs; \
- } \
- } \
-}
-
-void
-fbBlt (FbBits *srcLine,
- FbStride srcStride,
- int srcX,
-
- FbBits *dstLine,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
- int bpp,
-
- Bool reverse,
- Bool upsidedown)
-{
- FbBits *src, *dst;
- int leftShift, rightShift;
- FbBits startmask, endmask;
- FbBits bits, bits1;
- int n, nmiddle;
- Bool destInvarient;
- int startbyte, endbyte;
- FbDeclareMergeRop ();
-
-#ifdef FB_24BIT
- if (bpp == 24 && !FbCheck24Pix (pm))
- {
- fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
- width, height, alu, pm, reverse, upsidedown);
- return;
- }
-#endif
-
- if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
- !(srcX & 7) && !(dstX & 7) && !(width & 7)) {
- int i;
- CARD8 *src = (CARD8 *) srcLine;
- CARD8 *dst = (CARD8 *) dstLine;
-
- srcStride *= sizeof(FbBits);
- dstStride *= sizeof(FbBits);
- width >>= 3;
- src += (srcX >> 3);
- dst += (dstX >> 3);
-
- if (!upsidedown)
- for (i = 0; i < height; i++)
- MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);
- else
- for (i = height - 1; i >= 0; i--)
- MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);
-
- return;
- }
-
- FbInitializeMergeRop(alu, pm);
- destInvarient = FbDestInvarientMergeRop();
- if (upsidedown)
- {
- srcLine += (height - 1) * (srcStride);
- dstLine += (height - 1) * (dstStride);
- srcStride = -srcStride;
- dstStride = -dstStride;
- }
- FbMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte,
- nmiddle, endmask, endbyte);
- if (reverse)
- {
- srcLine += ((srcX + width - 1) >> FB_SHIFT) + 1;
- dstLine += ((dstX + width - 1) >> FB_SHIFT) + 1;
- srcX = (srcX + width - 1) & FB_MASK;
- dstX = (dstX + width - 1) & FB_MASK;
- }
- else
- {
- srcLine += srcX >> FB_SHIFT;
- dstLine += dstX >> FB_SHIFT;
- srcX &= FB_MASK;
- dstX &= FB_MASK;
- }
- if (srcX == dstX)
- {
- while (height--)
- {
- src = srcLine;
- srcLine += srcStride;
- dst = dstLine;
- dstLine += dstStride;
- if (reverse)
- {
- if (endmask)
- {
- bits = READ(--src);
- --dst;
- FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- WRITE(--dst, FbDoDestInvarientMergeRop(READ(--src)));
- }
- else
- {
- while (n--)
- {
- bits = READ(--src);
- --dst;
- WRITE(dst, FbDoMergeRop (bits, READ(dst)));
- }
- }
- if (startmask)
- {
- bits = READ(--src);
- --dst;
- FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
- }
- }
- else
- {
- if (startmask)
- {
- bits = READ(src++);
- FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
- dst++;
- }
- n = nmiddle;
- if (destInvarient)
- {
-#if 0
- /*
- * This provides some speedup on screen->screen blts
- * over the PCI bus, usually about 10%. But fb
- * isn't usually used for this operation...
- */
- if (_ca2 + 1 == 0 && _cx2 == 0)
- {
- FbBits t1, t2, t3, t4;
- while (n >= 4)
- {
- t1 = *src++;
- t2 = *src++;
- t3 = *src++;
- t4 = *src++;
- *dst++ = t1;
- *dst++ = t2;
- *dst++ = t3;
- *dst++ = t4;
- n -= 4;
- }
- }
-#endif
- while (n--)
- WRITE(dst++, FbDoDestInvarientMergeRop(READ(src++)));
- }
- else
- {
- while (n--)
- {
- bits = READ(src++);
- WRITE(dst, FbDoMergeRop (bits, READ(dst)));
- dst++;
- }
- }
- if (endmask)
- {
- bits = READ(src);
- FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
- }
- }
- }
- }
- else
- {
- if (srcX > dstX)
- {
- leftShift = srcX - dstX;
- rightShift = FB_UNIT - leftShift;
- }
- else
- {
- rightShift = dstX - srcX;
- leftShift = FB_UNIT - rightShift;
- }
- while (height--)
- {
- src = srcLine;
- srcLine += srcStride;
- dst = dstLine;
- dstLine += dstStride;
-
- bits1 = 0;
- if (reverse)
- {
- if (srcX < dstX)
- bits1 = READ(--src);
- if (endmask)
- {
- bits = FbScrRight(bits1, rightShift);
- if (FbScrRight(endmask, leftShift))
- {
- bits1 = READ(--src);
- bits |= FbScrLeft(bits1, leftShift);
- }
- --dst;
- FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- {
- bits = FbScrRight(bits1, rightShift);
- bits1 = READ(--src);
- bits |= FbScrLeft(bits1, leftShift);
- --dst;
- WRITE(dst, FbDoDestInvarientMergeRop(bits));
- }
- }
- else
- {
- while (n--)
- {
- bits = FbScrRight(bits1, rightShift);
- bits1 = READ(--src);
- bits |= FbScrLeft(bits1, leftShift);
- --dst;
- WRITE(dst, FbDoMergeRop(bits, READ(dst)));
- }
- }
- if (startmask)
- {
- bits = FbScrRight(bits1, rightShift);
- if (FbScrRight(startmask, leftShift))
- {
- bits1 = READ(--src);
- bits |= FbScrLeft(bits1, leftShift);
- }
- --dst;
- FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
- }
- }
- else
- {
- if (srcX > dstX)
- bits1 = READ(src++);
- if (startmask)
- {
- bits = FbScrLeft(bits1, leftShift);
- if (FbScrLeft(startmask, rightShift))
- {
- bits1 = READ(src++);
- bits |= FbScrRight(bits1, rightShift);
- }
- FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
- dst++;
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- {
- bits = FbScrLeft(bits1, leftShift);
- bits1 = READ(src++);
- bits |= FbScrRight(bits1, rightShift);
- WRITE(dst, FbDoDestInvarientMergeRop(bits));
- dst++;
- }
- }
- else
- {
- while (n--)
- {
- bits = FbScrLeft(bits1, leftShift);
- bits1 = READ(src++);
- bits |= FbScrRight(bits1, rightShift);
- WRITE(dst, FbDoMergeRop(bits, READ(dst)));
- dst++;
- }
- }
- if (endmask)
- {
- bits = FbScrLeft(bits1, leftShift);
- if (FbScrLeft(endmask, rightShift))
- {
- bits1 = READ(src);
- bits |= FbScrRight(bits1, rightShift);
- }
- FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask);
- }
- }
- }
- }
-}
-
-#ifdef FB_24BIT
-
-#undef DEBUG_BLT24
-#ifdef DEBUG_BLT24
-
-static unsigned long
-getPixel (char *src, int x)
-{
- unsigned long l;
-
- l = 0;
- memcpy (&l, src + x * 3, 3);
- return l;
-}
-#endif
-
-static void
-fbBlt24Line (FbBits *src,
- int srcX,
-
- FbBits *dst,
- int dstX,
-
- int width,
-
- int alu,
- FbBits pm,
-
- Bool reverse)
-{
-#ifdef DEBUG_BLT24
- char *origDst = (char *) dst;
- FbBits *origLine = dst + ((dstX >> FB_SHIFT) - 1);
- int origNlw = ((width + FB_MASK) >> FB_SHIFT) + 3;
- int origX = dstX / 24;
-#endif
-
- int leftShift, rightShift;
- FbBits startmask, endmask;
- int n;
-
- FbBits bits, bits1;
- FbBits mask;
-
- int rot;
- FbDeclareMergeRop ();
-
- FbInitializeMergeRop (alu, FB_ALLONES);
- FbMaskBits(dstX, width, startmask, n, endmask);
-#ifdef DEBUG_BLT24
- ErrorF ("dstX %d width %d reverse %d\n", dstX, width, reverse);
-#endif
- if (reverse)
- {
- src += ((srcX + width - 1) >> FB_SHIFT) + 1;
- dst += ((dstX + width - 1) >> FB_SHIFT) + 1;
- rot = FbFirst24Rot (((dstX + width - 8) & FB_MASK));
- rot = FbPrev24Rot(rot);
-#ifdef DEBUG_BLT24
- ErrorF ("dstX + width - 8: %d rot: %d\n", (dstX + width - 8) & FB_MASK, rot);
-#endif
- srcX = (srcX + width - 1) & FB_MASK;
- dstX = (dstX + width - 1) & FB_MASK;
- }
- else
- {
- src += srcX >> FB_SHIFT;
- dst += dstX >> FB_SHIFT;
- srcX &= FB_MASK;
- dstX &= FB_MASK;
- rot = FbFirst24Rot (dstX);
-#ifdef DEBUG_BLT24
- ErrorF ("dstX: %d rot: %d\n", dstX, rot);
-#endif
- }
- mask = FbRot24(pm,rot);
-#ifdef DEBUG_BLT24
- ErrorF ("pm 0x%x mask 0x%x\n", pm, mask);
-#endif
- if (srcX == dstX)
- {
- if (reverse)
- {
- if (endmask)
- {
- bits = READ(--src);
- --dst;
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask));
- mask = FbPrev24Pix (mask);
- }
- while (n--)
- {
- bits = READ(--src);
- --dst;
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask));
- mask = FbPrev24Pix (mask);
- }
- if (startmask)
- {
- bits = READ(--src);
- --dst;
- WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask & startmask));
- }
- }
- else
- {
- if (startmask)
- {
- bits = READ(src++);
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask));
- dst++;
- mask = FbNext24Pix(mask);
- }
- while (n--)
- {
- bits = READ(src++);
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask));
- dst++;
- mask = FbNext24Pix(mask);
- }
- if (endmask)
- {
- bits = READ(src);
- WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask & endmask));
- }
- }
- }
- else
- {
- if (srcX > dstX)
- {
- leftShift = srcX - dstX;
- rightShift = FB_UNIT - leftShift;
- }
- else
- {
- rightShift = dstX - srcX;
- leftShift = FB_UNIT - rightShift;
- }
-
- bits1 = 0;
- if (reverse)
- {
- if (srcX < dstX)
- bits1 = READ(--src);
- if (endmask)
- {
- bits = FbScrRight(bits1, rightShift);
- if (FbScrRight(endmask, leftShift))
- {
- bits1 = READ(--src);
- bits |= FbScrLeft(bits1, leftShift);
- }
- --dst;
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask));
- mask = FbPrev24Pix(mask);
- }
- while (n--)
- {
- bits = FbScrRight(bits1, rightShift);
- bits1 = READ(--src);
- bits |= FbScrLeft(bits1, leftShift);
- --dst;
- WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask));
- mask = FbPrev24Pix(mask);
- }
- if (startmask)
- {
- bits = FbScrRight(bits1, rightShift);
- if (FbScrRight(startmask, leftShift))
- {
- bits1 = READ(--src);
- bits |= FbScrLeft(bits1, leftShift);
- }
- --dst;
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask));
- }
- }
- else
- {
- if (srcX > dstX)
- bits1 = READ(src++);
- if (startmask)
- {
- bits = FbScrLeft(bits1, leftShift);
- bits1 = READ(src++);
- bits |= FbScrRight(bits1, rightShift);
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask));
- dst++;
- mask = FbNext24Pix(mask);
- }
- while (n--)
- {
- bits = FbScrLeft(bits1, leftShift);
- bits1 = READ(src++);
- bits |= FbScrRight(bits1, rightShift);
- WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask));
- dst++;
- mask = FbNext24Pix(mask);
- }
- if (endmask)
- {
- bits = FbScrLeft(bits1, leftShift);
- if (FbScrLeft(endmask, rightShift))
- {
- bits1 = READ(src);
- bits |= FbScrRight(bits1, rightShift);
- }
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask));
- }
- }
- }
-#ifdef DEBUG_BLT24
- {
- int firstx, lastx, x;
-
- firstx = origX;
- if (firstx)
- firstx--;
- lastx = origX + width/24 + 1;
- for (x = firstx; x <= lastx; x++)
- ErrorF ("%06x ", getPixel (origDst, x));
- ErrorF ("\n");
- while (origNlw--)
- ErrorF ("%08x ", *origLine++);
- ErrorF ("\n");
- }
-#endif
-}
-
-void
-fbBlt24 (FbBits *srcLine,
- FbStride srcStride,
- int srcX,
-
- FbBits *dstLine,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
-
- Bool reverse,
- Bool upsidedown)
-{
- if (upsidedown)
- {
- srcLine += (height-1) * srcStride;
- dstLine += (height-1) * dstStride;
- srcStride = -srcStride;
- dstStride = -dstStride;
- }
- while (height--)
- {
- fbBlt24Line (srcLine, srcX, dstLine, dstX, width, alu, pm, reverse);
- srcLine += srcStride;
- dstLine += dstStride;
- }
-#ifdef DEBUG_BLT24
- ErrorF ("\n");
-#endif
-}
-#endif /* FB_24BIT */
-
-#if FB_SHIFT == FB_STIP_SHIFT + 1
-
-/*
- * Could be generalized to FB_SHIFT > FB_STIP_SHIFT + 1 by
- * creating an ring of values stepped through for each line
- */
-
-void
-fbBltOdd (FbBits *srcLine,
- FbStride srcStrideEven,
- FbStride srcStrideOdd,
- int srcXEven,
- int srcXOdd,
-
- FbBits *dstLine,
- FbStride dstStrideEven,
- FbStride dstStrideOdd,
- int dstXEven,
- int dstXOdd,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
- int bpp)
-{
- FbBits *src;
- int leftShiftEven, rightShiftEven;
- FbBits startmaskEven, endmaskEven;
- int nmiddleEven;
-
- FbBits *dst;
- int leftShiftOdd, rightShiftOdd;
- FbBits startmaskOdd, endmaskOdd;
- int nmiddleOdd;
-
- int leftShift, rightShift;
- FbBits startmask, endmask;
- int nmiddle;
-
- int srcX, dstX;
-
- FbBits bits, bits1;
- int n;
-
- Bool destInvarient;
- Bool even;
- FbDeclareMergeRop ();
-
- FbInitializeMergeRop (alu, pm);
- destInvarient = FbDestInvarientMergeRop();
-
- srcLine += srcXEven >> FB_SHIFT;
- dstLine += dstXEven >> FB_SHIFT;
- srcXEven &= FB_MASK;
- dstXEven &= FB_MASK;
- srcXOdd &= FB_MASK;
- dstXOdd &= FB_MASK;
-
- FbMaskBits(dstXEven, width, startmaskEven, nmiddleEven, endmaskEven);
- FbMaskBits(dstXOdd, width, startmaskOdd, nmiddleOdd, endmaskOdd);
-
- even = TRUE;
- InitializeShifts(srcXEven, dstXEven, leftShiftEven, rightShiftEven);
- InitializeShifts(srcXOdd, dstXOdd, leftShiftOdd, rightShiftOdd);
- while (height--)
- {
- src = srcLine;
- dst = dstLine;
- if (even)
- {
- srcX = srcXEven;
- dstX = dstXEven;
- startmask = startmaskEven;
- endmask = endmaskEven;
- nmiddle = nmiddleEven;
- leftShift = leftShiftEven;
- rightShift = rightShiftEven;
- srcLine += srcStrideEven;
- dstLine += dstStrideEven;
- even = FALSE;
- }
- else
- {
- srcX = srcXOdd;
- dstX = dstXOdd;
- startmask = startmaskOdd;
- endmask = endmaskOdd;
- nmiddle = nmiddleOdd;
- leftShift = leftShiftOdd;
- rightShift = rightShiftOdd;
- srcLine += srcStrideOdd;
- dstLine += dstStrideOdd;
- even = TRUE;
- }
- if (srcX == dstX)
- {
- if (startmask)
- {
- bits = READ(src++);
- WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), startmask));
- dst++;
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- {
- bits = READ(src++);
- WRITE(dst, FbDoDestInvarientMergeRop(bits));
- dst++;
- }
- }
- else
- {
- while (n--)
- {
- bits = READ(src++);
- WRITE(dst, FbDoMergeRop (bits, READ(dst)));
- dst++;
- }
- }
- if (endmask)
- {
- bits = READ(src);
- WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), endmask));
- }
- }
- else
- {
- bits = 0;
- if (srcX > dstX)
- bits = READ(src++);
- if (startmask)
- {
- bits1 = FbScrLeft(bits, leftShift);
- bits = READ(src++);
- bits1 |= FbScrRight(bits, rightShift);
- WRITE(dst, FbDoMaskMergeRop (bits1, READ(dst), startmask));
- dst++;
- }
- n = nmiddle;
- if (destInvarient)
- {
- while (n--)
- {
- bits1 = FbScrLeft(bits, leftShift);
- bits = READ(src++);
- bits1 |= FbScrRight(bits, rightShift);
- WRITE(dst, FbDoDestInvarientMergeRop(bits1));
- dst++;
- }
- }
- else
- {
- while (n--)
- {
- bits1 = FbScrLeft(bits, leftShift);
- bits = READ(src++);
- bits1 |= FbScrRight(bits, rightShift);
- WRITE(dst, FbDoMergeRop(bits1, READ(dst)));
- dst++;
- }
- }
- if (endmask)
- {
- bits1 = FbScrLeft(bits, leftShift);
- if (FbScrLeft(endmask, rightShift))
- {
- bits = READ(src);
- bits1 |= FbScrRight(bits, rightShift);
- }
- WRITE(dst, FbDoMaskMergeRop (bits1, READ(dst), endmask));
- }
- }
- }
-}
-
-#ifdef FB_24BIT
-void
-fbBltOdd24 (FbBits *srcLine,
- FbStride srcStrideEven,
- FbStride srcStrideOdd,
- int srcXEven,
- int srcXOdd,
-
- FbBits *dstLine,
- FbStride dstStrideEven,
- FbStride dstStrideOdd,
- int dstXEven,
- int dstXOdd,
-
- int width,
- int height,
-
- int alu,
- FbBits pm)
-{
- Bool even = TRUE;
-
- while (height--)
- {
- if (even)
- {
- fbBlt24Line (srcLine, srcXEven, dstLine, dstXEven,
- width, alu, pm, FALSE);
- srcLine += srcStrideEven;
- dstLine += dstStrideEven;
- even = FALSE;
- }
- else
- {
- fbBlt24Line (srcLine, srcXOdd, dstLine, dstXOdd,
- width, alu, pm, FALSE);
- srcLine += srcStrideOdd;
- dstLine += dstStrideOdd;
- even = TRUE;
- }
- }
-}
-#endif
-
-#endif
-
-#if FB_STIP_SHIFT != FB_SHIFT
-void
-fbSetBltOdd (FbStip *stip,
- FbStride stipStride,
- int srcX,
- FbBits **bits,
- FbStride *strideEven,
- FbStride *strideOdd,
- int *srcXEven,
- int *srcXOdd)
-{
- int srcAdjust;
- int strideAdjust;
-
- /*
- * bytes needed to align source
- */
- srcAdjust = (((int) stip) & (FB_MASK >> 3));
- /*
- * FbStip units needed to align stride
- */
- strideAdjust = stipStride & (FB_MASK >> FB_STIP_SHIFT);
-
- *bits = (FbBits *) ((char *) stip - srcAdjust);
- if (srcAdjust)
- {
- *strideEven = FbStipStrideToBitsStride (stipStride + 1);
- *strideOdd = FbStipStrideToBitsStride (stipStride);
-
- *srcXEven = srcX + (srcAdjust << 3);
- *srcXOdd = srcX + (srcAdjust << 3) - (strideAdjust << FB_STIP_SHIFT);
- }
- else
- {
- *strideEven = FbStipStrideToBitsStride (stipStride);
- *strideOdd = FbStipStrideToBitsStride (stipStride + 1);
-
- *srcXEven = srcX;
- *srcXOdd = srcX + (strideAdjust << FB_STIP_SHIFT);
- }
-}
-#endif
-
-void
-fbBltStip (FbStip *src,
- FbStride srcStride, /* in FbStip units, not FbBits units */
- int srcX,
-
- FbStip *dst,
- FbStride dstStride, /* in FbStip units, not FbBits units */
- int dstX,
-
- int width,
- int height,
-
- int alu,
- FbBits pm,
- int bpp)
-{
-#if FB_STIP_SHIFT != FB_SHIFT
- if (FB_STIP_ODDSTRIDE(srcStride) || FB_STIP_ODDPTR(src) ||
- FB_STIP_ODDSTRIDE(dstStride) || FB_STIP_ODDPTR(dst))
- {
- FbStride srcStrideEven, srcStrideOdd;
- FbStride dstStrideEven, dstStrideOdd;
- int srcXEven, srcXOdd;
- int dstXEven, dstXOdd;
- FbBits *s, *d;
- int sx, dx;
-
- src += srcX >> FB_STIP_SHIFT;
- srcX &= FB_STIP_MASK;
- dst += dstX >> FB_STIP_SHIFT;
- dstX &= FB_STIP_MASK;
-
- fbSetBltOdd (src, srcStride, srcX,
- &s,
- &srcStrideEven, &srcStrideOdd,
- &srcXEven, &srcXOdd);
-
- fbSetBltOdd (dst, dstStride, dstX,
- &d,
- &dstStrideEven, &dstStrideOdd,
- &dstXEven, &dstXOdd);
-
-#ifdef FB_24BIT
- if (bpp == 24 && !FbCheck24Pix (pm))
- {
- fbBltOdd24 (s, srcStrideEven, srcStrideOdd,
- srcXEven, srcXOdd,
-
- d, dstStrideEven, dstStrideOdd,
- dstXEven, dstXOdd,
-
- width, height, alu, pm);
- }
- else
-#endif
- {
- fbBltOdd (s, srcStrideEven, srcStrideOdd,
- srcXEven, srcXOdd,
-
- d, dstStrideEven, dstStrideOdd,
- dstXEven, dstXOdd,
-
- width, height, alu, pm, bpp);
- }
- }
- else
-#endif
- {
- fbBlt ((FbBits *) src, FbStipStrideToBitsStride (srcStride),
- srcX,
- (FbBits *) dst, FbStipStrideToBitsStride (dstStride),
- dstX,
- width, height,
- alu, pm, bpp, FALSE, FALSE);
- }
-}
+/*
+ * Copyright © 1998 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
+ * 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.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include <string.h>
+#include "fb.h"
+
+#define InitializeShifts(sx,dx,ls,rs) { \
+ if (sx != dx) { \
+ if (sx > dx) { \
+ ls = sx - dx; \
+ rs = FB_UNIT - ls; \
+ } else { \
+ rs = dx - sx; \
+ ls = FB_UNIT - rs; \
+ } \
+ } \
+}
+
+void
+fbBlt (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp,
+
+ Bool reverse,
+ Bool upsidedown)
+{
+ FbBits *src, *dst;
+ int leftShift, rightShift;
+ FbBits startmask, endmask;
+ FbBits bits, bits1;
+ int n, nmiddle;
+ Bool destInvarient;
+ int startbyte, endbyte;
+ FbDeclareMergeRop ();
+
+ if (bpp == 24 && !FbCheck24Pix (pm))
+ {
+ fbBlt24 (srcLine, srcStride, srcX, dstLine, dstStride, dstX,
+ width, height, alu, pm, reverse, upsidedown);
+ return;
+ }
+
+ if (alu == GXcopy && pm == FB_ALLONES && !reverse &&
+ !(srcX & 7) && !(dstX & 7) && !(width & 7)) {
+ int i;
+ CARD8 *src = (CARD8 *) srcLine;
+ CARD8 *dst = (CARD8 *) dstLine;
+
+ srcStride *= sizeof(FbBits);
+ dstStride *= sizeof(FbBits);
+ width >>= 3;
+ src += (srcX >> 3);
+ dst += (dstX >> 3);
+
+ if (!upsidedown)
+ for (i = 0; i < height; i++)
+ MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);
+ else
+ for (i = height - 1; i >= 0; i--)
+ MEMCPY_WRAPPED(dst + i * dstStride, src + i * srcStride, width);
+
+ return;
+ }
+
+ FbInitializeMergeRop(alu, pm);
+ destInvarient = FbDestInvarientMergeRop();
+ if (upsidedown)
+ {
+ srcLine += (height - 1) * (srcStride);
+ dstLine += (height - 1) * (dstStride);
+ srcStride = -srcStride;
+ dstStride = -dstStride;
+ }
+ FbMaskBitsBytes (dstX, width, destInvarient, startmask, startbyte,
+ nmiddle, endmask, endbyte);
+ if (reverse)
+ {
+ srcLine += ((srcX + width - 1) >> FB_SHIFT) + 1;
+ dstLine += ((dstX + width - 1) >> FB_SHIFT) + 1;
+ srcX = (srcX + width - 1) & FB_MASK;
+ dstX = (dstX + width - 1) & FB_MASK;
+ }
+ else
+ {
+ srcLine += srcX >> FB_SHIFT;
+ dstLine += dstX >> FB_SHIFT;
+ srcX &= FB_MASK;
+ dstX &= FB_MASK;
+ }
+ if (srcX == dstX)
+ {
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += srcStride;
+ dst = dstLine;
+ dstLine += dstStride;
+ if (reverse)
+ {
+ if (endmask)
+ {
+ bits = READ(--src);
+ --dst;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ WRITE(--dst, FbDoDestInvarientMergeRop(READ(--src)));
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = READ(--src);
+ --dst;
+ WRITE(dst, FbDoMergeRop (bits, READ(dst)));
+ }
+ }
+ if (startmask)
+ {
+ bits = READ(--src);
+ --dst;
+ FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
+ }
+ }
+ else
+ {
+ if (startmask)
+ {
+ bits = READ(src++);
+ FbDoLeftMaskByteMergeRop(dst, bits, startbyte, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+#if 0
+ /*
+ * This provides some speedup on screen->screen blts
+ * over the PCI bus, usually about 10%. But fb
+ * isn't usually used for this operation...
+ */
+ if (_ca2 + 1 == 0 && _cx2 == 0)
+ {
+ FbBits t1, t2, t3, t4;
+ while (n >= 4)
+ {
+ t1 = *src++;
+ t2 = *src++;
+ t3 = *src++;
+ t4 = *src++;
+ *dst++ = t1;
+ *dst++ = t2;
+ *dst++ = t3;
+ *dst++ = t4;
+ n -= 4;
+ }
+ }
+#endif
+ while (n--)
+ WRITE(dst++, FbDoDestInvarientMergeRop(READ(src++)));
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = READ(src++);
+ WRITE(dst, FbDoMergeRop (bits, READ(dst)));
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = READ(src);
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ }
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ {
+ leftShift = srcX - dstX;
+ rightShift = FB_UNIT - leftShift;
+ }
+ else
+ {
+ rightShift = dstX - srcX;
+ leftShift = FB_UNIT - rightShift;
+ }
+ while (height--)
+ {
+ src = srcLine;
+ srcLine += srcStride;
+ dst = dstLine;
+ dstLine += dstStride;
+
+ bits1 = 0;
+ if (reverse)
+ {
+ if (srcX < dstX)
+ bits1 = READ(--src);
+ if (endmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(endmask, leftShift))
+ {
+ bits1 = READ(--src);
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ FbDoRightMaskByteMergeRop(dst, bits, endbyte, endmask);
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = READ(--src);
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ WRITE(dst, FbDoDestInvarientMergeRop(bits));
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = READ(--src);
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ WRITE(dst, FbDoMergeRop(bits, READ(dst)));
+ }
+ }
+ if (startmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(startmask, leftShift))
+ {
+ bits1 = READ(--src);
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ bits1 = READ(src++);
+ if (startmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(startmask, rightShift))
+ {
+ bits1 = READ(src++);
+ bits |= FbScrRight(bits1, rightShift);
+ }
+ FbDoLeftMaskByteMergeRop (dst, bits, startbyte, startmask);
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = READ(src++);
+ bits |= FbScrRight(bits1, rightShift);
+ WRITE(dst, FbDoDestInvarientMergeRop(bits));
+ dst++;
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = READ(src++);
+ bits |= FbScrRight(bits1, rightShift);
+ WRITE(dst, FbDoMergeRop(bits, READ(dst)));
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(endmask, rightShift))
+ {
+ bits1 = READ(src);
+ bits |= FbScrRight(bits1, rightShift);
+ }
+ FbDoRightMaskByteMergeRop (dst, bits, endbyte, endmask);
+ }
+ }
+ }
+ }
+}
+
+
+#undef DEBUG_BLT24
+#ifdef DEBUG_BLT24
+
+static unsigned long
+getPixel (char *src, int x)
+{
+ unsigned long l;
+
+ l = 0;
+ memcpy (&l, src + x * 3, 3);
+ return l;
+}
+#endif
+
+static void
+fbBlt24Line (FbBits *src,
+ int srcX,
+
+ FbBits *dst,
+ int dstX,
+
+ int width,
+
+ int alu,
+ FbBits pm,
+
+ Bool reverse)
+{
+#ifdef DEBUG_BLT24
+ char *origDst = (char *) dst;
+ FbBits *origLine = dst + ((dstX >> FB_SHIFT) - 1);
+ int origNlw = ((width + FB_MASK) >> FB_SHIFT) + 3;
+ int origX = dstX / 24;
+#endif
+
+ int leftShift, rightShift;
+ FbBits startmask, endmask;
+ int n;
+
+ FbBits bits, bits1;
+ FbBits mask;
+
+ int rot;
+ FbDeclareMergeRop ();
+
+ FbInitializeMergeRop (alu, FB_ALLONES);
+ FbMaskBits(dstX, width, startmask, n, endmask);
+#ifdef DEBUG_BLT24
+ ErrorF ("dstX %d width %d reverse %d\n", dstX, width, reverse);
+#endif
+ if (reverse)
+ {
+ src += ((srcX + width - 1) >> FB_SHIFT) + 1;
+ dst += ((dstX + width - 1) >> FB_SHIFT) + 1;
+ rot = FbFirst24Rot (((dstX + width - 8) & FB_MASK));
+ rot = FbPrev24Rot(rot);
+#ifdef DEBUG_BLT24
+ ErrorF ("dstX + width - 8: %d rot: %d\n", (dstX + width - 8) & FB_MASK, rot);
+#endif
+ srcX = (srcX + width - 1) & FB_MASK;
+ dstX = (dstX + width - 1) & FB_MASK;
+ }
+ else
+ {
+ src += srcX >> FB_SHIFT;
+ dst += dstX >> FB_SHIFT;
+ srcX &= FB_MASK;
+ dstX &= FB_MASK;
+ rot = FbFirst24Rot (dstX);
+#ifdef DEBUG_BLT24
+ ErrorF ("dstX: %d rot: %d\n", dstX, rot);
+#endif
+ }
+ mask = FbRot24(pm,rot);
+#ifdef DEBUG_BLT24
+ ErrorF ("pm 0x%x mask 0x%x\n", pm, mask);
+#endif
+ if (srcX == dstX)
+ {
+ if (reverse)
+ {
+ if (endmask)
+ {
+ bits = READ(--src);
+ --dst;
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask));
+ mask = FbPrev24Pix (mask);
+ }
+ while (n--)
+ {
+ bits = READ(--src);
+ --dst;
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask));
+ mask = FbPrev24Pix (mask);
+ }
+ if (startmask)
+ {
+ bits = READ(--src);
+ --dst;
+ WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask & startmask));
+ }
+ }
+ else
+ {
+ if (startmask)
+ {
+ bits = READ(src++);
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask));
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ while (n--)
+ {
+ bits = READ(src++);
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask));
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ if (endmask)
+ {
+ bits = READ(src);
+ WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask & endmask));
+ }
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ {
+ leftShift = srcX - dstX;
+ rightShift = FB_UNIT - leftShift;
+ }
+ else
+ {
+ rightShift = dstX - srcX;
+ leftShift = FB_UNIT - rightShift;
+ }
+
+ bits1 = 0;
+ if (reverse)
+ {
+ if (srcX < dstX)
+ bits1 = READ(--src);
+ if (endmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(endmask, leftShift))
+ {
+ bits1 = READ(--src);
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask));
+ mask = FbPrev24Pix(mask);
+ }
+ while (n--)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ bits1 = READ(--src);
+ bits |= FbScrLeft(bits1, leftShift);
+ --dst;
+ WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask));
+ mask = FbPrev24Pix(mask);
+ }
+ if (startmask)
+ {
+ bits = FbScrRight(bits1, rightShift);
+ if (FbScrRight(startmask, leftShift))
+ {
+ bits1 = READ(--src);
+ bits |= FbScrLeft(bits1, leftShift);
+ }
+ --dst;
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask));
+ }
+ }
+ else
+ {
+ if (srcX > dstX)
+ bits1 = READ(src++);
+ if (startmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = READ(src++);
+ bits |= FbScrRight(bits1, rightShift);
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & startmask));
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ while (n--)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ bits1 = READ(src++);
+ bits |= FbScrRight(bits1, rightShift);
+ WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), mask));
+ dst++;
+ mask = FbNext24Pix(mask);
+ }
+ if (endmask)
+ {
+ bits = FbScrLeft(bits1, leftShift);
+ if (FbScrLeft(endmask, rightShift))
+ {
+ bits1 = READ(src);
+ bits |= FbScrRight(bits1, rightShift);
+ }
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), mask & endmask));
+ }
+ }
+ }
+#ifdef DEBUG_BLT24
+ {
+ int firstx, lastx, x;
+
+ firstx = origX;
+ if (firstx)
+ firstx--;
+ lastx = origX + width/24 + 1;
+ for (x = firstx; x <= lastx; x++)
+ ErrorF ("%06x ", getPixel (origDst, x));
+ ErrorF ("\n");
+ while (origNlw--)
+ ErrorF ("%08x ", *origLine++);
+ ErrorF ("\n");
+ }
+#endif
+}
+
+void
+fbBlt24 (FbBits *srcLine,
+ FbStride srcStride,
+ int srcX,
+
+ FbBits *dstLine,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+
+ Bool reverse,
+ Bool upsidedown)
+{
+ if (upsidedown)
+ {
+ srcLine += (height-1) * srcStride;
+ dstLine += (height-1) * dstStride;
+ srcStride = -srcStride;
+ dstStride = -dstStride;
+ }
+ while (height--)
+ {
+ fbBlt24Line (srcLine, srcX, dstLine, dstX, width, alu, pm, reverse);
+ srcLine += srcStride;
+ dstLine += dstStride;
+ }
+#ifdef DEBUG_BLT24
+ ErrorF ("\n");
+#endif
+}
+
+#if FB_SHIFT == FB_STIP_SHIFT + 1
+
+/*
+ * Could be generalized to FB_SHIFT > FB_STIP_SHIFT + 1 by
+ * creating an ring of values stepped through for each line
+ */
+
+void
+fbBltOdd (FbBits *srcLine,
+ FbStride srcStrideEven,
+ FbStride srcStrideOdd,
+ int srcXEven,
+ int srcXOdd,
+
+ FbBits *dstLine,
+ FbStride dstStrideEven,
+ FbStride dstStrideOdd,
+ int dstXEven,
+ int dstXOdd,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp)
+{
+ FbBits *src;
+ int leftShiftEven, rightShiftEven;
+ FbBits startmaskEven, endmaskEven;
+ int nmiddleEven;
+
+ FbBits *dst;
+ int leftShiftOdd, rightShiftOdd;
+ FbBits startmaskOdd, endmaskOdd;
+ int nmiddleOdd;
+
+ int leftShift, rightShift;
+ FbBits startmask, endmask;
+ int nmiddle;
+
+ int srcX, dstX;
+
+ FbBits bits, bits1;
+ int n;
+
+ Bool destInvarient;
+ Bool even;
+ FbDeclareMergeRop ();
+
+ FbInitializeMergeRop (alu, pm);
+ destInvarient = FbDestInvarientMergeRop();
+
+ srcLine += srcXEven >> FB_SHIFT;
+ dstLine += dstXEven >> FB_SHIFT;
+ srcXEven &= FB_MASK;
+ dstXEven &= FB_MASK;
+ srcXOdd &= FB_MASK;
+ dstXOdd &= FB_MASK;
+
+ FbMaskBits(dstXEven, width, startmaskEven, nmiddleEven, endmaskEven);
+ FbMaskBits(dstXOdd, width, startmaskOdd, nmiddleOdd, endmaskOdd);
+
+ even = TRUE;
+ InitializeShifts(srcXEven, dstXEven, leftShiftEven, rightShiftEven);
+ InitializeShifts(srcXOdd, dstXOdd, leftShiftOdd, rightShiftOdd);
+ while (height--)
+ {
+ src = srcLine;
+ dst = dstLine;
+ if (even)
+ {
+ srcX = srcXEven;
+ dstX = dstXEven;
+ startmask = startmaskEven;
+ endmask = endmaskEven;
+ nmiddle = nmiddleEven;
+ leftShift = leftShiftEven;
+ rightShift = rightShiftEven;
+ srcLine += srcStrideEven;
+ dstLine += dstStrideEven;
+ even = FALSE;
+ }
+ else
+ {
+ srcX = srcXOdd;
+ dstX = dstXOdd;
+ startmask = startmaskOdd;
+ endmask = endmaskOdd;
+ nmiddle = nmiddleOdd;
+ leftShift = leftShiftOdd;
+ rightShift = rightShiftOdd;
+ srcLine += srcStrideOdd;
+ dstLine += dstStrideOdd;
+ even = TRUE;
+ }
+ if (srcX == dstX)
+ {
+ if (startmask)
+ {
+ bits = READ(src++);
+ WRITE(dst, FbDoMaskMergeRop (bits, READ(dst), startmask));
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits = READ(src++);
+ WRITE(dst, FbDoDestInvarientMergeRop(bits));
+ dst++;
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits = READ(src++);
+ WRITE(dst, FbDoMergeRop (bits, READ(dst)));
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits = READ(src);
+ WRITE(dst, FbDoMaskMergeRop(bits, READ(dst), endmask));
+ }
+ }
+ else
+ {
+ bits = 0;
+ if (srcX > dstX)
+ bits = READ(src++);
+ if (startmask)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ bits = READ(src++);
+ bits1 |= FbScrRight(bits, rightShift);
+ WRITE(dst, FbDoMaskMergeRop (bits1, READ(dst), startmask));
+ dst++;
+ }
+ n = nmiddle;
+ if (destInvarient)
+ {
+ while (n--)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ bits = READ(src++);
+ bits1 |= FbScrRight(bits, rightShift);
+ WRITE(dst, FbDoDestInvarientMergeRop(bits1));
+ dst++;
+ }
+ }
+ else
+ {
+ while (n--)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ bits = READ(src++);
+ bits1 |= FbScrRight(bits, rightShift);
+ WRITE(dst, FbDoMergeRop(bits1, READ(dst)));
+ dst++;
+ }
+ }
+ if (endmask)
+ {
+ bits1 = FbScrLeft(bits, leftShift);
+ if (FbScrLeft(endmask, rightShift))
+ {
+ bits = READ(src);
+ bits1 |= FbScrRight(bits, rightShift);
+ }
+ WRITE(dst, FbDoMaskMergeRop (bits1, READ(dst), endmask));
+ }
+ }
+ }
+}
+
+void
+fbBltOdd24 (FbBits *srcLine,
+ FbStride srcStrideEven,
+ FbStride srcStrideOdd,
+ int srcXEven,
+ int srcXOdd,
+
+ FbBits *dstLine,
+ FbStride dstStrideEven,
+ FbStride dstStrideOdd,
+ int dstXEven,
+ int dstXOdd,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm)
+{
+ Bool even = TRUE;
+
+ while (height--)
+ {
+ if (even)
+ {
+ fbBlt24Line (srcLine, srcXEven, dstLine, dstXEven,
+ width, alu, pm, FALSE);
+ srcLine += srcStrideEven;
+ dstLine += dstStrideEven;
+ even = FALSE;
+ }
+ else
+ {
+ fbBlt24Line (srcLine, srcXOdd, dstLine, dstXOdd,
+ width, alu, pm, FALSE);
+ srcLine += srcStrideOdd;
+ dstLine += dstStrideOdd;
+ even = TRUE;
+ }
+ }
+}
+
+#endif
+
+#if FB_STIP_SHIFT != FB_SHIFT
+void
+fbSetBltOdd (FbStip *stip,
+ FbStride stipStride,
+ int srcX,
+ FbBits **bits,
+ FbStride *strideEven,
+ FbStride *strideOdd,
+ int *srcXEven,
+ int *srcXOdd)
+{
+ int srcAdjust;
+ int strideAdjust;
+
+ /*
+ * bytes needed to align source
+ */
+ srcAdjust = (((int) stip) & (FB_MASK >> 3));
+ /*
+ * FbStip units needed to align stride
+ */
+ strideAdjust = stipStride & (FB_MASK >> FB_STIP_SHIFT);
+
+ *bits = (FbBits *) ((char *) stip - srcAdjust);
+ if (srcAdjust)
+ {
+ *strideEven = FbStipStrideToBitsStride (stipStride + 1);
+ *strideOdd = FbStipStrideToBitsStride (stipStride);
+
+ *srcXEven = srcX + (srcAdjust << 3);
+ *srcXOdd = srcX + (srcAdjust << 3) - (strideAdjust << FB_STIP_SHIFT);
+ }
+ else
+ {
+ *strideEven = FbStipStrideToBitsStride (stipStride);
+ *strideOdd = FbStipStrideToBitsStride (stipStride + 1);
+
+ *srcXEven = srcX;
+ *srcXOdd = srcX + (strideAdjust << FB_STIP_SHIFT);
+ }
+}
+#endif
+
+void
+fbBltStip (FbStip *src,
+ FbStride srcStride, /* in FbStip units, not FbBits units */
+ int srcX,
+
+ FbStip *dst,
+ FbStride dstStride, /* in FbStip units, not FbBits units */
+ int dstX,
+
+ int width,
+ int height,
+
+ int alu,
+ FbBits pm,
+ int bpp)
+{
+#if FB_STIP_SHIFT != FB_SHIFT
+ if (FB_STIP_ODDSTRIDE(srcStride) || FB_STIP_ODDPTR(src) ||
+ FB_STIP_ODDSTRIDE(dstStride) || FB_STIP_ODDPTR(dst))
+ {
+ FbStride srcStrideEven, srcStrideOdd;
+ FbStride dstStrideEven, dstStrideOdd;
+ int srcXEven, srcXOdd;
+ int dstXEven, dstXOdd;
+ FbBits *s, *d;
+ int sx, dx;
+
+ src += srcX >> FB_STIP_SHIFT;
+ srcX &= FB_STIP_MASK;
+ dst += dstX >> FB_STIP_SHIFT;
+ dstX &= FB_STIP_MASK;
+
+ fbSetBltOdd (src, srcStride, srcX,
+ &s,
+ &srcStrideEven, &srcStrideOdd,
+ &srcXEven, &srcXOdd);
+
+ fbSetBltOdd (dst, dstStride, dstX,
+ &d,
+ &dstStrideEven, &dstStrideOdd,
+ &dstXEven, &dstXOdd);
+
+ if (bpp == 24 && !FbCheck24Pix (pm))
+ {
+ fbBltOdd24 (s, srcStrideEven, srcStrideOdd,
+ srcXEven, srcXOdd,
+
+ d, dstStrideEven, dstStrideOdd,
+ dstXEven, dstXOdd,
+
+ width, height, alu, pm);
+ }
+ else
+ {
+ fbBltOdd (s, srcStrideEven, srcStrideOdd,
+ srcXEven, srcXOdd,
+
+ d, dstStrideEven, dstStrideOdd,
+ dstXEven, dstXOdd,
+
+ width, height, alu, pm, bpp);
+ }
+ }
+ else
+#endif
+ {
+ fbBlt ((FbBits *) src, FbStipStrideToBitsStride (srcStride),
+ srcX,
+ (FbBits *) dst, FbStipStrideToBitsStride (dstStride),
+ dstX,
+ width, height,
+ alu, pm, bpp, FALSE, FALSE);
+ }
+}
diff --git a/xorg-server/fb/fbbltone.c b/xorg-server/fb/fbbltone.c
index 5d5d2e6bf..4a08a5a33 100644
--- a/xorg-server/fb/fbbltone.c
+++ b/xorg-server/fb/fbbltone.c
@@ -1,879 +1,857 @@
-/*
- * Copyright © 1998 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
- * 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.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-/*
- * Example: srcX = 13 dstX = 8 (FB unit 32 dstBpp 8)
- *
- * **** **** **** **** **** **** **** ****
- * ^
- * ******** ******** ******** ********
- * ^
- * leftShift = 12
- * rightShift = 20
- *
- * Example: srcX = 0 dstX = 8 (FB unit 32 dstBpp 8)
- *
- * **** **** **** **** **** **** **** ****
- * ^
- * ******** ******** ******** ********
- * ^
- *
- * leftShift = 24
- * rightShift = 8
- */
-
-#define LoadBits {\
- if (leftShift) { \
- bitsRight = (src < srcEnd ? READ(src++) : 0); \
- bits = (FbStipLeft (bitsLeft, leftShift) | \
- FbStipRight(bitsRight, rightShift)); \
- bitsLeft = bitsRight; \
- } else \
- bits = (src < srcEnd ? READ(src++) : 0); \
-}
-
-#ifndef FBNOPIXADDR
-
-#define LaneCases1(n,a) case n: FbLaneCase(n,a); break
-#define LaneCases2(n,a) LaneCases1(n,a); LaneCases1(n+1,a)
-#define LaneCases4(n,a) LaneCases2(n,a); LaneCases2(n+2,a)
-#define LaneCases8(n,a) LaneCases4(n,a); LaneCases4(n+4,a)
-#define LaneCases16(n,a) LaneCases8(n,a); LaneCases8(n+8,a)
-#define LaneCases32(n,a) LaneCases16(n,a); LaneCases16(n+16,a)
-#define LaneCases64(n,a) LaneCases32(n,a); LaneCases32(n+32,a)
-#define LaneCases128(n,a) LaneCases64(n,a); LaneCases64(n+64,a)
-#define LaneCases256(n,a) LaneCases128(n,a); LaneCases128(n+128,a)
-
-#if FB_SHIFT == 6
-#define LaneCases(a) LaneCases256(0,a)
-#endif
-
-#if FB_SHIFT == 5
-#define LaneCases(a) LaneCases16(0,a)
-#endif
-
-#if FB_SHIFT == 6
-CARD8 fb8Lane[256] = {
-0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
-22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
-41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
-60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
-79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
-98, 99, 100, 101, 102,103,104,105,106,107,108,109,110,111,112,113,114,115,
-116, 117, 118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,
-134, 135, 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,
-152, 153, 154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,
-170, 171, 172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
-188, 189, 190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,
-206, 207, 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
-224, 225, 226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,
-242, 243, 244,245,246,247,248,249,250,251,252,253,254,255,
-};
-
-CARD8 fb16Lane[256] = {
- 0x00, 0x03, 0x0c, 0x0f,
- 0x30, 0x33, 0x3c, 0x3f,
- 0xc0, 0xc3, 0xcc, 0xcf,
- 0xf0, 0xf3, 0xfc, 0xff,
-};
-
-CARD8 fb32Lane[16] = {
- 0x00, 0x0f, 0xf0, 0xff,
-};
-#endif
-
-#if FB_SHIFT == 5
-CARD8 fb8Lane[16] = {
- 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
-};
-
-CARD8 fb16Lane[16] = {
- 0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-
-CARD8 fb32Lane[16] = {
- 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
-};
-#endif
-
-CARD8 *fbLaneTable[33] = {
- 0, 0, 0, 0, 0, 0, 0, 0,
- fb8Lane, 0, 0, 0, 0, 0, 0, 0,
- fb16Lane, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0,
- fb32Lane
-};
-#endif
-
-void
-fbBltOne (FbStip *src,
- FbStride srcStride, /* FbStip units per scanline */
- int srcX, /* bit position of source */
- FbBits *dst,
- FbStride dstStride, /* FbBits units per scanline */
- int dstX, /* bit position of dest */
- int dstBpp, /* bits per destination unit */
-
- int width, /* width in bits of destination */
- int height, /* height in scanlines */
-
- FbBits fgand, /* rrop values */
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor)
-{
- const FbBits *fbBits;
- FbBits *srcEnd;
- int pixelsPerDst; /* dst pixels per FbBits */
- int unitsPerSrc; /* src patterns per FbStip */
- int leftShift, rightShift; /* align source with dest */
- FbBits startmask, endmask; /* dest scanline masks */
- FbStip bits=0, bitsLeft, bitsRight;/* source bits */
- FbStip left;
- FbBits mask;
- int nDst; /* dest longwords (w.o. end) */
- int w;
- int n, nmiddle;
- int dstS; /* stipple-relative dst X coordinate */
- Bool copy; /* accelerate dest-invariant */
- Bool transparent; /* accelerate 0 nop */
- int srcinc; /* source units consumed */
- Bool endNeedsLoad = FALSE; /* need load for endmask */
-#ifndef FBNOPIXADDR
- CARD8 *fbLane;
-#endif
- int startbyte, endbyte;
-
-#ifdef FB_24BIT
- if (dstBpp == 24)
- {
- fbBltOne24 (src, srcStride, srcX,
- dst, dstStride, dstX, dstBpp,
- width, height,
- fgand, fgxor, bgand, bgxor);
- return;
- }
-#endif
-
- /*
- * Do not read past the end of the buffer!
- */
- srcEnd = src + height * srcStride;
-
- /*
- * Number of destination units in FbBits == number of stipple pixels
- * used each time
- */
- pixelsPerDst = FB_UNIT / dstBpp;
-
- /*
- * Number of source stipple patterns in FbStip
- */
- unitsPerSrc = FB_STIP_UNIT / pixelsPerDst;
-
- copy = FALSE;
- transparent = FALSE;
- if (bgand == 0 && fgand == 0)
- copy = TRUE;
- else if (bgand == FB_ALLONES && bgxor == 0)
- transparent = TRUE;
-
- /*
- * Adjust source and dest to nearest FbBits boundary
- */
- src += srcX >> FB_STIP_SHIFT;
- dst += dstX >> FB_SHIFT;
- srcX &= FB_STIP_MASK;
- dstX &= FB_MASK;
-
- FbMaskBitsBytes(dstX, width, copy,
- startmask, startbyte, nmiddle, endmask, endbyte);
-
- /*
- * Compute effective dest alignment requirement for
- * source -- must align source to dest unit boundary
- */
- dstS = dstX / dstBpp;
- /*
- * Compute shift constants for effective alignement
- */
- if (srcX >= dstS)
- {
- leftShift = srcX - dstS;
- rightShift = FB_STIP_UNIT - leftShift;
- }
- else
- {
- rightShift = dstS - srcX;
- leftShift = FB_STIP_UNIT - rightShift;
- }
- /*
- * Get pointer to stipple mask array for this depth
- */
- fbBits = 0; /* unused */
- if (pixelsPerDst <= 8)
- fbBits = fbStippleTable[pixelsPerDst];
-#ifndef FBNOPIXADDR
- fbLane = 0;
- if (transparent && fgand == 0 && dstBpp >= 8)
- fbLane = fbLaneTable[dstBpp];
-#endif
-
- /*
- * Compute total number of destination words written, but
- * don't count endmask
- */
- nDst = nmiddle;
- if (startmask)
- nDst++;
-
- dstStride -= nDst;
-
- /*
- * Compute total number of source words consumed
- */
-
- srcinc = (nDst + unitsPerSrc - 1) / unitsPerSrc;
-
- if (srcX > dstS)
- srcinc++;
- if (endmask)
- {
- endNeedsLoad = nDst % unitsPerSrc == 0;
- if (endNeedsLoad)
- srcinc++;
- }
-
- srcStride -= srcinc;
-
- /*
- * Copy rectangle
- */
- while (height--)
- {
- w = nDst; /* total units across scanline */
- n = unitsPerSrc; /* units avail in single stipple */
- if (n > w)
- n = w;
-
- bitsLeft = 0;
- if (srcX > dstS)
- bitsLeft = READ(src++);
- if (n)
- {
- /*
- * Load first set of stipple bits
- */
- LoadBits;
-
- /*
- * Consume stipple bits for startmask
- */
- if (startmask)
- {
-#if FB_UNIT > 32
- if (pixelsPerDst == 16)
- mask = FbStipple16Bits(FbLeftStipBits(bits,16));
- else
-#endif
- mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
-#ifndef FBNOPIXADDR
- if (fbLane)
- {
- fbTransparentSpan (dst, mask & startmask, fgxor, 1);
- }
- else
-#endif
- {
- if (mask || !transparent)
- FbDoLeftMaskByteStippleRRop (dst, mask,
- fgand, fgxor, bgand, bgxor,
- startbyte, startmask);
- }
- bits = FbStipLeft (bits, pixelsPerDst);
- dst++;
- n--;
- w--;
- }
- /*
- * Consume stipple bits across scanline
- */
- for (;;)
- {
- w -= n;
- if (copy)
- {
- while (n--)
- {
-#if FB_UNIT > 32
- if (pixelsPerDst == 16)
- mask = FbStipple16Bits(FbLeftStipBits(bits,16));
- else
-#endif
- mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
- WRITE(dst, FbOpaqueStipple (mask, fgxor, bgxor));
- dst++;
- bits = FbStipLeft(bits, pixelsPerDst);
- }
- }
- else
- {
-#ifndef FBNOPIXADDR
- if (fbLane)
- {
- while (bits && n)
- {
- switch (fbLane[FbLeftStipBits(bits,pixelsPerDst)]) {
- LaneCases((CARD8 *) dst);
- }
- bits = FbStipLeft(bits,pixelsPerDst);
- dst++;
- n--;
- }
- dst += n;
- }
- else
-#endif
- {
- while (n--)
- {
- left = FbLeftStipBits(bits,pixelsPerDst);
- if (left || !transparent)
- {
- mask = fbBits[left];
- WRITE(dst, FbStippleRRop (READ(dst), mask,
- fgand, fgxor, bgand, bgxor));
- }
- dst++;
- bits = FbStipLeft(bits, pixelsPerDst);
- }
- }
- }
- if (!w)
- break;
- /*
- * Load another set and reset number of available units
- */
- LoadBits;
- n = unitsPerSrc;
- if (n > w)
- n = w;
- }
- }
- /*
- * Consume stipple bits for endmask
- */
- if (endmask)
- {
- if (endNeedsLoad)
- {
- LoadBits;
- }
-#if FB_UNIT > 32
- if (pixelsPerDst == 16)
- mask = FbStipple16Bits(FbLeftStipBits(bits,16));
- else
-#endif
- mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
-#ifndef FBNOPIXADDR
- if (fbLane)
- {
- fbTransparentSpan (dst, mask & endmask, fgxor, 1);
- }
- else
-#endif
- {
- if (mask || !transparent)
- FbDoRightMaskByteStippleRRop (dst, mask,
- fgand, fgxor, bgand, bgxor,
- endbyte, endmask);
- }
- }
- dst += dstStride;
- src += srcStride;
- }
-}
-
-#ifdef FB_24BIT
-
-/*
- * Crufty macros to initialize the mask array, most of this
- * is to avoid compile-time warnings about shift overflow
- */
-
-#if BITMAP_BIT_ORDER == MSBFirst
-#define Mask24Pos(x,r) ((x)*24-(r))
-#else
-#define Mask24Pos(x,r) ((x)*24-((r) ? 24 - (r) : 0))
-#endif
-
-#define Mask24Neg(x,r) (Mask24Pos(x,r) < 0 ? -Mask24Pos(x,r) : 0)
-#define Mask24Check(x,r) (Mask24Pos(x,r) < 0 ? 0 : \
- Mask24Pos(x,r) >= FB_UNIT ? 0 : Mask24Pos(x,r))
-
-#define Mask24(x,r) (Mask24Pos(x,r) < FB_UNIT ? \
- (Mask24Pos(x,r) < 0 ? \
- 0xffffff >> Mask24Neg (x,r) : \
- 0xffffff << Mask24Check(x,r)) : 0)
-
-#define SelMask24(b,n,r) ((((b) >> n) & 1) * Mask24(n,r))
-
-/*
- * Untested for MSBFirst or FB_UNIT == 32
- */
-
-#if FB_UNIT == 64
-#define C4_24(b,r) \
- (SelMask24(b,0,r) | \
- SelMask24(b,1,r) | \
- SelMask24(b,2,r) | \
- SelMask24(b,3,r))
-
-#define FbStip24New(rot) (2 + (rot != 0))
-#define FbStip24Len 4
-
-const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
- /* rotate 0 */
- {
- C4_24( 0, 0), C4_24( 1, 0), C4_24( 2, 0), C4_24( 3, 0),
- C4_24( 4, 0), C4_24( 5, 0), C4_24( 6, 0), C4_24( 7, 0),
- C4_24( 8, 0), C4_24( 9, 0), C4_24(10, 0), C4_24(11, 0),
- C4_24(12, 0), C4_24(13, 0), C4_24(14, 0), C4_24(15, 0),
- },
- /* rotate 8 */
- {
- C4_24( 0, 8), C4_24( 1, 8), C4_24( 2, 8), C4_24( 3, 8),
- C4_24( 4, 8), C4_24( 5, 8), C4_24( 6, 8), C4_24( 7, 8),
- C4_24( 8, 8), C4_24( 9, 8), C4_24(10, 8), C4_24(11, 8),
- C4_24(12, 8), C4_24(13, 8), C4_24(14, 8), C4_24(15, 8),
- },
- /* rotate 16 */
- {
- C4_24( 0,16), C4_24( 1,16), C4_24( 2,16), C4_24( 3,16),
- C4_24( 4,16), C4_24( 5,16), C4_24( 6,16), C4_24( 7,16),
- C4_24( 8,16), C4_24( 9,16), C4_24(10,16), C4_24(11,16),
- C4_24(12,16), C4_24(13,16), C4_24(14,16), C4_24(15,16),
- }
-};
-
-#endif
-
-#if FB_UNIT == 32
-#define C2_24(b,r) \
- (SelMask24(b,0,r) | \
- SelMask24(b,1,r))
-
-#define FbStip24Len 2
-#if BITMAP_BIT_ORDER == MSBFirst
-#define FbStip24New(rot) (1 + (rot == 0))
-#else
-#define FbStip24New(rot) (1 + (rot == 8))
-#endif
-
-const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
- /* rotate 0 */
- {
- C2_24( 0, 0), C2_24 ( 1, 0), C2_24 ( 2, 0), C2_24 ( 3, 0),
- },
- /* rotate 8 */
- {
- C2_24( 0, 8), C2_24 ( 1, 8), C2_24 ( 2, 8), C2_24 ( 3, 8),
- },
- /* rotate 16 */
- {
- C2_24( 0,16), C2_24 ( 1,16), C2_24 ( 2,16), C2_24 ( 3,16),
- }
-};
-#endif
-
-#if BITMAP_BIT_ORDER == LSBFirst
-
-#define FbMergeStip24Bits(left, right, new) \
- (FbStipLeft (left, new) | FbStipRight ((right), (FbStip24Len - (new))))
-
-#define FbMergePartStip24Bits(left, right, llen, rlen) \
- (left | FbStipRight(right, llen))
-
-#else
-
-#define FbMergeStip24Bits(left, right, new) \
- ((FbStipLeft (left, new) & ((1 << FbStip24Len) - 1)) | right)
-
-#define FbMergePartStip24Bits(left, right, llen, rlen) \
- (FbStipLeft(left, rlen) | right)
-
-#endif
-
-#define fbFirstStipBits(len,stip) {\
- int __len = (len); \
- if (len <= remain) { \
- stip = FbLeftStipBits(bits, len); \
- } else { \
- stip = FbLeftStipBits(bits, remain); \
- bits = (src < srcEnd ? READ(src++) : 0); \
- __len = (len) - remain; \
- stip = FbMergePartStip24Bits(stip, FbLeftStipBits(bits, __len), \
- remain, __len); \
- remain = FB_STIP_UNIT; \
- } \
- bits = FbStipLeft (bits, __len); \
- remain -= __len; \
-}
-
-#define fbInitStipBits(offset,len,stip) {\
- bits = FbStipLeft (READ(src++),offset); \
- remain = FB_STIP_UNIT - offset; \
- fbFirstStipBits(len,stip); \
- stip = FbMergeStip24Bits (0, stip, len); \
-}
-
-#define fbNextStipBits(rot,stip) {\
- int __new = FbStip24New(rot); \
- FbStip __right; \
- fbFirstStipBits(__new, __right); \
- stip = FbMergeStip24Bits (stip, __right, __new); \
- rot = FbNext24Rot (rot); \
-}
-
-/*
- * Use deep mask tables that incorporate rotation, pull
- * a variable number of bits out of the stipple and
- * reuse the right bits as needed for the next write
- *
- * Yes, this is probably too much code, but most 24-bpp screens
- * have no acceleration so this code is used for stipples, copyplane
- * and text
- */
-void
-fbBltOne24 (FbStip *srcLine,
- FbStride srcStride, /* FbStip units per scanline */
- int srcX, /* bit position of source */
- FbBits *dst,
- FbStride dstStride, /* FbBits units per scanline */
- int dstX, /* bit position of dest */
- int dstBpp, /* bits per destination unit */
-
- int width, /* width in bits of destination */
- int height, /* height in scanlines */
-
- FbBits fgand, /* rrop values */
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor)
-{
- FbStip *src, *srcEnd;
- FbBits leftMask, rightMask, mask;
- int nlMiddle, nl;
- FbStip stip, bits;
- int remain;
- int dstS;
- int firstlen;
- int rot0, rot;
- int nDst;
-
- /*
- * Do not read past the end of the buffer!
- */
- srcEnd = srcLine + height * srcStride;
-
- srcLine += srcX >> FB_STIP_SHIFT;
- dst += dstX >> FB_SHIFT;
- srcX &= FB_STIP_MASK;
- dstX &= FB_MASK;
- rot0 = FbFirst24Rot (dstX);
-
- FbMaskBits (dstX, width, leftMask, nlMiddle, rightMask);
-
- dstS = (dstX + 23) / 24;
- firstlen = FbStip24Len - dstS;
-
- nDst = nlMiddle;
- if (leftMask)
- nDst++;
- dstStride -= nDst;
-
- /* opaque copy */
- if (bgand == 0 && fgand == 0)
- {
- while (height--)
- {
- rot = rot0;
- src = srcLine;
- srcLine += srcStride;
- fbInitStipBits (srcX,firstlen, stip);
- if (leftMask)
- {
- mask = fbStipple24Bits[rot >> 3][stip];
- WRITE(dst, (READ(dst) & ~leftMask) |
- (FbOpaqueStipple (mask,
- FbRot24(fgxor, rot),
- FbRot24(bgxor, rot))
- & leftMask));
- dst++;
- fbNextStipBits(rot,stip);
- }
- nl = nlMiddle;
- while (nl--)
- {
- mask = fbStipple24Bits[rot>>3][stip];
- WRITE(dst, FbOpaqueStipple (mask,
- FbRot24(fgxor, rot),
- FbRot24(bgxor, rot)));
- dst++;
- fbNextStipBits(rot,stip);
- }
- if (rightMask)
- {
- mask = fbStipple24Bits[rot >> 3][stip];
- WRITE(dst, (READ(dst) & ~rightMask) |
- (FbOpaqueStipple (mask,
- FbRot24(fgxor, rot),
- FbRot24(bgxor, rot))
- & rightMask));
- }
- dst += dstStride;
- src += srcStride;
- }
- }
- /* transparent copy */
- else if (bgand == FB_ALLONES && bgxor == 0 && fgand == 0)
- {
- while (height--)
- {
- rot = rot0;
- src = srcLine;
- srcLine += srcStride;
- fbInitStipBits (srcX, firstlen, stip);
- if (leftMask)
- {
- if (stip)
- {
- mask = fbStipple24Bits[rot >> 3][stip] & leftMask;
- WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
- }
- dst++;
- fbNextStipBits (rot, stip);
- }
- nl = nlMiddle;
- while (nl--)
- {
- if (stip)
- {
- mask = fbStipple24Bits[rot>>3][stip];
- WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor,rot) & mask));
- }
- dst++;
- fbNextStipBits (rot, stip);
- }
- if (rightMask)
- {
- if (stip)
- {
- mask = fbStipple24Bits[rot >> 3][stip] & rightMask;
- WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
- }
- }
- dst += dstStride;
- }
- }
- else
- {
- while (height--)
- {
- rot = rot0;
- src = srcLine;
- srcLine += srcStride;
- fbInitStipBits (srcX, firstlen, stip);
- if (leftMask)
- {
- mask = fbStipple24Bits[rot >> 3][stip];
- WRITE(dst, FbStippleRRopMask (READ(dst), mask,
- FbRot24(fgand, rot),
- FbRot24(fgxor, rot),
- FbRot24(bgand, rot),
- FbRot24(bgxor, rot),
- leftMask));
- dst++;
- fbNextStipBits(rot,stip);
- }
- nl = nlMiddle;
- while (nl--)
- {
- mask = fbStipple24Bits[rot >> 3][stip];
- WRITE(dst, FbStippleRRop (READ(dst), mask,
- FbRot24(fgand, rot),
- FbRot24(fgxor, rot),
- FbRot24(bgand, rot),
- FbRot24(bgxor, rot)));
- dst++;
- fbNextStipBits(rot,stip);
- }
- if (rightMask)
- {
- mask = fbStipple24Bits[rot >> 3][stip];
- WRITE(dst, FbStippleRRopMask (READ(dst), mask,
- FbRot24(fgand, rot),
- FbRot24(fgxor, rot),
- FbRot24(bgand, rot),
- FbRot24(bgxor, rot),
- rightMask));
- }
- dst += dstStride;
- }
- }
-}
-#endif
-
-/*
- * Not very efficient, but simple -- copy a single plane
- * from an N bit image to a 1 bit image
- */
-
-void
-fbBltPlane (FbBits *src,
- FbStride srcStride,
- int srcX,
- int srcBpp,
-
- FbStip *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- FbStip fgand,
- FbStip fgxor,
- FbStip bgand,
- FbStip bgxor,
- Pixel planeMask)
-{
- FbBits *s;
- FbBits pm;
- FbBits srcMask;
- FbBits srcMaskFirst;
- FbBits srcMask0 = 0;
- FbBits srcBits;
-
- FbStip dstBits;
- FbStip *d;
- FbStip dstMask;
- FbStip dstMaskFirst;
- FbStip dstUnion;
- int w;
- int wt;
- int rot0;
-
- if (!width)
- return;
-
- src += srcX >> FB_SHIFT;
- srcX &= FB_MASK;
-
- dst += dstX >> FB_STIP_SHIFT;
- dstX &= FB_STIP_MASK;
-
- w = width / srcBpp;
-
- pm = fbReplicatePixel (planeMask, srcBpp);
-#ifdef FB_24BIT
- if (srcBpp == 24)
- {
- int w = 24;
-
- rot0 = FbFirst24Rot (srcX);
- if (srcX + w > FB_UNIT)
- w = FB_UNIT - srcX;
- srcMaskFirst = FbRot24(pm,rot0) & FbBitsMask(srcX,w);
- }
- else
-#endif
- {
- rot0 = 0;
- srcMaskFirst = pm & FbBitsMask(srcX, srcBpp);
- srcMask0 = pm & FbBitsMask(0, srcBpp);
- }
-
- dstMaskFirst = FbStipMask(dstX,1);
- while (height--)
- {
- d = dst;
- dst += dstStride;
- s = src;
- src += srcStride;
-
- srcMask = srcMaskFirst;
-#ifdef FB_24BIT
- if (srcBpp == 24)
- srcMask0 = FbRot24(pm,rot0) & FbBitsMask(0, srcBpp);
-#endif
- srcBits = READ(s++);
-
- dstMask = dstMaskFirst;
- dstUnion = 0;
- dstBits = 0;
-
- wt = w;
-
- while (wt--)
- {
- if (!srcMask)
- {
- srcBits = READ(s++);
-#ifdef FB_24BIT
- if (srcBpp == 24)
- srcMask0 = FbNext24Pix(srcMask0) & FbBitsMask(0,24);
-#endif
- srcMask = srcMask0;
- }
- if (!dstMask)
- {
- WRITE(d, FbStippleRRopMask(READ(d), dstBits,
- fgand, fgxor, bgand, bgxor,
- dstUnion));
- d++;
- dstMask = FbStipMask(0,1);
- dstUnion = 0;
- dstBits = 0;
- }
- if (srcBits & srcMask)
- dstBits |= dstMask;
- dstUnion |= dstMask;
- if (srcBpp == FB_UNIT)
- srcMask = 0;
- else
- srcMask = FbScrRight(srcMask,srcBpp);
- dstMask = FbStipRight(dstMask,1);
- }
- if (dstUnion)
- WRITE(d, FbStippleRRopMask(READ(d),dstBits,
- fgand, fgxor, bgand, bgxor,
- dstUnion));
- }
-}
-
+/*
+ * Copyright © 1998 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
+ * 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.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+/*
+ * Example: srcX = 13 dstX = 8 (FB unit 32 dstBpp 8)
+ *
+ * **** **** **** **** **** **** **** ****
+ * ^
+ * ******** ******** ******** ********
+ * ^
+ * leftShift = 12
+ * rightShift = 20
+ *
+ * Example: srcX = 0 dstX = 8 (FB unit 32 dstBpp 8)
+ *
+ * **** **** **** **** **** **** **** ****
+ * ^
+ * ******** ******** ******** ********
+ * ^
+ *
+ * leftShift = 24
+ * rightShift = 8
+ */
+
+#define LoadBits {\
+ if (leftShift) { \
+ bitsRight = (src < srcEnd ? READ(src++) : 0); \
+ bits = (FbStipLeft (bitsLeft, leftShift) | \
+ FbStipRight(bitsRight, rightShift)); \
+ bitsLeft = bitsRight; \
+ } else \
+ bits = (src < srcEnd ? READ(src++) : 0); \
+}
+
+
+#define LaneCases1(n,a) case n: FbLaneCase(n,a); break
+#define LaneCases2(n,a) LaneCases1(n,a); LaneCases1(n+1,a)
+#define LaneCases4(n,a) LaneCases2(n,a); LaneCases2(n+2,a)
+#define LaneCases8(n,a) LaneCases4(n,a); LaneCases4(n+4,a)
+#define LaneCases16(n,a) LaneCases8(n,a); LaneCases8(n+8,a)
+#define LaneCases32(n,a) LaneCases16(n,a); LaneCases16(n+16,a)
+#define LaneCases64(n,a) LaneCases32(n,a); LaneCases32(n+32,a)
+#define LaneCases128(n,a) LaneCases64(n,a); LaneCases64(n+64,a)
+#define LaneCases256(n,a) LaneCases128(n,a); LaneCases128(n+128,a)
+
+#if FB_SHIFT == 6
+#define LaneCases(a) LaneCases256(0,a)
+#endif
+
+#if FB_SHIFT == 5
+#define LaneCases(a) LaneCases16(0,a)
+#endif
+
+#if FB_SHIFT == 6
+CARD8 fb8Lane[256] = {
+0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21,
+22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40,
+41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
+60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78,
+79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96, 97,
+98, 99, 100, 101, 102,103,104,105,106,107,108,109,110,111,112,113,114,115,
+116, 117, 118,119,120,121,122,123,124,125,126,127,128,129,130,131,132,133,
+134, 135, 136,137,138,139,140,141,142,143,144,145,146,147,148,149,150,151,
+152, 153, 154,155,156,157,158,159,160,161,162,163,164,165,166,167,168,169,
+170, 171, 172,173,174,175,176,177,178,179,180,181,182,183,184,185,186,187,
+188, 189, 190,191,192,193,194,195,196,197,198,199,200,201,202,203,204,205,
+206, 207, 208,209,210,211,212,213,214,215,216,217,218,219,220,221,222,223,
+224, 225, 226,227,228,229,230,231,232,233,234,235,236,237,238,239,240,241,
+242, 243, 244,245,246,247,248,249,250,251,252,253,254,255,
+};
+
+CARD8 fb16Lane[256] = {
+ 0x00, 0x03, 0x0c, 0x0f,
+ 0x30, 0x33, 0x3c, 0x3f,
+ 0xc0, 0xc3, 0xcc, 0xcf,
+ 0xf0, 0xf3, 0xfc, 0xff,
+};
+
+CARD8 fb32Lane[16] = {
+ 0x00, 0x0f, 0xf0, 0xff,
+};
+#endif
+
+#if FB_SHIFT == 5
+CARD8 fb8Lane[16] = {
+ 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15
+};
+
+CARD8 fb16Lane[16] = {
+ 0, 3, 12, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+
+CARD8 fb32Lane[16] = {
+ 0, 15, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
+};
+#endif
+
+CARD8 *fbLaneTable[33] = {
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ fb8Lane, 0, 0, 0, 0, 0, 0, 0,
+ fb16Lane, 0, 0, 0, 0, 0, 0, 0,
+ 0, 0, 0, 0, 0, 0, 0, 0,
+ fb32Lane
+};
+
+void
+fbBltOne (FbStip *src,
+ FbStride srcStride, /* FbStip units per scanline */
+ int srcX, /* bit position of source */
+ FbBits *dst,
+ FbStride dstStride, /* FbBits units per scanline */
+ int dstX, /* bit position of dest */
+ int dstBpp, /* bits per destination unit */
+
+ int width, /* width in bits of destination */
+ int height, /* height in scanlines */
+
+ FbBits fgand, /* rrop values */
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor)
+{
+ const FbBits *fbBits;
+ FbBits *srcEnd;
+ int pixelsPerDst; /* dst pixels per FbBits */
+ int unitsPerSrc; /* src patterns per FbStip */
+ int leftShift, rightShift; /* align source with dest */
+ FbBits startmask, endmask; /* dest scanline masks */
+ FbStip bits=0, bitsLeft, bitsRight;/* source bits */
+ FbStip left;
+ FbBits mask;
+ int nDst; /* dest longwords (w.o. end) */
+ int w;
+ int n, nmiddle;
+ int dstS; /* stipple-relative dst X coordinate */
+ Bool copy; /* accelerate dest-invariant */
+ Bool transparent; /* accelerate 0 nop */
+ int srcinc; /* source units consumed */
+ Bool endNeedsLoad = FALSE; /* need load for endmask */
+ CARD8 *fbLane;
+ int startbyte, endbyte;
+
+ if (dstBpp == 24)
+ {
+ fbBltOne24 (src, srcStride, srcX,
+ dst, dstStride, dstX, dstBpp,
+ width, height,
+ fgand, fgxor, bgand, bgxor);
+ return;
+ }
+
+ /*
+ * Do not read past the end of the buffer!
+ */
+ srcEnd = src + height * srcStride;
+
+ /*
+ * Number of destination units in FbBits == number of stipple pixels
+ * used each time
+ */
+ pixelsPerDst = FB_UNIT / dstBpp;
+
+ /*
+ * Number of source stipple patterns in FbStip
+ */
+ unitsPerSrc = FB_STIP_UNIT / pixelsPerDst;
+
+ copy = FALSE;
+ transparent = FALSE;
+ if (bgand == 0 && fgand == 0)
+ copy = TRUE;
+ else if (bgand == FB_ALLONES && bgxor == 0)
+ transparent = TRUE;
+
+ /*
+ * Adjust source and dest to nearest FbBits boundary
+ */
+ src += srcX >> FB_STIP_SHIFT;
+ dst += dstX >> FB_SHIFT;
+ srcX &= FB_STIP_MASK;
+ dstX &= FB_MASK;
+
+ FbMaskBitsBytes(dstX, width, copy,
+ startmask, startbyte, nmiddle, endmask, endbyte);
+
+ /*
+ * Compute effective dest alignment requirement for
+ * source -- must align source to dest unit boundary
+ */
+ dstS = dstX / dstBpp;
+ /*
+ * Compute shift constants for effective alignement
+ */
+ if (srcX >= dstS)
+ {
+ leftShift = srcX - dstS;
+ rightShift = FB_STIP_UNIT - leftShift;
+ }
+ else
+ {
+ rightShift = dstS - srcX;
+ leftShift = FB_STIP_UNIT - rightShift;
+ }
+ /*
+ * Get pointer to stipple mask array for this depth
+ */
+ fbBits = 0; /* unused */
+ if (pixelsPerDst <= 8)
+ fbBits = fbStippleTable[pixelsPerDst];
+ fbLane = 0;
+ if (transparent && fgand == 0 && dstBpp >= 8)
+ fbLane = fbLaneTable[dstBpp];
+
+ /*
+ * Compute total number of destination words written, but
+ * don't count endmask
+ */
+ nDst = nmiddle;
+ if (startmask)
+ nDst++;
+
+ dstStride -= nDst;
+
+ /*
+ * Compute total number of source words consumed
+ */
+
+ srcinc = (nDst + unitsPerSrc - 1) / unitsPerSrc;
+
+ if (srcX > dstS)
+ srcinc++;
+ if (endmask)
+ {
+ endNeedsLoad = nDst % unitsPerSrc == 0;
+ if (endNeedsLoad)
+ srcinc++;
+ }
+
+ srcStride -= srcinc;
+
+ /*
+ * Copy rectangle
+ */
+ while (height--)
+ {
+ w = nDst; /* total units across scanline */
+ n = unitsPerSrc; /* units avail in single stipple */
+ if (n > w)
+ n = w;
+
+ bitsLeft = 0;
+ if (srcX > dstS)
+ bitsLeft = READ(src++);
+ if (n)
+ {
+ /*
+ * Load first set of stipple bits
+ */
+ LoadBits;
+
+ /*
+ * Consume stipple bits for startmask
+ */
+ if (startmask)
+ {
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+ if (fbLane)
+ {
+ fbTransparentSpan (dst, mask & startmask, fgxor, 1);
+ }
+ else
+ {
+ if (mask || !transparent)
+ FbDoLeftMaskByteStippleRRop (dst, mask,
+ fgand, fgxor, bgand, bgxor,
+ startbyte, startmask);
+ }
+ bits = FbStipLeft (bits, pixelsPerDst);
+ dst++;
+ n--;
+ w--;
+ }
+ /*
+ * Consume stipple bits across scanline
+ */
+ for (;;)
+ {
+ w -= n;
+ if (copy)
+ {
+ while (n--)
+ {
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+ WRITE(dst, FbOpaqueStipple (mask, fgxor, bgxor));
+ dst++;
+ bits = FbStipLeft(bits, pixelsPerDst);
+ }
+ }
+ else
+ {
+ if (fbLane)
+ {
+ while (bits && n)
+ {
+ switch (fbLane[FbLeftStipBits(bits,pixelsPerDst)]) {
+ LaneCases((CARD8 *) dst);
+ }
+ bits = FbStipLeft(bits,pixelsPerDst);
+ dst++;
+ n--;
+ }
+ dst += n;
+ }
+ else
+ {
+ while (n--)
+ {
+ left = FbLeftStipBits(bits,pixelsPerDst);
+ if (left || !transparent)
+ {
+ mask = fbBits[left];
+ WRITE(dst, FbStippleRRop (READ(dst), mask,
+ fgand, fgxor, bgand, bgxor));
+ }
+ dst++;
+ bits = FbStipLeft(bits, pixelsPerDst);
+ }
+ }
+ }
+ if (!w)
+ break;
+ /*
+ * Load another set and reset number of available units
+ */
+ LoadBits;
+ n = unitsPerSrc;
+ if (n > w)
+ n = w;
+ }
+ }
+ /*
+ * Consume stipple bits for endmask
+ */
+ if (endmask)
+ {
+ if (endNeedsLoad)
+ {
+ LoadBits;
+ }
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+ if (fbLane)
+ {
+ fbTransparentSpan (dst, mask & endmask, fgxor, 1);
+ }
+ else
+ {
+ if (mask || !transparent)
+ FbDoRightMaskByteStippleRRop (dst, mask,
+ fgand, fgxor, bgand, bgxor,
+ endbyte, endmask);
+ }
+ }
+ dst += dstStride;
+ src += srcStride;
+ }
+}
+
+
+/*
+ * Crufty macros to initialize the mask array, most of this
+ * is to avoid compile-time warnings about shift overflow
+ */
+
+#if BITMAP_BIT_ORDER == MSBFirst
+#define Mask24Pos(x,r) ((x)*24-(r))
+#else
+#define Mask24Pos(x,r) ((x)*24-((r) ? 24 - (r) : 0))
+#endif
+
+#define Mask24Neg(x,r) (Mask24Pos(x,r) < 0 ? -Mask24Pos(x,r) : 0)
+#define Mask24Check(x,r) (Mask24Pos(x,r) < 0 ? 0 : \
+ Mask24Pos(x,r) >= FB_UNIT ? 0 : Mask24Pos(x,r))
+
+#define Mask24(x,r) (Mask24Pos(x,r) < FB_UNIT ? \
+ (Mask24Pos(x,r) < 0 ? \
+ 0xffffff >> Mask24Neg (x,r) : \
+ 0xffffff << Mask24Check(x,r)) : 0)
+
+#define SelMask24(b,n,r) ((((b) >> n) & 1) * Mask24(n,r))
+
+/*
+ * Untested for MSBFirst or FB_UNIT == 32
+ */
+
+#if FB_UNIT == 64
+#define C4_24(b,r) \
+ (SelMask24(b,0,r) | \
+ SelMask24(b,1,r) | \
+ SelMask24(b,2,r) | \
+ SelMask24(b,3,r))
+
+#define FbStip24New(rot) (2 + (rot != 0))
+#define FbStip24Len 4
+
+const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
+ /* rotate 0 */
+ {
+ C4_24( 0, 0), C4_24( 1, 0), C4_24( 2, 0), C4_24( 3, 0),
+ C4_24( 4, 0), C4_24( 5, 0), C4_24( 6, 0), C4_24( 7, 0),
+ C4_24( 8, 0), C4_24( 9, 0), C4_24(10, 0), C4_24(11, 0),
+ C4_24(12, 0), C4_24(13, 0), C4_24(14, 0), C4_24(15, 0),
+ },
+ /* rotate 8 */
+ {
+ C4_24( 0, 8), C4_24( 1, 8), C4_24( 2, 8), C4_24( 3, 8),
+ C4_24( 4, 8), C4_24( 5, 8), C4_24( 6, 8), C4_24( 7, 8),
+ C4_24( 8, 8), C4_24( 9, 8), C4_24(10, 8), C4_24(11, 8),
+ C4_24(12, 8), C4_24(13, 8), C4_24(14, 8), C4_24(15, 8),
+ },
+ /* rotate 16 */
+ {
+ C4_24( 0,16), C4_24( 1,16), C4_24( 2,16), C4_24( 3,16),
+ C4_24( 4,16), C4_24( 5,16), C4_24( 6,16), C4_24( 7,16),
+ C4_24( 8,16), C4_24( 9,16), C4_24(10,16), C4_24(11,16),
+ C4_24(12,16), C4_24(13,16), C4_24(14,16), C4_24(15,16),
+ }
+};
+
+#endif
+
+#if FB_UNIT == 32
+#define C2_24(b,r) \
+ (SelMask24(b,0,r) | \
+ SelMask24(b,1,r))
+
+#define FbStip24Len 2
+#if BITMAP_BIT_ORDER == MSBFirst
+#define FbStip24New(rot) (1 + (rot == 0))
+#else
+#define FbStip24New(rot) (1 + (rot == 8))
+#endif
+
+const FbBits fbStipple24Bits[3][1 << FbStip24Len] = {
+ /* rotate 0 */
+ {
+ C2_24( 0, 0), C2_24 ( 1, 0), C2_24 ( 2, 0), C2_24 ( 3, 0),
+ },
+ /* rotate 8 */
+ {
+ C2_24( 0, 8), C2_24 ( 1, 8), C2_24 ( 2, 8), C2_24 ( 3, 8),
+ },
+ /* rotate 16 */
+ {
+ C2_24( 0,16), C2_24 ( 1,16), C2_24 ( 2,16), C2_24 ( 3,16),
+ }
+};
+#endif
+
+#if BITMAP_BIT_ORDER == LSBFirst
+
+#define FbMergeStip24Bits(left, right, new) \
+ (FbStipLeft (left, new) | FbStipRight ((right), (FbStip24Len - (new))))
+
+#define FbMergePartStip24Bits(left, right, llen, rlen) \
+ (left | FbStipRight(right, llen))
+
+#else
+
+#define FbMergeStip24Bits(left, right, new) \
+ ((FbStipLeft (left, new) & ((1 << FbStip24Len) - 1)) | right)
+
+#define FbMergePartStip24Bits(left, right, llen, rlen) \
+ (FbStipLeft(left, rlen) | right)
+
+#endif
+
+#define fbFirstStipBits(len,stip) {\
+ int __len = (len); \
+ if (len <= remain) { \
+ stip = FbLeftStipBits(bits, len); \
+ } else { \
+ stip = FbLeftStipBits(bits, remain); \
+ bits = (src < srcEnd ? READ(src++) : 0); \
+ __len = (len) - remain; \
+ stip = FbMergePartStip24Bits(stip, FbLeftStipBits(bits, __len), \
+ remain, __len); \
+ remain = FB_STIP_UNIT; \
+ } \
+ bits = FbStipLeft (bits, __len); \
+ remain -= __len; \
+}
+
+#define fbInitStipBits(offset,len,stip) {\
+ bits = FbStipLeft (READ(src++),offset); \
+ remain = FB_STIP_UNIT - offset; \
+ fbFirstStipBits(len,stip); \
+ stip = FbMergeStip24Bits (0, stip, len); \
+}
+
+#define fbNextStipBits(rot,stip) {\
+ int __new = FbStip24New(rot); \
+ FbStip __right; \
+ fbFirstStipBits(__new, __right); \
+ stip = FbMergeStip24Bits (stip, __right, __new); \
+ rot = FbNext24Rot (rot); \
+}
+
+/*
+ * Use deep mask tables that incorporate rotation, pull
+ * a variable number of bits out of the stipple and
+ * reuse the right bits as needed for the next write
+ *
+ * Yes, this is probably too much code, but most 24-bpp screens
+ * have no acceleration so this code is used for stipples, copyplane
+ * and text
+ */
+void
+fbBltOne24 (FbStip *srcLine,
+ FbStride srcStride, /* FbStip units per scanline */
+ int srcX, /* bit position of source */
+ FbBits *dst,
+ FbStride dstStride, /* FbBits units per scanline */
+ int dstX, /* bit position of dest */
+ int dstBpp, /* bits per destination unit */
+
+ int width, /* width in bits of destination */
+ int height, /* height in scanlines */
+
+ FbBits fgand, /* rrop values */
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor)
+{
+ FbStip *src, *srcEnd;
+ FbBits leftMask, rightMask, mask;
+ int nlMiddle, nl;
+ FbStip stip, bits;
+ int remain;
+ int dstS;
+ int firstlen;
+ int rot0, rot;
+ int nDst;
+
+ /*
+ * Do not read past the end of the buffer!
+ */
+ srcEnd = srcLine + height * srcStride;
+
+ srcLine += srcX >> FB_STIP_SHIFT;
+ dst += dstX >> FB_SHIFT;
+ srcX &= FB_STIP_MASK;
+ dstX &= FB_MASK;
+ rot0 = FbFirst24Rot (dstX);
+
+ FbMaskBits (dstX, width, leftMask, nlMiddle, rightMask);
+
+ dstS = (dstX + 23) / 24;
+ firstlen = FbStip24Len - dstS;
+
+ nDst = nlMiddle;
+ if (leftMask)
+ nDst++;
+ dstStride -= nDst;
+
+ /* opaque copy */
+ if (bgand == 0 && fgand == 0)
+ {
+ while (height--)
+ {
+ rot = rot0;
+ src = srcLine;
+ srcLine += srcStride;
+ fbInitStipBits (srcX,firstlen, stip);
+ if (leftMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ WRITE(dst, (READ(dst) & ~leftMask) |
+ (FbOpaqueStipple (mask,
+ FbRot24(fgxor, rot),
+ FbRot24(bgxor, rot))
+ & leftMask));
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ mask = fbStipple24Bits[rot>>3][stip];
+ WRITE(dst, FbOpaqueStipple (mask,
+ FbRot24(fgxor, rot),
+ FbRot24(bgxor, rot)));
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ if (rightMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ WRITE(dst, (READ(dst) & ~rightMask) |
+ (FbOpaqueStipple (mask,
+ FbRot24(fgxor, rot),
+ FbRot24(bgxor, rot))
+ & rightMask));
+ }
+ dst += dstStride;
+ src += srcStride;
+ }
+ }
+ /* transparent copy */
+ else if (bgand == FB_ALLONES && bgxor == 0 && fgand == 0)
+ {
+ while (height--)
+ {
+ rot = rot0;
+ src = srcLine;
+ srcLine += srcStride;
+ fbInitStipBits (srcX, firstlen, stip);
+ if (leftMask)
+ {
+ if (stip)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip] & leftMask;
+ WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
+ }
+ dst++;
+ fbNextStipBits (rot, stip);
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ if (stip)
+ {
+ mask = fbStipple24Bits[rot>>3][stip];
+ WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor,rot) & mask));
+ }
+ dst++;
+ fbNextStipBits (rot, stip);
+ }
+ if (rightMask)
+ {
+ if (stip)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip] & rightMask;
+ WRITE(dst, (READ(dst) & ~mask) | (FbRot24(fgxor, rot) & mask));
+ }
+ }
+ dst += dstStride;
+ }
+ }
+ else
+ {
+ while (height--)
+ {
+ rot = rot0;
+ src = srcLine;
+ srcLine += srcStride;
+ fbInitStipBits (srcX, firstlen, stip);
+ if (leftMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ WRITE(dst, FbStippleRRopMask (READ(dst), mask,
+ FbRot24(fgand, rot),
+ FbRot24(fgxor, rot),
+ FbRot24(bgand, rot),
+ FbRot24(bgxor, rot),
+ leftMask));
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ nl = nlMiddle;
+ while (nl--)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ WRITE(dst, FbStippleRRop (READ(dst), mask,
+ FbRot24(fgand, rot),
+ FbRot24(fgxor, rot),
+ FbRot24(bgand, rot),
+ FbRot24(bgxor, rot)));
+ dst++;
+ fbNextStipBits(rot,stip);
+ }
+ if (rightMask)
+ {
+ mask = fbStipple24Bits[rot >> 3][stip];
+ WRITE(dst, FbStippleRRopMask (READ(dst), mask,
+ FbRot24(fgand, rot),
+ FbRot24(fgxor, rot),
+ FbRot24(bgand, rot),
+ FbRot24(bgxor, rot),
+ rightMask));
+ }
+ dst += dstStride;
+ }
+ }
+}
+
+/*
+ * Not very efficient, but simple -- copy a single plane
+ * from an N bit image to a 1 bit image
+ */
+
+void
+fbBltPlane (FbBits *src,
+ FbStride srcStride,
+ int srcX,
+ int srcBpp,
+
+ FbStip *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbStip fgand,
+ FbStip fgxor,
+ FbStip bgand,
+ FbStip bgxor,
+ Pixel planeMask)
+{
+ FbBits *s;
+ FbBits pm;
+ FbBits srcMask;
+ FbBits srcMaskFirst;
+ FbBits srcMask0 = 0;
+ FbBits srcBits;
+
+ FbStip dstBits;
+ FbStip *d;
+ FbStip dstMask;
+ FbStip dstMaskFirst;
+ FbStip dstUnion;
+ int w;
+ int wt;
+ int rot0;
+
+ if (!width)
+ return;
+
+ src += srcX >> FB_SHIFT;
+ srcX &= FB_MASK;
+
+ dst += dstX >> FB_STIP_SHIFT;
+ dstX &= FB_STIP_MASK;
+
+ w = width / srcBpp;
+
+ pm = fbReplicatePixel (planeMask, srcBpp);
+ if (srcBpp == 24)
+ {
+ int w = 24;
+
+ rot0 = FbFirst24Rot (srcX);
+ if (srcX + w > FB_UNIT)
+ w = FB_UNIT - srcX;
+ srcMaskFirst = FbRot24(pm,rot0) & FbBitsMask(srcX,w);
+ }
+ else
+ {
+ rot0 = 0;
+ srcMaskFirst = pm & FbBitsMask(srcX, srcBpp);
+ srcMask0 = pm & FbBitsMask(0, srcBpp);
+ }
+
+ dstMaskFirst = FbStipMask(dstX,1);
+ while (height--)
+ {
+ d = dst;
+ dst += dstStride;
+ s = src;
+ src += srcStride;
+
+ srcMask = srcMaskFirst;
+ if (srcBpp == 24)
+ srcMask0 = FbRot24(pm,rot0) & FbBitsMask(0, srcBpp);
+ srcBits = READ(s++);
+
+ dstMask = dstMaskFirst;
+ dstUnion = 0;
+ dstBits = 0;
+
+ wt = w;
+
+ while (wt--)
+ {
+ if (!srcMask)
+ {
+ srcBits = READ(s++);
+ if (srcBpp == 24)
+ srcMask0 = FbNext24Pix(srcMask0) & FbBitsMask(0,24);
+ srcMask = srcMask0;
+ }
+ if (!dstMask)
+ {
+ WRITE(d, FbStippleRRopMask(READ(d), dstBits,
+ fgand, fgxor, bgand, bgxor,
+ dstUnion));
+ d++;
+ dstMask = FbStipMask(0,1);
+ dstUnion = 0;
+ dstBits = 0;
+ }
+ if (srcBits & srcMask)
+ dstBits |= dstMask;
+ dstUnion |= dstMask;
+ if (srcBpp == FB_UNIT)
+ srcMask = 0;
+ else
+ srcMask = FbScrRight(srcMask,srcBpp);
+ dstMask = FbStipRight(dstMask,1);
+ }
+ if (dstUnion)
+ WRITE(d, FbStippleRRopMask(READ(d),dstBits,
+ fgand, fgxor, bgand, bgxor,
+ dstUnion));
+ }
+}
+
diff --git a/xorg-server/fb/fbcopy.c b/xorg-server/fb/fbcopy.c
index 84f157ea5..6688a4369 100644
--- a/xorg-server/fb/fbcopy.c
+++ b/xorg-server/fb/fbcopy.c
@@ -302,11 +302,9 @@ fbCopyArea (DrawablePtr pSrcDrawable,
{
miCopyProc copy;
-#ifdef FB_24_32BIT
if (pSrcDrawable->bitsPerPixel != pDstDrawable->bitsPerPixel)
copy = fb24_32CopyMtoN;
else
-#endif
copy = fbCopyNtoN;
return miDoCopy (pSrcDrawable, pDstDrawable, pGC, xIn, yIn,
widthSrc, heightSrc, xOut, yOut, copy, 0, 0);
diff --git a/xorg-server/fb/fbgc.c b/xorg-server/fb/fbgc.c
index 75d240a33..70df0b253 100644
--- a/xorg-server/fb/fbgc.c
+++ b/xorg-server/fb/fbgc.c
@@ -206,7 +206,6 @@ fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
miComputeCompositeClip (pGC, pDrawable);
}
-#ifdef FB_24_32BIT
if (pPriv->bpp != pDrawable->bitsPerPixel)
{
changes |= GCStipple|GCForeground|GCBackground|GCPlaneMask;
@@ -240,7 +239,6 @@ fbValidateGC(GCPtr pGC, unsigned long changes, DrawablePtr pDrawable)
}
}
}
-#endif
if (changes & GCTile)
{
if (!pGC->tileIsPixel &&
diff --git a/xorg-server/fb/fbgetsp.c b/xorg-server/fb/fbgetsp.c
index 6402c6c38..5c8396ac2 100644
--- a/xorg-server/fb/fbgetsp.c
+++ b/xorg-server/fb/fbgetsp.c
@@ -1,87 +1,85 @@
-/*
- * Copyright © 1998 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
- * 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.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-void
-fbGetSpans(DrawablePtr pDrawable,
- int wMax,
- DDXPointPtr ppt,
- int *pwidth,
- int nspans,
- char *pchardstStart)
-{
- FbBits *src, *dst;
- FbStride srcStride;
- int srcBpp;
- int srcXoff, srcYoff;
- int xoff;
-
- /*
- * XFree86 DDX empties the root borderClip when the VT is
- * switched away; this checks for that case
- */
- if (!fbDrawableEnabled(pDrawable))
- return;
-
-#ifdef FB_24_32BIT
- if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
- {
- fb24_32GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
- return;
- }
-#endif
-
- fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
-
- while (nspans--)
- {
- xoff = (int) (((long) pchardstStart) & (FB_MASK >> 3));
- dst = (FbBits *) (pchardstStart - xoff);
- xoff <<= 3;
- fbBlt (src + (ppt->y + srcYoff) * srcStride, srcStride,
- (ppt->x + srcXoff) * srcBpp,
-
- dst,
- 1,
- xoff,
-
- *pwidth * srcBpp,
- 1,
-
- GXcopy,
- FB_ALLONES,
- srcBpp,
-
- FALSE,
- FALSE);
- pchardstStart += PixmapBytePad(*pwidth, pDrawable->depth);
- ppt++;
- pwidth++;
- }
-
- fbFinishAccess (pDrawable);
-}
+/*
+ * Copyright © 1998 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
+ * 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.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbGetSpans(DrawablePtr pDrawable,
+ int wMax,
+ DDXPointPtr ppt,
+ int *pwidth,
+ int nspans,
+ char *pchardstStart)
+{
+ FbBits *src, *dst;
+ FbStride srcStride;
+ int srcBpp;
+ int srcXoff, srcYoff;
+ int xoff;
+
+ /*
+ * XFree86 DDX empties the root borderClip when the VT is
+ * switched away; this checks for that case
+ */
+ if (!fbDrawableEnabled(pDrawable))
+ return;
+
+ if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
+ {
+ fb24_32GetSpans (pDrawable, wMax, ppt, pwidth, nspans, pchardstStart);
+ return;
+ }
+
+ fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
+
+ while (nspans--)
+ {
+ xoff = (int) (((long) pchardstStart) & (FB_MASK >> 3));
+ dst = (FbBits *) (pchardstStart - xoff);
+ xoff <<= 3;
+ fbBlt (src + (ppt->y + srcYoff) * srcStride, srcStride,
+ (ppt->x + srcXoff) * srcBpp,
+
+ dst,
+ 1,
+ xoff,
+
+ *pwidth * srcBpp,
+ 1,
+
+ GXcopy,
+ FB_ALLONES,
+ srcBpp,
+
+ FALSE,
+ FALSE);
+ pchardstStart += PixmapBytePad(*pwidth, pDrawable->depth);
+ ppt++;
+ pwidth++;
+ }
+
+ fbFinishAccess (pDrawable);
+}
diff --git a/xorg-server/fb/fbglyph.c b/xorg-server/fb/fbglyph.c
index 51a5ea0a4..879ef4223 100644
--- a/xorg-server/fb/fbglyph.c
+++ b/xorg-server/fb/fbglyph.c
@@ -57,8 +57,6 @@ fbGlyphIn (RegionPtr pRegion,
return RegionContainsRect(pRegion, &box) == rgnIN;
}
-#ifdef FB_24BIT
-#ifndef FBNOPIXADDR
#define WRITE1(d,n,fg) WRITE((d) + (n), (CARD8) fg)
#define WRITE2(d,n,fg) WRITE((CARD16 *) &(d[n]), (CARD16) fg)
@@ -248,8 +246,6 @@ fbGlyph24 (FbBits *dstBits,
dstLine += dstStride;
}
}
-#endif
-#endif
void
fbPolyGlyphBlt (DrawablePtr pDrawable,
@@ -266,7 +262,6 @@ fbPolyGlyphBlt (DrawablePtr pDrawable,
int gx, gy;
int gWidth, gHeight; /* width and height of glyph */
FbStride gStride; /* stride of glyph */
-#ifndef FBNOPIXADDR
void (*glyph) (FbBits *,
FbStride,
int,
@@ -286,13 +281,10 @@ fbPolyGlyphBlt (DrawablePtr pDrawable,
switch (dstBpp) {
case 8: glyph = fbGlyph8; break;
case 16: glyph = fbGlyph16; break;
-#ifdef FB_24BIT
case 24: glyph = fbGlyph24; break;
-#endif
case 32: glyph = fbGlyph32; break;
}
}
-#endif
x += pDrawable->x;
y += pDrawable->y;
@@ -306,7 +298,6 @@ fbPolyGlyphBlt (DrawablePtr pDrawable,
{
gx = x + pci->metrics.leftSideBearing;
gy = y - pci->metrics.ascent;
-#ifndef FBNOPIXADDR
if (glyph && gWidth <= sizeof (FbStip) * 8 &&
fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
{
@@ -321,7 +312,6 @@ fbPolyGlyphBlt (DrawablePtr pDrawable,
fbFinishAccess (pDrawable);
}
else
-#endif
{
gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
fbPushImage (pDrawable,
@@ -359,7 +349,6 @@ fbImageGlyphBlt (DrawablePtr pDrawable,
Bool opaque;
int n;
int gx, gy;
-#ifndef FBNOPIXADDR
void (*glyph) (FbBits *,
FbStride,
int,
@@ -379,21 +368,16 @@ fbImageGlyphBlt (DrawablePtr pDrawable,
switch (dstBpp) {
case 8: glyph = fbGlyph8; break;
case 16: glyph = fbGlyph16; break;
-#ifdef FB_24BIT
case 24: glyph = fbGlyph24; break;
-#endif
case 32: glyph = fbGlyph32; break;
}
}
-#endif
x += pDrawable->x;
y += pDrawable->y;
if (TERMINALFONT (pGC->font)
-#ifndef FBNOPIXADDR
&& !glyph
-#endif
)
{
opaque = TRUE;
@@ -439,7 +423,6 @@ fbImageGlyphBlt (DrawablePtr pDrawable,
{
gx = x + pci->metrics.leftSideBearing;
gy = y - pci->metrics.ascent;
-#ifndef FBNOPIXADDR
if (glyph && gWidth <= sizeof (FbStip) * 8 &&
fbGlyphIn (fbGetCompositeClip(pGC), gx, gy, gWidth, gHeight))
{
@@ -454,7 +437,6 @@ fbImageGlyphBlt (DrawablePtr pDrawable,
fbFinishAccess (pDrawable);
}
else
-#endif
{
gStride = GLYPHWIDTHBYTESPADDED(pci) / sizeof (FbStip);
fbPutXYImage (pDrawable,
diff --git a/xorg-server/fb/fbimage.c b/xorg-server/fb/fbimage.c
index 0fcb05f7c..5cbc56d2b 100644
--- a/xorg-server/fb/fbimage.c
+++ b/xorg-server/fb/fbimage.c
@@ -86,7 +86,6 @@ fbPutImage (DrawablePtr pDrawable,
}
break;
case ZPixmap:
-#ifdef FB_24_32BIT
if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
{
srcStride = PixmapBytePad(w, pDrawable->depth);
@@ -99,7 +98,6 @@ fbPutImage (DrawablePtr pDrawable,
srcStride);
}
else
-#endif
{
srcStride = PixmapBytePad(w, pDrawable->depth) / sizeof (FbStip);
fbPutZImage (pDrawable,
@@ -305,14 +303,12 @@ fbGetImage (DrawablePtr pDrawable,
if (!fbDrawableEnabled(pDrawable))
return;
-#ifdef FB_24_32BIT
if (format == ZPixmap &&
pDrawable->bitsPerPixel != BitsPerPixel (pDrawable->depth))
{
fb24_32GetImage (pDrawable, x, y, w, h, format, planeMask, d);
return;
}
-#endif
fbGetDrawable (pDrawable, src, srcStride, srcBpp, srcXoff, srcYoff);
diff --git a/xorg-server/fb/fbline.c b/xorg-server/fb/fbline.c
index 66e6d3690..33a25f7f5 100644
--- a/xorg-server/fb/fbline.c
+++ b/xorg-server/fb/fbline.c
@@ -114,7 +114,6 @@ fbPolyLine (DrawablePtr pDrawable,
if (pGC->lineWidth == 0)
{
line = fbZeroLine;
-#ifndef FBNOPIXADDR
if (pGC->fillStyle == FillSolid &&
pGC->lineStyle == LineSolid &&
RegionNumRects (fbGetCompositeClip(pGC)) == 1)
@@ -122,13 +121,10 @@ fbPolyLine (DrawablePtr pDrawable,
switch (pDrawable->bitsPerPixel) {
case 8: line = fbPolyline8; break;
case 16: line = fbPolyline16; break;
-#ifdef FB_24BIT
case 24: line = fbPolyline24; break;
-#endif
case 32: line = fbPolyline32; break;
}
}
-#endif
}
else
{
@@ -151,7 +147,6 @@ fbPolySegment (DrawablePtr pDrawable,
if (pGC->lineWidth == 0)
{
seg = fbZeroSegment;
-#ifndef FBNOPIXADDR
if (pGC->fillStyle == FillSolid &&
pGC->lineStyle == LineSolid &&
RegionNumRects (fbGetCompositeClip(pGC)) == 1)
@@ -159,13 +154,10 @@ fbPolySegment (DrawablePtr pDrawable,
switch (pDrawable->bitsPerPixel) {
case 8: seg = fbPolySegment8; break;
case 16: seg = fbPolySegment16; break;
-#ifdef FB_24BIT
case 24: seg = fbPolySegment24; break;
-#endif
case 32: seg = fbPolySegment32; break;
}
}
-#endif
}
else
{
diff --git a/xorg-server/fb/fboverlay.c b/xorg-server/fb/fboverlay.c
index d6986e2a8..00092bb05 100644
--- a/xorg-server/fb/fboverlay.c
+++ b/xorg-server/fb/fboverlay.c
@@ -55,10 +55,8 @@ fbOverlayCreateWindow(WindowPtr pWin)
if (pWin->drawable.class != InputOutput)
return TRUE;
-#ifdef FB_SCREEN_PRIVATE
if (pWin->drawable.bitsPerPixel == 32)
pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
-#endif
for (i = 0; i < pScrPriv->nlayers; i++)
{
@@ -349,7 +347,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
if (!pScrPriv)
return FALSE;
-#ifdef FB_24_32BIT
if (bpp1 == 32 || bpp2 == 32)
bpp = 32;
else if (bpp1 == 24 || bpp2 == 24)
@@ -374,8 +371,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
}
}
}
-#endif
-#ifdef FB_SCREEN_PRIVATE
if (imagebpp == 32)
{
fbGetScreenPrivate(pScreen)->win32bpp = bpp;
@@ -386,7 +381,6 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
fbGetScreenPrivate(pScreen)->win32bpp = 32;
fbGetScreenPrivate(pScreen)->pix32bpp = 32;
}
-#endif
if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &depth1,
&defaultVisual, ((unsigned long)1<<(bpp1-1)) |
@@ -421,13 +415,11 @@ fbOverlayFinishScreenInit(ScreenPtr pScreen,
pScreen->CreateWindow = fbOverlayCreateWindow;
pScreen->WindowExposures = fbOverlayWindowExposures;
pScreen->CopyWindow = fbOverlayCopyWindow;
-#ifdef FB_24_32BIT
if (bpp == 24 && imagebpp == 32)
{
pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
pScreen->CreateScreenResources = fb24_32OverlayCreateScreenResources;
}
-#endif
return TRUE;
}
diff --git a/xorg-server/fb/fbpixmap.c b/xorg-server/fb/fbpixmap.c
index 80d3252d2..6df46e1c6 100644
--- a/xorg-server/fb/fbpixmap.c
+++ b/xorg-server/fb/fbpixmap.c
@@ -89,10 +89,8 @@ fbCreatePixmap (ScreenPtr pScreen, int width, int height, int depth,
{
int bpp;
bpp = BitsPerPixel (depth);
-#ifdef FB_SCREEN_PRIVATE
if (bpp == 32 && depth <= 24)
bpp = fbGetScreenPrivate(pScreen)->pix32bpp;
-#endif
return fbCreatePixmapBpp (pScreen, width, height, depth, bpp, usage_hint);
}
diff --git a/xorg-server/fb/fbpoint.c b/xorg-server/fb/fbpoint.c
index d675dbaff..f7db7e231 100644
--- a/xorg-server/fb/fbpoint.c
+++ b/xorg-server/fb/fbpoint.c
@@ -75,7 +75,6 @@ fbDots (FbBits *dstOrig,
x = (x + xoff) * dstBpp;
d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT);
x &= FB_STIP_MASK;
-#ifdef FB_24BIT
if (dstBpp == 24)
{
FbStip leftMask, rightMask;
@@ -97,7 +96,6 @@ fbDots (FbBits *dstOrig,
WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask));
}
else
-#endif
{
FbStip mask;
mask = FbStipMask(x, dstBpp);
@@ -144,16 +142,12 @@ fbPolyPoint (DrawablePtr pDrawable,
and = pPriv->and;
xor = pPriv->xor;
dots = fbDots;
-#ifndef FBNOPIXADDR
switch (dstBpp) {
case 8: dots = fbDots8; break;
case 16: dots = fbDots16; break;
-#ifdef FB_24BIT
case 24: dots = fbDots24; break;
-#endif
case 32: dots = fbDots32; break;
}
-#endif
for (nBox = RegionNumRects (pClip), pBox = RegionRects (pClip);
nBox--; pBox++)
(*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit,
diff --git a/xorg-server/fb/fbscreen.c b/xorg-server/fb/fbscreen.c
index f6eda6d64..7a10286cf 100644
--- a/xorg-server/fb/fbscreen.c
+++ b/xorg-server/fb/fbscreen.c
@@ -185,7 +185,6 @@ fbFinishScreenInit(ScreenPtr pScreen,
* pixels. If you want real 24bit images, include a 24bpp
* format in the pixmap formats
*/
-#ifdef FB_24_32BIT
if (bpp == 24)
{
int f;
@@ -205,8 +204,6 @@ fbFinishScreenInit(ScreenPtr pScreen,
}
}
}
-#endif
-#ifdef FB_SCREEN_PRIVATE
if (imagebpp == 32)
{
fbGetScreenPrivate(pScreen)->win32bpp = bpp;
@@ -221,7 +218,6 @@ fbFinishScreenInit(ScreenPtr pScreen,
fbGetScreenPrivate(pScreen)->setupWrap = setupWrap;
fbGetScreenPrivate(pScreen)->finishWrap = finishWrap;
#endif
-#endif
rootdepth = 0;
if (!fbInitVisuals (&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
&defaultVisual,((unsigned long)1<<(imagebpp-1)), 8))
@@ -236,13 +232,11 @@ fbFinishScreenInit(ScreenPtr pScreen,
return FALSE;
/* overwrite miCloseScreen with our own */
pScreen->CloseScreen = fbCloseScreen;
-#ifdef FB_24_32BIT
if (bpp == 24 && imagebpp == 32)
{
pScreen->ModifyPixmapHeader = fb24_32ModifyPixmapHeader;
pScreen->CreateScreenResources = fb24_32CreateScreenResources;
}
-#endif
return TRUE;
}
diff --git a/xorg-server/fb/fbseg.c b/xorg-server/fb/fbseg.c
index 8a68857f7..4885bd87f 100644
--- a/xorg-server/fb/fbseg.c
+++ b/xorg-server/fb/fbseg.c
@@ -330,7 +330,6 @@ fbBresFillDash (DrawablePtr pDrawable,
fbSetFg (pDrawable, pGC, fg);
}
-#ifdef FB_24BIT
static void
fbBresSolid24RRop (DrawablePtr pDrawable,
GCPtr pGC,
@@ -507,7 +506,6 @@ fbBresDash24RRop (DrawablePtr pDrawable,
fbFinishAccess (pDrawable);
}
-#endif
/*
* For drivers that want to bail drawing some lines, this
@@ -529,23 +527,17 @@ fbSelectBres (DrawablePtr pDrawable,
if (pGC->fillStyle == FillSolid)
{
bres = fbBresSolid;
-#ifdef FB_24BIT
if (dstBpp == 24)
bres = fbBresSolid24RRop;
-#endif
-#ifndef FBNOPIXADDR
if (pPriv->and == 0)
{
switch (dstBpp) {
case 8: bres = fbBresSolid8; break;
case 16: bres = fbBresSolid16; break;
-#ifdef FB_24BIT
case 24: bres = fbBresSolid24; break;
-#endif
case 32: bres = fbBresSolid32; break;
}
}
-#endif
}
}
else
@@ -554,24 +546,18 @@ fbSelectBres (DrawablePtr pDrawable,
if (pGC->fillStyle == FillSolid)
{
bres = fbBresDash;
-#ifdef FB_24BIT
if (dstBpp == 24)
bres = fbBresDash24RRop;
-#endif
-#ifndef FBNOPIXADDR
if (pPriv->and == 0 &&
(pGC->lineStyle == LineOnOffDash || pPriv->bgand == 0))
{
switch (dstBpp) {
case 8: bres = fbBresDash8; break;
case 16: bres = fbBresDash16; break;
-#ifdef FB_24BIT
case 24: bres = fbBresDash24; break;
-#endif
case 32: bres = fbBresDash32; break;
}
}
-#endif
}
}
return bres;
diff --git a/xorg-server/fb/fbsetsp.c b/xorg-server/fb/fbsetsp.c
index ce016453f..8076d5db6 100644
--- a/xorg-server/fb/fbsetsp.c
+++ b/xorg-server/fb/fbsetsp.c
@@ -46,13 +46,11 @@ fbSetSpans (DrawablePtr pDrawable,
int xoff;
int x1, x2;
-#ifdef FB_24_32BIT
if (pDrawable->bitsPerPixel != BitsPerPixel(pDrawable->depth))
{
fb24_32SetSpans (pDrawable, pGC, src, ppt, pwidth, nspans, fSorted);
return;
}
-#endif
fbGetDrawable (pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff);
while (nspans--)
{
diff --git a/xorg-server/fb/fbsolid.c b/xorg-server/fb/fbsolid.c
index 53fcae071..544a1c683 100644
--- a/xorg-server/fb/fbsolid.c
+++ b/xorg-server/fb/fbsolid.c
@@ -1,213 +1,209 @@
-/*
- * Copyright © 1998 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
- * 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.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#define FbSelectPart(xor,o,t) xor
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-void
-fbSolid (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int bpp,
-
- int width,
- int height,
-
- FbBits and,
- FbBits xor)
-{
- FbBits startmask, endmask;
- int n, nmiddle;
- int startbyte, endbyte;
-
-#ifdef FB_24BIT
- if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
- {
- fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
- return;
- }
-#endif
- dst += dstX >> FB_SHIFT;
- dstX &= FB_MASK;
- FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte,
- nmiddle, endmask, endbyte);
- if (startmask)
- dstStride--;
- dstStride -= nmiddle;
- while (height--)
- {
- if (startmask)
- {
- FbDoLeftMaskByteRRop(dst,startbyte,startmask,and,xor);
- dst++;
- }
- n = nmiddle;
- if (!and)
- while (n--)
- WRITE(dst++, xor);
- else
- while (n--)
- {
- WRITE(dst, FbDoRRop (READ(dst), and, xor));
- dst++;
- }
- if (endmask)
- FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor);
- dst += dstStride;
- }
-}
-
-#ifdef FB_24BIT
-void
-fbSolid24 (FbBits *dst,
- FbStride dstStride,
- int dstX,
-
- int width,
- int height,
-
- FbBits and,
- FbBits xor)
-{
- FbBits startmask, endmask;
- FbBits xor0 = 0, xor1 = 0, xor2 = 0;
- FbBits and0 = 0, and1 = 0, and2 = 0;
- FbBits xorS = 0, andS = 0, xorE = 0, andE = 0;
- int n, nmiddle;
- int rotS, rot;
-
- dst += dstX >> FB_SHIFT;
- dstX &= FB_MASK;
- /*
- * Rotate pixel values this far across the word to align on
- * screen pixel boundaries
- */
- rot = FbFirst24Rot (dstX);
- FbMaskBits (dstX, width, startmask, nmiddle, endmask);
- if (startmask)
- dstStride--;
- dstStride -= nmiddle;
-
- /*
- * Precompute rotated versions of the rasterop values
- */
- rotS = rot;
- xor = FbRot24(xor,rotS);
- and = FbRot24(and,rotS);
- if (startmask)
- {
- xorS = xor;
- andS = and;
- xor = FbNext24Pix(xor);
- and = FbNext24Pix(and);
- }
-
- if (nmiddle)
- {
- xor0 = xor;
- and0 = and;
- xor1 = FbNext24Pix(xor0);
- and1 = FbNext24Pix(and0);
- xor2 = FbNext24Pix(xor1);
- and2 = FbNext24Pix(and1);
- }
-
- if (endmask)
- {
- switch (nmiddle % 3) {
- case 0:
- xorE = xor;
- andE = and;
- break;
- case 1:
- xorE = xor1;
- andE = and1;
- break;
- case 2:
- xorE = xor2;
- andE = and2;
- break;
- }
- }
-
- while (height--)
- {
- if (startmask)
- {
- WRITE(dst, FbDoMaskRRop(READ(dst), andS, xorS, startmask));
- dst++;
- }
- n = nmiddle;
- if (!and0)
- {
- while (n >= 3)
- {
- WRITE(dst++, xor0);
- WRITE(dst++, xor1);
- WRITE(dst++, xor2);
- n -= 3;
- }
- if (n)
- {
- WRITE(dst++, xor0);
- n--;
- if (n)
- {
- WRITE(dst++, xor1);
- }
- }
- }
- else
- {
- while (n >= 3)
- {
- WRITE(dst, FbDoRRop (READ(dst), and0, xor0));
- dst++;
- WRITE(dst, FbDoRRop (READ(dst), and1, xor1));
- dst++;
- WRITE(dst, FbDoRRop (READ(dst), and2, xor2));
- dst++;
- n -= 3;
- }
- if (n)
- {
- WRITE(dst, FbDoRRop (READ(dst), and0, xor0));
- dst++;
- n--;
- if (n)
- {
- WRITE(dst, FbDoRRop (READ(dst), and1, xor1));
- dst++;
- }
- }
- }
- if (endmask)
- WRITE(dst, FbDoMaskRRop (READ(dst), andE, xorE, endmask));
- dst += dstStride;
- }
-}
-#endif
+/*
+ * Copyright © 1998 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
+ * 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.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#define FbSelectPart(xor,o,t) xor
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+void
+fbSolid (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int bpp,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor)
+{
+ FbBits startmask, endmask;
+ int n, nmiddle;
+ int startbyte, endbyte;
+
+ if (bpp == 24 && (!FbCheck24Pix(and) || !FbCheck24Pix(xor)))
+ {
+ fbSolid24 (dst, dstStride, dstX, width, height, and, xor);
+ return;
+ }
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBitsBytes(dstX, width, and == 0, startmask, startbyte,
+ nmiddle, endmask, endbyte);
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+ while (height--)
+ {
+ if (startmask)
+ {
+ FbDoLeftMaskByteRRop(dst,startbyte,startmask,and,xor);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and)
+ while (n--)
+ WRITE(dst++, xor);
+ else
+ while (n--)
+ {
+ WRITE(dst, FbDoRRop (READ(dst), and, xor));
+ dst++;
+ }
+ if (endmask)
+ FbDoRightMaskByteRRop(dst,endbyte,endmask,and,xor);
+ dst += dstStride;
+ }
+}
+
+void
+fbSolid24 (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+
+ int width,
+ int height,
+
+ FbBits and,
+ FbBits xor)
+{
+ FbBits startmask, endmask;
+ FbBits xor0 = 0, xor1 = 0, xor2 = 0;
+ FbBits and0 = 0, and1 = 0, and2 = 0;
+ FbBits xorS = 0, andS = 0, xorE = 0, andE = 0;
+ int n, nmiddle;
+ int rotS, rot;
+
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ /*
+ * Rotate pixel values this far across the word to align on
+ * screen pixel boundaries
+ */
+ rot = FbFirst24Rot (dstX);
+ FbMaskBits (dstX, width, startmask, nmiddle, endmask);
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+
+ /*
+ * Precompute rotated versions of the rasterop values
+ */
+ rotS = rot;
+ xor = FbRot24(xor,rotS);
+ and = FbRot24(and,rotS);
+ if (startmask)
+ {
+ xorS = xor;
+ andS = and;
+ xor = FbNext24Pix(xor);
+ and = FbNext24Pix(and);
+ }
+
+ if (nmiddle)
+ {
+ xor0 = xor;
+ and0 = and;
+ xor1 = FbNext24Pix(xor0);
+ and1 = FbNext24Pix(and0);
+ xor2 = FbNext24Pix(xor1);
+ and2 = FbNext24Pix(and1);
+ }
+
+ if (endmask)
+ {
+ switch (nmiddle % 3) {
+ case 0:
+ xorE = xor;
+ andE = and;
+ break;
+ case 1:
+ xorE = xor1;
+ andE = and1;
+ break;
+ case 2:
+ xorE = xor2;
+ andE = and2;
+ break;
+ }
+ }
+
+ while (height--)
+ {
+ if (startmask)
+ {
+ WRITE(dst, FbDoMaskRRop(READ(dst), andS, xorS, startmask));
+ dst++;
+ }
+ n = nmiddle;
+ if (!and0)
+ {
+ while (n >= 3)
+ {
+ WRITE(dst++, xor0);
+ WRITE(dst++, xor1);
+ WRITE(dst++, xor2);
+ n -= 3;
+ }
+ if (n)
+ {
+ WRITE(dst++, xor0);
+ n--;
+ if (n)
+ {
+ WRITE(dst++, xor1);
+ }
+ }
+ }
+ else
+ {
+ while (n >= 3)
+ {
+ WRITE(dst, FbDoRRop (READ(dst), and0, xor0));
+ dst++;
+ WRITE(dst, FbDoRRop (READ(dst), and1, xor1));
+ dst++;
+ WRITE(dst, FbDoRRop (READ(dst), and2, xor2));
+ dst++;
+ n -= 3;
+ }
+ if (n)
+ {
+ WRITE(dst, FbDoRRop (READ(dst), and0, xor0));
+ dst++;
+ n--;
+ if (n)
+ {
+ WRITE(dst, FbDoRRop (READ(dst), and1, xor1));
+ dst++;
+ }
+ }
+ }
+ if (endmask)
+ WRITE(dst, FbDoMaskRRop (READ(dst), andE, xorE, endmask));
+ dst += dstStride;
+ }
+}
diff --git a/xorg-server/fb/fbstipple.c b/xorg-server/fb/fbstipple.c
index bc25e462f..1316d5113 100644
--- a/xorg-server/fb/fbstipple.c
+++ b/xorg-server/fb/fbstipple.c
@@ -1,312 +1,308 @@
-/*
- * Copyright © 1998 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
- * 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.
- *
- * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
- * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
- * EVENT SHALL KEITH PACKARD 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.
- */
-
-#ifdef HAVE_DIX_CONFIG_H
-#include <dix-config.h>
-#endif
-
-#include "fb.h"
-
-#ifndef FBNOPIXADDR
-/*
- * This is a slight abuse of the preprocessor to generate repetitive
- * code, the idea is to generate code for each case of a copy-mode
- * transparent stipple
- */
-#define LaneCases1(c,a) case c: \
- while (n--) { FbLaneCase(c,a); a++; } \
- break
-#define LaneCases2(c,a) LaneCases1(c,a); LaneCases1(c+1,a)
-#define LaneCases4(c,a) LaneCases2(c,a); LaneCases2(c+2,a)
-#define LaneCases8(c,a) LaneCases4(c,a); LaneCases4(c+4,a)
-#define LaneCases16(c,a) LaneCases8(c,a); LaneCases8(c+8,a)
-#define LaneCases32(c,a) LaneCases16(c,a); LaneCases16(c+16,a)
-#define LaneCases64(c,a) LaneCases32(c,a); LaneCases32(c+32,a)
-#define LaneCases128(c,a) LaneCases64(c,a); LaneCases64(c+64,a)
-#define LaneCases256(c,a) LaneCases128(c,a); LaneCases128(c+128,a)
-
-#if FB_SHIFT == 6
-#define LaneCases(a) LaneCases256(0,a)
-#endif
-
-#if FB_SHIFT == 5
-#define LaneCases(a) LaneCases16(0,a)
-#endif
-
-/*
- * Repeat a transparent stipple across a scanline n times
- */
-
-void
-fbTransparentSpan (FbBits *dst,
- FbBits stip,
- FbBits fgxor,
- int n)
-{
- FbStip s;
-
- s = ((FbStip) (stip ) & 0x01);
- s |= ((FbStip) (stip >> 8) & 0x02);
- s |= ((FbStip) (stip >> 16) & 0x04);
- s |= ((FbStip) (stip >> 24) & 0x08);
-#if FB_SHIFT > 5
- s |= ((FbStip) (stip >> 32) & 0x10);
- s |= ((FbStip) (stip >> 40) & 0x20);
- s |= ((FbStip) (stip >> 48) & 0x40);
- s |= ((FbStip) (stip >> 56) & 0x80);
-#endif
- switch (s) {
- LaneCases(dst);
- }
-}
-#endif
-
-void
-fbEvenStipple (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int dstBpp,
-
- int width,
- int height,
-
- FbStip *stip,
- FbStride stipStride,
- int stipHeight,
-
- FbBits fgand,
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor,
-
- int xRot,
- int yRot)
-{
- FbBits startmask, endmask;
- FbBits mask, and, xor;
- int nmiddle, n;
- FbStip *s, *stipEnd, bits;
- int rot, stipX, stipY;
- int pixelsPerDst;
- const FbBits *fbBits;
- Bool transparent;
- int startbyte, endbyte;
-
- /*
- * Check for a transparent stipple (stencil)
- */
- transparent = FALSE;
- if (dstBpp >= 8 &&
- fgand == 0 && bgand == FB_ALLONES && bgxor == 0)
- transparent = TRUE;
-
- pixelsPerDst = FB_UNIT / dstBpp;
- /*
- * Adjust dest pointers
- */
- dst += dstX >> FB_SHIFT;
- dstX &= FB_MASK;
- FbMaskBitsBytes (dstX, width, fgand == 0 && bgand == 0,
- startmask, startbyte, nmiddle, endmask, endbyte);
-
- if (startmask)
- dstStride--;
- dstStride -= nmiddle;
-
- xRot *= dstBpp;
- /*
- * Compute stip start scanline and rotation parameters
- */
- stipEnd = stip + stipStride * stipHeight;
- modulus (- yRot, stipHeight, stipY);
- s = stip + stipStride * stipY;
- modulus (- xRot, FB_UNIT, stipX);
- rot = stipX;
-
- /*
- * Get pointer to stipple mask array for this depth
- */
- /* fbStippleTable covers all valid bpp (4,8,16,32) */
- fbBits = fbStippleTable[pixelsPerDst];
-
- while (height--)
- {
- /*
- * Extract stipple bits for this scanline;
- */
- bits = READ(s);
- s += stipStride;
- if (s == stipEnd)
- s = stip;
-#if FB_UNIT > 32
- if (pixelsPerDst == 16)
- mask = FbStipple16Bits(FbLeftStipBits(bits,16));
- else
-#endif
- mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
- /*
- * Rotate into position and compute reduced rop values
- */
- mask = FbRotLeft(mask, rot);
- and = (fgand & mask) | (bgand & ~mask);
- xor = (fgxor & mask) | (bgxor & ~mask);
-
-#ifndef FBNOPIXADDR
- if (transparent)
- {
- if (startmask)
- {
- fbTransparentSpan(dst, mask&startmask, fgxor, 1);
- dst++;
- }
- fbTransparentSpan (dst, mask, fgxor, nmiddle);
- dst += nmiddle;
- if (endmask)
- fbTransparentSpan(dst, mask&endmask, fgxor, 1);
- }
- else
-#endif
- {
- /*
- * Fill scanline
- */
- if (startmask)
- {
- FbDoLeftMaskByteRRop (dst, startbyte, startmask, and, xor);
- dst++;
- }
- n = nmiddle;
- if (!and)
- while (n--)
- WRITE(dst++, xor);
- else
- {
- while (n--)
- {
- WRITE(dst, FbDoRRop (READ(dst), and, xor));
- dst++;
- }
- }
- if (endmask)
- FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
- }
- dst += dstStride;
- }
-}
-
-void
-fbOddStipple (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int dstBpp,
-
- int width,
- int height,
-
- FbStip *stip,
- FbStride stipStride,
- int stipWidth,
- int stipHeight,
-
- FbBits fgand,
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor,
-
- int xRot,
- int yRot)
-{
- int stipX, stipY, sx;
- int widthTmp;
- int h, w;
- int x, y;
-
- modulus (- yRot, stipHeight, stipY);
- modulus (dstX / dstBpp - xRot, stipWidth, stipX);
- y = 0;
- while (height)
- {
- h = stipHeight - stipY;
- if (h > height)
- h = height;
- height -= h;
- widthTmp = width;
- x = dstX;
- sx = stipX;
- while (widthTmp)
- {
- w = (stipWidth - sx) * dstBpp;
- if (w > widthTmp)
- w = widthTmp;
- widthTmp -= w;
- fbBltOne (stip + stipY * stipStride,
- stipStride,
- sx,
-
- dst + y * dstStride,
- dstStride,
- x,
- dstBpp,
-
- w, h,
-
- fgand, fgxor, bgand, bgxor);
- x += w;
- sx = 0;
- }
- y += h;
- stipY = 0;
- }
-}
-
-void
-fbStipple (FbBits *dst,
- FbStride dstStride,
- int dstX,
- int dstBpp,
-
- int width,
- int height,
-
- FbStip *stip,
- FbStride stipStride,
- int stipWidth,
- int stipHeight,
- Bool even,
-
- FbBits fgand,
- FbBits fgxor,
- FbBits bgand,
- FbBits bgxor,
-
- int xRot,
- int yRot)
-{
- if (even)
- fbEvenStipple (dst, dstStride, dstX, dstBpp, width, height,
- stip, stipStride, stipHeight,
- fgand, fgxor, bgand, bgxor, xRot, yRot);
- else
- fbOddStipple (dst, dstStride, dstX, dstBpp, width, height,
- stip, stipStride, stipWidth, stipHeight,
- fgand, fgxor, bgand, bgxor, xRot, yRot);
-}
+/*
+ * Copyright © 1998 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
+ * 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.
+ *
+ * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
+ * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
+ * EVENT SHALL KEITH PACKARD 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.
+ */
+
+#ifdef HAVE_DIX_CONFIG_H
+#include <dix-config.h>
+#endif
+
+#include "fb.h"
+
+/*
+ * This is a slight abuse of the preprocessor to generate repetitive
+ * code, the idea is to generate code for each case of a copy-mode
+ * transparent stipple
+ */
+#define LaneCases1(c,a) case c: \
+ while (n--) { FbLaneCase(c,a); a++; } \
+ break
+#define LaneCases2(c,a) LaneCases1(c,a); LaneCases1(c+1,a)
+#define LaneCases4(c,a) LaneCases2(c,a); LaneCases2(c+2,a)
+#define LaneCases8(c,a) LaneCases4(c,a); LaneCases4(c+4,a)
+#define LaneCases16(c,a) LaneCases8(c,a); LaneCases8(c+8,a)
+#define LaneCases32(c,a) LaneCases16(c,a); LaneCases16(c+16,a)
+#define LaneCases64(c,a) LaneCases32(c,a); LaneCases32(c+32,a)
+#define LaneCases128(c,a) LaneCases64(c,a); LaneCases64(c+64,a)
+#define LaneCases256(c,a) LaneCases128(c,a); LaneCases128(c+128,a)
+
+#if FB_SHIFT == 6
+#define LaneCases(a) LaneCases256(0,a)
+#endif
+
+#if FB_SHIFT == 5
+#define LaneCases(a) LaneCases16(0,a)
+#endif
+
+/*
+ * Repeat a transparent stipple across a scanline n times
+ */
+
+void
+fbTransparentSpan (FbBits *dst,
+ FbBits stip,
+ FbBits fgxor,
+ int n)
+{
+ FbStip s;
+
+ s = ((FbStip) (stip ) & 0x01);
+ s |= ((FbStip) (stip >> 8) & 0x02);
+ s |= ((FbStip) (stip >> 16) & 0x04);
+ s |= ((FbStip) (stip >> 24) & 0x08);
+#if FB_SHIFT > 5
+ s |= ((FbStip) (stip >> 32) & 0x10);
+ s |= ((FbStip) (stip >> 40) & 0x20);
+ s |= ((FbStip) (stip >> 48) & 0x40);
+ s |= ((FbStip) (stip >> 56) & 0x80);
+#endif
+ switch (s) {
+ LaneCases(dst);
+ }
+}
+
+void
+fbEvenStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot)
+{
+ FbBits startmask, endmask;
+ FbBits mask, and, xor;
+ int nmiddle, n;
+ FbStip *s, *stipEnd, bits;
+ int rot, stipX, stipY;
+ int pixelsPerDst;
+ const FbBits *fbBits;
+ Bool transparent;
+ int startbyte, endbyte;
+
+ /*
+ * Check for a transparent stipple (stencil)
+ */
+ transparent = FALSE;
+ if (dstBpp >= 8 &&
+ fgand == 0 && bgand == FB_ALLONES && bgxor == 0)
+ transparent = TRUE;
+
+ pixelsPerDst = FB_UNIT / dstBpp;
+ /*
+ * Adjust dest pointers
+ */
+ dst += dstX >> FB_SHIFT;
+ dstX &= FB_MASK;
+ FbMaskBitsBytes (dstX, width, fgand == 0 && bgand == 0,
+ startmask, startbyte, nmiddle, endmask, endbyte);
+
+ if (startmask)
+ dstStride--;
+ dstStride -= nmiddle;
+
+ xRot *= dstBpp;
+ /*
+ * Compute stip start scanline and rotation parameters
+ */
+ stipEnd = stip + stipStride * stipHeight;
+ modulus (- yRot, stipHeight, stipY);
+ s = stip + stipStride * stipY;
+ modulus (- xRot, FB_UNIT, stipX);
+ rot = stipX;
+
+ /*
+ * Get pointer to stipple mask array for this depth
+ */
+ /* fbStippleTable covers all valid bpp (4,8,16,32) */
+ fbBits = fbStippleTable[pixelsPerDst];
+
+ while (height--)
+ {
+ /*
+ * Extract stipple bits for this scanline;
+ */
+ bits = READ(s);
+ s += stipStride;
+ if (s == stipEnd)
+ s = stip;
+#if FB_UNIT > 32
+ if (pixelsPerDst == 16)
+ mask = FbStipple16Bits(FbLeftStipBits(bits,16));
+ else
+#endif
+ mask = fbBits[FbLeftStipBits(bits,pixelsPerDst)];
+ /*
+ * Rotate into position and compute reduced rop values
+ */
+ mask = FbRotLeft(mask, rot);
+ and = (fgand & mask) | (bgand & ~mask);
+ xor = (fgxor & mask) | (bgxor & ~mask);
+
+ if (transparent)
+ {
+ if (startmask)
+ {
+ fbTransparentSpan(dst, mask&startmask, fgxor, 1);
+ dst++;
+ }
+ fbTransparentSpan (dst, mask, fgxor, nmiddle);
+ dst += nmiddle;
+ if (endmask)
+ fbTransparentSpan(dst, mask&endmask, fgxor, 1);
+ }
+ else
+ {
+ /*
+ * Fill scanline
+ */
+ if (startmask)
+ {
+ FbDoLeftMaskByteRRop (dst, startbyte, startmask, and, xor);
+ dst++;
+ }
+ n = nmiddle;
+ if (!and)
+ while (n--)
+ WRITE(dst++, xor);
+ else
+ {
+ while (n--)
+ {
+ WRITE(dst, FbDoRRop (READ(dst), and, xor));
+ dst++;
+ }
+ }
+ if (endmask)
+ FbDoRightMaskByteRRop(dst, endbyte, endmask, and, xor);
+ }
+ dst += dstStride;
+ }
+}
+
+void
+fbOddStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot)
+{
+ int stipX, stipY, sx;
+ int widthTmp;
+ int h, w;
+ int x, y;
+
+ modulus (- yRot, stipHeight, stipY);
+ modulus (dstX / dstBpp - xRot, stipWidth, stipX);
+ y = 0;
+ while (height)
+ {
+ h = stipHeight - stipY;
+ if (h > height)
+ h = height;
+ height -= h;
+ widthTmp = width;
+ x = dstX;
+ sx = stipX;
+ while (widthTmp)
+ {
+ w = (stipWidth - sx) * dstBpp;
+ if (w > widthTmp)
+ w = widthTmp;
+ widthTmp -= w;
+ fbBltOne (stip + stipY * stipStride,
+ stipStride,
+ sx,
+
+ dst + y * dstStride,
+ dstStride,
+ x,
+ dstBpp,
+
+ w, h,
+
+ fgand, fgxor, bgand, bgxor);
+ x += w;
+ sx = 0;
+ }
+ y += h;
+ stipY = 0;
+ }
+}
+
+void
+fbStipple (FbBits *dst,
+ FbStride dstStride,
+ int dstX,
+ int dstBpp,
+
+ int width,
+ int height,
+
+ FbStip *stip,
+ FbStride stipStride,
+ int stipWidth,
+ int stipHeight,
+ Bool even,
+
+ FbBits fgand,
+ FbBits fgxor,
+ FbBits bgand,
+ FbBits bgxor,
+
+ int xRot,
+ int yRot)
+{
+ if (even)
+ fbEvenStipple (dst, dstStride, dstX, dstBpp, width, height,
+ stip, stipStride, stipHeight,
+ fgand, fgxor, bgand, bgxor, xRot, yRot);
+ else
+ fbOddStipple (dst, dstStride, dstX, dstBpp, width, height,
+ stip, stipStride, stipWidth, stipHeight,
+ fgand, fgxor, bgand, bgxor, xRot, yRot);
+}
diff --git a/xorg-server/fb/fbwindow.c b/xorg-server/fb/fbwindow.c
index 92b23acdb..f4032b053 100644
--- a/xorg-server/fb/fbwindow.c
+++ b/xorg-server/fb/fbwindow.c
@@ -33,10 +33,8 @@ fbCreateWindow(WindowPtr pWin)
{
dixSetPrivate(&pWin->devPrivates, fbGetWinPrivateKey(),
fbGetScreenPixmap(pWin->drawable.pScreen));
-#ifdef FB_SCREEN_PRIVATE
if (pWin->drawable.bitsPerPixel == 32)
pWin->drawable.bitsPerPixel = fbGetScreenPrivate(pWin->drawable.pScreen)->win32bpp;
-#endif
return TRUE;
}
@@ -148,55 +146,36 @@ fbCopyWindow(WindowPtr pWin,
fbValidateDrawable (&pWin->drawable);
}
+static void
+fbFixupWindowPixmap(DrawablePtr pDrawable, PixmapPtr *ppPixmap)
+{
+ PixmapPtr pPixmap = *ppPixmap;
+
+ if (pPixmap->drawable.bitsPerPixel != pDrawable->bitsPerPixel)
+ {
+ pPixmap = fb24_32ReformatTile (pPixmap, pDrawable->bitsPerPixel);
+ if (!pPixmap)
+ return;
+ (*pDrawable->pScreen->DestroyPixmap) (*ppPixmap);
+ *ppPixmap = pPixmap;
+ }
+ if (FbEvenTile (pPixmap->drawable.width *
+ pPixmap->drawable.bitsPerPixel))
+ fbPadPixmap (pPixmap);
+}
+
Bool
fbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
{
- PixmapPtr pPixmap;
-
if (mask & CWBackPixmap)
{
if (pWin->backgroundState == BackgroundPixmap)
- {
- pPixmap = pWin->background.pixmap;
-#ifdef FB_24_32BIT
- if (pPixmap->drawable.bitsPerPixel != pWin->drawable.bitsPerPixel)
- {
- pPixmap = fb24_32ReformatTile (pPixmap,
- pWin->drawable.bitsPerPixel);
- if (pPixmap)
- {
- (*pWin->drawable.pScreen->DestroyPixmap) (pWin->background.pixmap);
- pWin->background.pixmap = pPixmap;
- }
- }
-#endif
- if (FbEvenTile (pPixmap->drawable.width *
- pPixmap->drawable.bitsPerPixel))
- fbPadPixmap (pPixmap);
- }
+ fbFixupWindowPixmap(&pWin->drawable, &pWin->background.pixmap);
}
if (mask & CWBorderPixmap)
{
if (pWin->borderIsPixel == FALSE)
- {
- pPixmap = pWin->border.pixmap;
-#ifdef FB_24_32BIT
- if (pPixmap->drawable.bitsPerPixel !=
- pWin->drawable.bitsPerPixel)
- {
- pPixmap = fb24_32ReformatTile (pPixmap,
- pWin->drawable.bitsPerPixel);
- if (pPixmap)
- {
- (*pWin->drawable.pScreen->DestroyPixmap) (pWin->border.pixmap);
- pWin->border.pixmap = pPixmap;
- }
- }
-#endif
- if (FbEvenTile (pPixmap->drawable.width *
- pPixmap->drawable.bitsPerPixel))
- fbPadPixmap (pPixmap);
- }
+ fbFixupWindowPixmap(&pWin->drawable, &pWin->border.pixmap);
}
return TRUE;
}