summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAdam Jackson <ajax@redhat.com>2008-05-21 17:03:25 -0400
committerAdam Jackson <ajax@redhat.com>2008-05-21 17:03:25 -0400
commit20ea99c655140e101f2d20cfab78fb22765fec62 (patch)
tree0d8bf0dee374acfe3f0f1ccc3c02bc7b879b1a9d
parentc76fddeea28b4f88db97a2a3487d7a57cd9d578c (diff)
Death to afb.
Planar framebuffer people, please talk to wfb for all your 1988 hardware needs.
-rw-r--r--Makefile.am4
-rw-r--r--afb/Makefile.am51
-rw-r--r--afb/README10
-rw-r--r--afb/Xdaniver.doc218
-rw-r--r--afb/afb.h972
-rw-r--r--afb/afbbitblt.c343
-rw-r--r--afb/afbblt.c563
-rw-r--r--afb/afbbres.c323
-rw-r--r--afb/afbbresd.c214
-rw-r--r--afb/afbclip.c248
-rw-r--r--afb/afbcmap.c84
-rw-r--r--afb/afbfillarc.c347
-rw-r--r--afb/afbfillrct.c292
-rw-r--r--afb/afbfillsp.c1130
-rw-r--r--afb/afbfont.c77
-rw-r--r--afb/afbgc.c685
-rw-r--r--afb/afbgetsp.c165
-rw-r--r--afb/afbhrzvert.c209
-rw-r--r--afb/afbimage.c272
-rw-r--r--afb/afbimggblt.c472
-rw-r--r--afb/afbline.c707
-rw-r--r--afb/afbmisc.c94
-rw-r--r--afb/afbpixmap.c299
-rw-r--r--afb/afbply1rct.c300
-rw-r--r--afb/afbplygblt.c463
-rw-r--r--afb/afbpntarea.c655
-rw-r--r--afb/afbpolypnt.c146
-rw-r--r--afb/afbpushpxl.c169
-rw-r--r--afb/afbscrinit.c218
-rw-r--r--afb/afbsetsp.c257
-rw-r--r--afb/afbtegblt.c586
-rw-r--r--afb/afbtile.c857
-rw-r--r--afb/afbwindow.c164
-rw-r--r--afb/afbzerarc.c201
-rw-r--r--configure.ac6
-rw-r--r--hw/xfree86/dixmods/Makefile.am11
-rw-r--r--hw/xfree86/dixmods/afbmodule.c57
37 files changed, 2 insertions, 11867 deletions
diff --git a/Makefile.am b/Makefile.am
index 86ee9e8e3..7b6b02a1f 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -9,10 +9,6 @@ if XTRAP
9XTRAP_DIR=XTrap 9XTRAP_DIR=XTrap
10endif 10endif
11 11
12if AFB
13AFB_DIR=afb
14endif
15
16if MFB 12if MFB
17MFB_DIR=mfb 13MFB_DIR=mfb
18endif 14endif
diff --git a/afb/Makefile.am b/afb/Makefile.am
deleted file mode 100644
index 9fc22ca54..000000000
--- a/afb/Makefile.am
+++ /dev/null
@@ -1,51 +0,0 @@
1noinst_LTLIBRARIES = libafb.la
2
3AM_CFLAGS = $(DIX_CFLAGS)
4
5libafb_gen_sources = afbbltC.c afbbltX.c afbbltCI.c afbbltO.c afbbltG.c afbtileC.c afbtileG.c afbseg.c
6
7DISTCLEANFILES = $(libafb_gen_sources)
8
9libafb_la_SOURCES = afbgc.c afbwindow.c afbfont.c afbfillrct.c afbpixmap.c \
10 afbimage.c afbline.c afbbres.c afbhrzvert.c afbbresd.c afbpushpxl.c afbply1rct.c \
11 afbzerarc.c afbfillarc.c afbfillsp.c afbsetsp.c afbscrinit.c afbplygblt.c \
12 afbclip.c afbgetsp.c afbpolypnt.c afbbitblt.c afbcmap.c afbimggblt.c afbpntarea.c \
13 afbmisc.c afbtegblt.c $(libafb_gen_sources)
14
15INCLUDES = -I$(top_srcdir)/mfb -I$(top_srcdir)/hw/xfree86/os-support
16
17EXTRA_DIST = afbline.c afbblt.c afbtile.c README Xdaniver.doc
18
19afbseg.c:
20 echo "#define POLYSEGMENT" > $@
21 echo "#include \"$(srcdir)/afbline.c\"" >> $@
22
23afbbltC.c:
24 echo "#define MROP Mcopy" > $@
25 echo "#include \"$(srcdir)/afbblt.c\"" >> $@
26
27afbbltX.c:
28 echo "#define MROP Mxor" > $@
29 echo "#include \"$(srcdir)/afbblt.c\"" >> $@
30
31afbbltCI.c:
32 echo "#define MROP McopyInverted" > $@
33 echo "#include \"$(srcdir)/afbblt.c\"" >> $@
34
35afbbltO.c:
36 echo "#define MROP Mor" > $@
37 echo "#include \"$(srcdir)/afbblt.c\"" >> $@
38
39afbbltG.c:
40 echo "#define MROP 0" > $@
41 echo "#include \"$(srcdir)/afbblt.c\"" >> $@
42
43afbtileC.c:
44 echo "#define MROP Mcopy" > $@
45 echo "#include \"$(srcdir)/afbtile.c\"" >> $@
46
47afbtileG.c:
48 echo "#define MROP 0" > $@
49 echo "#include \"$(srcdir)/afbtile.c\"" >> $@
50
51sdk_HEADERS = afb.h
diff --git a/afb/README b/afb/README
deleted file mode 100644
index 5c9586013..000000000
--- a/afb/README
+++ /dev/null
@@ -1,10 +0,0 @@
1
2All stuff in this directory is based on Xdaniver (read Xdaniver.doc).
3
4Actually this is the same code as in the ilbm directory, except that here the
5conversion from normal bitplanes to interleaved bitplanes didn't happen.
6
7--
8Geert Uytterhoeven Geert.Uytterhoeven@cs.kuleuven.ac.be
9Wavelets, Linux/m68k on Amiga http://www.cs.kuleuven.ac.be/~geert/
10Department of Computer Science -- Katholieke Universiteit Leuven -- Belgium
diff --git a/afb/Xdaniver.doc b/afb/Xdaniver.doc
deleted file mode 100644
index 1c8ad5ad4..000000000
--- a/afb/Xdaniver.doc
+++ /dev/null
@@ -1,218 +0,0 @@
1
2What is it?
3-----------
4
5Xdaniver is a fast, colour X11R6 server for the Amiga's custom chip set
6under NetBSD 1.0 and NetBSD-current, supporting all the Amiga's display
7depths from 1 to 4 (upto 16 colours) on ECS machines and 1 to 8 (upto 256
8colours) on AGA machines (though, not all resolutions are available, see
9General Information below).
10
11Xdaniver is designed to be a drop-in replacement for the Xmono server provided
12with the X11R6 binary distribution supplied by Bernd Ernesti available from
13ftp.uni-regensburg.de or one of its mirrors.
14
15Unlike previous colour X servers for the Amiga that emulate a chunky pixel
16screen in fast RAM, use the standard frame buffer drivers provided with the
17X11R6 source code to draw and then use a chunky to planar conversion routine
18to write the results to the screen (all very slow), Xdaniver uses a heavily
19modified mono frame buffer driver to draw directly using the Amiga's planar
20format. The net result is much faster drawing and support for all the Amiga's
21custom display depths but, as usual, the fewer planes used, the faster the
22drawing operations of the X server. Even so, on my A1200 with a 33Mhz 68030,
23I'm getting reasonable performance when using 8 bit planes in Dbl NTSC mode.
24
25Installation
26------------
27
28You will need to have first obtained and installed the X11R6 binary
29distribution available from ftp.uni-regensburg.de in
30/pub/NetBSD-Amiga/contrib/X11 or one of its mirrors. Xdaniver has been
31compiled to expect font and configuration files sitting under
32/usr/local/X11R6, if your setup is different you will need to provide a
33symbolic link from /usr/local/X11R6 to where your tree resides or supply
34several command line flags to the server.
35
36To get Xdaniver running as the default X server, copy the uncompressed binary
37into /usr/local/X11R6/bin, remove the current X file from that directory
38(which is a symbolic link to Xmono) and replace it with a link to Xdaniver:
39
40 gzip -d < X11R6.Xdaniver.1.01.tar.gz | tar xvf -
41 mv Xdaniver /usr/local/X11R6/bin
42 cd /usr/local/X11R6/bin
43 rm X
44 ln -s Xdaniver X
45
46Note that on some setups, the devices /dev/kbd, /dev/mouse and /dev/view??
47have been created to be accessable only by superuser; Xdaniver needs to open
48these devices. To workaround this problem, log on as superuser and then
49either make Xdaniver setuid root:
50
51 chown root Xdaniver
52 chmod 4755 Xdaniver
53
54or give everyone access the devices:
55
56 chmod 666 /dev/kbd /dev/mouse /dev/view??
57
58the latter option is a possible cause of a security hole if your machine is
59ever used multi-user.
60
61General Information
62-------------------
63
64The default resolution of the server is 700x430 and the default depth 4. AGA
65users might what to increase the display depth by editing the startx script
66and providing a -depth <depth> argument to Xdaniver on the xinit line of the
67script. As always, the lower the depth, the faster the drawing and window
68manipulation of the server.
69
70The resolution can be altered similarly by suppling -width <width> and
71-height <height> arguments to the server.
72
73The NetBSD kernel selects actual screen modes by picking a mode who's
74natural, non-overscanned size best-fits the requested resolution.
75Unfortunately, for AGA users, the 1.0 kernel only has support for the
76Dbl-NTSC AGA display mode and only this mode has support for depths greater
77than 4. The NetBSD-current (work-in-progress) kernel also has support for
78Dbl-PAL but still no support for the Super72 or other super-hires modes
79(perhaps some kind, kernel-hacker could add support for them ?).
80
81If you have a 2 button mouse (like me) you might want to try and use the 3
82button mouse emulation. On other systems, it is usual for the left and right
83buttons to be provided and emulate the middle button by pressing both
84buttons together, however, the middle button is tends to be used more than
85the right button so I have provided two options:
86
87-emulateright (or -3), the two physical mouse buttons act as left and middle
88and pressing them both together emulates the right button.
89
90-emulatemiddle (or -2), the two physical mouse buttons act as left and right
91and pressing them both together emulated the middle button.
92
93When using screen depths of less than 6 (4 is the maximum for ECS machines)
94the lack of possible colours on screen at once causes problems for many X
95applications. Specifying -cc 2 as a command line argument to Xdaniver
96causes the server to switch the default visual type from PsuedoColor to
97StaticColor; to put it simply, the server prefills the colormap with a
98selection of 16 colours (depth 4) and when an application asks for a
99particular colour, its gets allocated one that is closest to one from the
100selection of 16. This removes the 'WARNING: Cannot allocate colormap entry
101for "XXX"' errors but at the expense of applications not being able to get
102the precise colour they wanted. Also, some badly written X applications fail
103altogether when presented with a StaticColor visual.
104
105Bugs/Limitations
106----------------
107
108The limited choice of display resolutions for AGA/ECS machines is a real
109pain - requires a kernel change to fix. Worse still, the kernel specifies
110the maximum overscan resolution on the Dbl-NTSC to be 724x482 but selecting
111anything more than 702x430 on my machine causes the screen either sheer
112diagonally (as if the bytes per row calculation in Xdaniver or the kernel is
113wrong) or completely loose sync (suggesting a custom chip register sync
114calculation bug). As other, non-aga modes aren't affected when selection
115overscan both problems seem to point to a kernel driver bug. Also, depths
116greater than 4 for AGA users are only supported by the kernel in the Dbl-NTSC
117mode (and Dbl-PAL with the current-NetBSD kernel).
118
119I know of one bug so-far (there will be more), The PutImage request of an XY
120format image expects the bitplane order to be the reverse of that specified
121in the X protocol but since virtually all applications use the Z (chunky)
122format, you are unlikely to come across this problem.
123
124The PutImage request of Z format images is a little slow - when I have time
125I'll try and add one of the fast assembly chunky-to-planar routines developed
126for doom style games/demos. Unfortunately, the current crop all require a
127picture size that is a multiple of 32 pixels and so cannot be used out-of-the-
128box.
129
130Some extra performance could easily be squeezed out of the terminal font
131drawing code (used by xterm) - when I have time I'll add the code.
132
133The Amiga's blitter and sprites are totally unused and will remain so
134until/if someone else adds support to the kernel. The blitter would help
135speed up screen scrolling and window manipulation and sprite support could
136be used for the X pointer shape (if small enough) which would speed up all
137drawing operations (no need to remove the software based pointer shape
138first, draw, then replace the pointer shape).
139
140I removed the X image extension (XIE) from the X server as it increased the
141size of the binary by some 400k. I haven't come across any applications that
142need it yet (I haven't been looking!) so if you need the extension for some
143reason send me e-mail and I'll build a server with the extension included.
144
145The 3 button mouse emulation is very simple - to emulate the 3rd button you
146have to press both button precisely at the same moment - I've got quite good
147at it now. When I have some spare time I'll add a timer so you will have a
148few milli-seconds between one button being pressed and the next and it still
149being registered as the emulated button.
150
151AGA users don't forget to provide the -A flag to loadbsd to enable the one
152AGA mode in the 1.0 kernel but only if you have a VGA, multisync or dual-scan
153monitor, of course !
154
155Xdaniver has been tested on:
156
157A1200, 33Mhz 68030, 8Mb RAM and NetBSD 1.0 by myself.
158A4000/40, 12Mb RAM and NetBSD 1.0 by Andreas Holzhammer.
159A3000, 12Mb RAM and NetBSD 1.0 by Charlie Root, Stuart Park and others.
160A3000, 25Mhz 68040, 18Mb RAM and NetBSD-current by Michael K. Sanders.
161A2000, 8Mb RAM and NetBSD (version unknown) by Hubert Feyrer.
162
163Release and Bug Fix History
164---------------------------
165
1661.0 - First release
167
1681.01 Bugs fixed:
169 - Narrow (<32 pixels) Z format GetImage requests corrupted the stack
170 and could cause the server to core dump. (Xpaint caused this problem)
171 - Drawing dots (PolyPoint request) into a clipped window caused a
172 c pointer to go out of range, causing a core dump (xv showed this
173 problem).
174
175 New features:
176 - Simple 3 button mouse emulation using a 2 button mouse; specify
177 -emulate_middle (or -2) or -emulate_right (or -3) on the server's
178 command line and press both mouse buttons together emulate the 'missing'
179 button.
180 - Basic beep sound support added by sending bell characters to the
181 console.
182 - Source code released.
183
184Disclaimer and Copyright Notices
185--------------------------------
186
187Multi-depth planar frame buffer code:
188Copyright (c) 1995 by Daniver Limited.
189
190Large portions:
191Copyright (c) 1994 by Eduardo Horvath.
192Copyright (c) 1987-1995 by the Regents of the University of California.
193Copyright (c) 1987 by Sun Microsystems, Inc. Mountain View, CA.
194Copyright (c) 1987-1995 by X Consortium.
195Copyright (c) 1987, 1989 by Digital Equipment Corporation, Maynard, Massachusetts.
196Copyright (c) 1989 Network Computing Devices, Inc., Mountain View, California.
197
198Permission to use, copy, modify, and distribute this software and its
199documentation for any purpose and without fee is hereby granted, provided
200that the above copyright notice appear in all copies. The Daniver Limited,
201the above companies and individuals makes no representations about the
202suitability of this software for any purpose. It is provided "as is" without
203express or implied warranty.
204
205Credits
206-------
207
208Thanks to Bernd Ernesti for making the operating system server source code
209available for others to use and Eduardo Horvath and Andy Heffernan, who (I
210think) did the original Xmono server port.
211
212Also, many thanks to the first brave users who tested Xdaniver for me on other
213Amiga setups and found a few bugs in the process.
214
215Gary Henderson.
216
217Daytime: garyh@wet.sbi.com
218Home: gary@daniver.demon.co.uk
diff --git a/afb/afb.h b/afb/afb.h
deleted file mode 100644
index 6731d9557..000000000
--- a/afb/afb.h
+++ /dev/null
@@ -1,972 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49/* Monochrome Frame Buffer definitions
50 written by drewry, september 1986
51*/
52
53#include "pixmap.h"
54#include "region.h"
55#include "gc.h"
56#include "colormap.h"
57#include "regionstr.h"
58#include "privates.h"
59#include "mibstore.h"
60#include "mfb.h"
61
62extern int afbInverseAlu[];
63/* warning: PixelType definition duplicated in maskbits.h */
64#ifndef PixelType
65#define PixelType CARD32
66#endif /* PixelType */
67
68#define AFB_MAX_DEPTH 8
69
70/* afbbitblt.c */
71
72extern void afbDoBitblt(
73 DrawablePtr /*pSrc*/,
74 DrawablePtr /*pDst*/,
75 int /*alu*/,
76 RegionPtr /*prgnDst*/,
77 DDXPointPtr /*pptSrc*/,
78 unsigned long /*planemask*/
79);
80
81extern RegionPtr afbCopyArea(
82 DrawablePtr /*pSrcDrawable*/,
83 DrawablePtr /*pDstDrawable*/,
84 GCPtr/*pGC*/,
85 int /*srcx*/,
86 int /*srcy*/,
87 int /*width*/,
88 int /*height*/,
89 int /*dstx*/,
90 int /*dsty*/
91);
92
93/* afbbltC.c */
94
95extern void afbDoBitbltCopy(
96 DrawablePtr /*pSrc*/,
97 DrawablePtr /*pDst*/,
98 int /*alu*/,
99 RegionPtr /*prgnDst*/,
100 DDXPointPtr /*pptSrc*/,
101 unsigned long /*planemask*/
102);
103/* afbbltCI.c */
104
105extern void afbDoBitbltCopyInverted(
106 DrawablePtr /*pSrc*/,
107 DrawablePtr /*pDst*/,
108 int /*alu*/,
109 RegionPtr /*prgnDst*/,
110 DDXPointPtr /*pptSrc*/,
111 unsigned long /*planemask*/
112);
113/* afbbltG.c */
114
115extern void afbDoBitbltGeneral(
116 DrawablePtr /*pSrc*/,
117 DrawablePtr /*pDst*/,
118 int /*alu*/,
119 RegionPtr /*prgnDst*/,
120 DDXPointPtr /*pptSrc*/,
121 unsigned long /*planemask*/
122);
123/* afbbltO.c */
124
125extern void afbDoBitbltOr(
126 DrawablePtr /*pSrc*/,
127 DrawablePtr /*pDst*/,
128 int /*alu*/,
129 RegionPtr /*prgnDst*/,
130 DDXPointPtr /*pptSrc*/,
131 unsigned long /*planemask*/
132);
133/* afbbltX.c */
134
135extern void afbDoBitbltXor(
136 DrawablePtr /*pSrc*/,
137 DrawablePtr /*pDst*/,
138 int /*alu*/,
139 RegionPtr /*prgnDst*/,
140 DDXPointPtr /*pptSrc*/,
141 unsigned long /*planemask*/
142);
143/* afbbres.c */
144
145extern void afbBresS(
146 PixelType * /*addrl*/,
147 int /*nlwidth*/,
148 int /*sizeDst*/,
149 int /*depthDst*/,
150 int /*signdx*/,
151 int /*signdy*/,
152 int /*axis*/,
153 int /*x1*/,
154 int /*y1*/,
155 int /*e*/,
156 int /*e1*/,
157 int /*e2*/,
158 int /*len*/,
159 unsigned char * /*rrops*/
160);
161/* afbbresd.c */
162
163extern void afbBresD(
164 int * /*pdashIndex*/,
165 unsigned char * /*pDash*/,
166 int /*numInDashList*/,
167 int * /*pdashOffset*/,
168 int /*isDoubleDash*/,
169 PixelType * /*addrl*/,
170 int /*nlwidth*/,
171 int /*sizeDst*/,
172 int /*depthDst*/,
173 int /*signdx*/,
174 int /*signdy*/,
175 int /*axis*/,
176 int /*x1*/,
177 int /*y1*/,
178 int /*e*/,
179 int /*e1*/,
180 int /*e2*/,
181 int /*len*/,
182 unsigned char * /*rrops*/,
183 unsigned char * /*bgrrops*/
184);
185
186/* afbclip.c */
187
188extern RegionPtr afbPixmapToRegion(
189 PixmapPtr /*pPix*/
190);
191
192/* afbcmap.c */
193
194extern int afbListInstalledColormaps(
195 ScreenPtr /*pScreen*/,
196 Colormap * /*pmaps*/
197);
198
199extern void afbInstallColormap(
200 ColormapPtr /*pmap*/
201);
202
203extern void afbUninstallColormap(
204 ColormapPtr /*pmap*/
205);
206
207extern void afbResolveColor(
208 unsigned short * /*pred*/,
209 unsigned short * /*pgreen*/,
210 unsigned short * /*pblue*/,
211 VisualPtr /*pVisual*/
212);
213
214extern Bool afbInitializeColormap(
215 ColormapPtr /*pmap*/
216);
217
218extern Bool afbInitVisuals(
219 VisualPtr * /*visualp*/,
220 DepthPtr * /*depthp*/,
221 int * /*nvisualp*/,
222 int * /*ndepthp*/,
223 int * /*rootDepthp*/,
224 VisualID * /*defaultVisp*/,
225 unsigned long /*sizes*/,
226 int /*bitsPerRGB*/
227);
228
229/* afbfillarc.c */
230
231extern void afbPolyFillArcSolid(
232 DrawablePtr /*pDraw*/,
233 GCPtr /*pGC*/,
234 int /*narcs*/,
235 xArc * /*parcs*/
236);
237/* afbfillrct.c */
238
239extern void afbPolyFillRect(
240 DrawablePtr /*pDrawable*/,
241 GCPtr /*pGC*/,
242 int /*nrectFill*/,
243 xRectangle * /*prectInit*/
244);
245
246/* afbply1rct.c */
247extern void afbFillPolygonSolid(
248 DrawablePtr /*pDrawable*/,
249 GCPtr /*pGC*/,
250 int /*mode*/,
251 int /*shape*/,
252 int /*count*/,
253 DDXPointPtr /*ptsIn*/
254);
255
256/* afbfillsp.c */
257
258extern void afbSolidFS(
259 DrawablePtr /*pDrawable*/,
260 GCPtr /*pGC*/,
261 int /*nInit*/,
262 DDXPointPtr /*pptInit*/,
263 int * /*pwidthInit*/,
264 int /*fSorted*/
265);
266
267extern void afbStippleFS(
268 DrawablePtr /*pDrawable*/,
269 GCPtr/*pGC*/,
270 int /*nInit*/,
271 DDXPointPtr /*pptInit*/,
272 int * /*pwidthInit*/,
273 int /*fSorted*/
274);
275
276extern void afbTileFS(
277 DrawablePtr /*pDrawable*/,
278 GCPtr/*pGC*/,
279 int /*nInit*/,
280 DDXPointPtr /*pptInit*/,
281 int * /*pwidthInit*/,
282 int /*fSorted*/
283);
284
285extern void afbUnnaturalTileFS(
286 DrawablePtr /*pDrawable*/,
287 GCPtr/*pGC*/,
288 int /*nInit*/,
289 DDXPointPtr /*pptInit*/,
290 int * /*pwidthInit*/,
291 int /*fSorted*/
292);
293
294extern void afbUnnaturalStippleFS(
295 DrawablePtr /*pDrawable*/,
296 GCPtr/*pGC*/,
297 int /*nInit*/,
298 DDXPointPtr /*pptInit*/,
299 int * /*pwidthInit*/,
300 int /*fSorted*/
301);
302
303extern void afbOpaqueStippleFS(
304 DrawablePtr /*pDrawable*/,
305 GCPtr/*pGC*/,
306 int /*nInit*/,
307 DDXPointPtr /*pptInit*/,
308 int * /*pwidthInit*/,
309 int /*fSorted*/
310);
311
312extern void afbUnnaturalOpaqueStippleFS(
313 DrawablePtr /*pDrawable*/,
314 GCPtr/*pGC*/,
315 int /*nInit*/,
316 DDXPointPtr /*pptInit*/,
317 int * /*pwidthInit*/,
318 int /*fSorted*/
319);
320
321/* afbfont.c */
322
323extern Bool afbRealizeFont(
324 ScreenPtr /*pscr*/,
325 FontPtr /*pFont*/
326);
327
328extern Bool afbUnrealizeFont(
329 ScreenPtr /*pscr*/,
330 FontPtr /*pFont*/
331);
332/* afbgc.c */
333
334extern Bool afbCreateGC(
335 GCPtr /*pGC*/
336);
337
338extern void afbReduceRop(
339 int /*alu*/,
340 Pixel /*src*/,
341 unsigned long /*planemask*/,
342 int /*depth*/,
343 unsigned char * /*rrops*/
344);
345
346/* afbgetsp.c */
347
348extern void afbGetSpans(
349 DrawablePtr /*pDrawable*/,
350 int /*wMax*/,
351 DDXPointPtr /*ppt*/,
352 int * /*pwidth*/,
353 int /*nspans*/,
354 char * /*pdstStart*/
355);
356/* afbhrzvert.c */
357
358extern void afbHorzS(
359 PixelType * /*addrl*/,
360 int /*nlwidth*/,
361 int /*sizeDst*/,
362 int /*depthDst*/,
363 int /*x1*/,
364 int /*y1*/,
365 int /*len*/,
366 unsigned char * /*rrops*/
367);
368
369extern void afbVertS(
370 PixelType * /*addrl*/,
371 int /*nlwidth*/,
372 int /*sizeDst*/,
373 int /*depthDst*/,
374 int /*x1*/,
375 int /*y1*/,
376 int /*len*/,
377 unsigned char * /*rrops*/
378);
379/* afbigbblak.c */
380
381extern void afbImageGlyphBlt (
382 DrawablePtr /*pDrawable*/,
383 GCPtr/*pGC*/,
384 int /*x*/,
385 int /*y*/,
386 unsigned int /*nglyph*/,
387 CharInfoPtr * /*ppci*/,
388 pointer /*pglyphBase*/
389);
390/* afbigbwht.c */
391
392/* afbimage.c */
393
394extern void afbPutImage(
395 DrawablePtr /*dst*/,
396 GCPtr /*pGC*/,
397 int /*depth*/,
398 int /*x*/,
399 int /*y*/,
400 int /*w*/,
401 int /*h*/,
402 int /*leftPad*/,
403 int /*format*/,
404 char * /*pImage*/
405);
406
407extern void afbGetImage(
408 DrawablePtr /*pDrawable*/,
409 int /*sx*/,
410 int /*sy*/,
411 int /*w*/,
412 int /*h*/,
413 unsigned int /*format*/,
414 unsigned long /*planeMask*/,
415 char * /*pdstLine*/
416);
417/* afbline.c */
418
419extern void afbLineSS(
420 DrawablePtr /*pDrawable*/,
421 GCPtr /*pGC*/,
422 int /*mode*/,
423 int /*npt*/,
424 DDXPointPtr /*pptInit*/
425);
426
427extern void afbLineSD(
428 DrawablePtr /*pDrawable*/,
429 GCPtr /*pGC*/,
430 int /*mode*/,
431 int /*npt*/,
432 DDXPointPtr /*pptInit*/
433);
434
435/* afbmisc.c */
436
437extern void afbQueryBestSize(
438 int /*class*/,
439 unsigned short * /*pwidth*/,
440 unsigned short * /*pheight*/,
441 ScreenPtr /*pScreen*/
442);
443/* afbpntarea.c */
444
445extern void afbSolidFillArea(
446 DrawablePtr /*pDraw*/,
447 int /*nbox*/,
448 BoxPtr /*pbox*/,
449 unsigned char * /*rrops*/
450);
451
452extern void afbStippleAreaPPW(
453 DrawablePtr /*pDraw*/,
454 int /*nbox*/,
455 BoxPtr /*pbox*/,
456 PixmapPtr /*pstipple*/,
457 unsigned char * /*rrops*/
458);
459extern void afbStippleArea(
460 DrawablePtr /*pDraw*/,
461 int /*nbox*/,
462 BoxPtr /*pbox*/,
463 PixmapPtr /*pstipple*/,
464 int /*xOff*/,
465 int /*yOff*/,
466 unsigned char * /*rrops*/
467);
468/* afbplygblt.c */
469
470extern void afbPolyGlyphBlt(
471 DrawablePtr /*pDrawable*/,
472 GCPtr /*pGC*/,
473 int /*x*/,
474 int /*y*/,
475 unsigned int /*nglyph*/,
476 CharInfoPtr * /*ppci*/,
477 pointer /*pglyphBase*/
478);
479
480/* afbpixmap.c */
481
482extern PixmapPtr afbCreatePixmap(
483 ScreenPtr /*pScreen*/,
484 int /*width*/,
485 int /*height*/,
486 int /*depth*/,
487 unsigned /*usage_hint*/
488);
489
490extern Bool afbDestroyPixmap(
491 PixmapPtr /*pPixmap*/
492);
493
494extern void afbXRotatePixmap(
495 PixmapPtr /*pPix*/,
496 int /*rw*/
497);
498
499extern void afbYRotatePixmap(
500 PixmapPtr /*pPix*/,
501 int /*rh*/
502);
503
504extern void afbCopyRotatePixmap(
505 PixmapPtr /*psrcPix*/,
506 PixmapPtr * /*ppdstPix*/,
507 int /*xrot*/,
508 int /*yrot*/
509);
510/* afbpolypnt.c */
511
512extern void afbPolyPoint(
513 DrawablePtr /*pDrawable*/,
514 GCPtr /*pGC*/,
515 int /*mode*/,
516 int /*npt*/,
517 xPoint * /*pptInit*/
518);
519/* afbpushpxl.c */
520
521extern void afbPushPixels(
522 GCPtr /*pGC*/,
523 PixmapPtr /*pBitMap*/,
524 DrawablePtr /*pDrawable*/,
525 int /*dx*/,
526 int /*dy*/,
527 int /*xOrg*/,
528 int /*yOrg*/
529);
530
531/* afbscrinit.c */
532
533extern Bool afbScreenInit(
534 ScreenPtr /*pScreen*/,
535 pointer /*pbits*/,
536 int /*xsize*/,
537 int /*ysize*/,
538 int /*dpix*/,
539 int /*dpiy*/,
540 int /*width*/
541);
542
543/* afbseg.c */
544
545extern void afbSegmentSS(
546 DrawablePtr /*pDrawable*/,
547 GCPtr /*pGC*/,
548 int /*nseg*/,
549 xSegment * /*pSeg*/
550);
551
552extern void afbSegmentSD(
553 DrawablePtr /*pDrawable*/,
554 GCPtr /*pGC*/,
555 int /*nseg*/,
556 xSegment * /*pSeg*/
557);
558/* afbsetsp.c */
559
560extern void afbSetSpans(
561 DrawablePtr /*pDrawable*/,
562 GCPtr /*pGC*/,
563 char * /*psrc*/,
564 DDXPointPtr /*ppt*/,
565 int * /*pwidth*/,
566 int /*nspans*/,
567 int /*fSorted*/
568);
569/* afbtegblt.c */
570
571extern void afbTEGlyphBlt(
572 DrawablePtr /*pDrawable*/,
573 GCPtr/*pGC*/,
574 int /*x*/,
575 int /*y*/,
576 unsigned int /*nglyph*/,
577 CharInfoPtr * /*ppci*/,
578 pointer /*pglyphBase*/
579);
580/* afbtileC.c */
581
582extern void afbTileAreaPPWCopy(
583 DrawablePtr /*pDraw*/,
584 int /*nbox*/,
585 BoxPtr /*pbox*/,
586 int /*alu*/,
587 PixmapPtr /*ptile*/,
588 unsigned long /*planemask*/
589);
590/* afbtileG.c */
591
592extern void afbTileAreaPPWGeneral(
593 DrawablePtr /*pDraw*/,
594 int /*nbox*/,
595 BoxPtr /*pbox*/,
596 int /*alu*/,
597 PixmapPtr /*ptile*/,
598 unsigned long /*planemask*/
599);
600
601extern void afbTileAreaCopy(
602 DrawablePtr /*pDraw*/,
603 int /*nbox*/,
604 BoxPtr /*pbox*/,
605 int /*alu*/,
606 PixmapPtr /*ptile*/,
607 int /*xOff*/,
608 int /*yOff*/,
609 unsigned long /*planemask*/
610);
611/* afbtileG.c */
612
613extern void afbTileAreaGeneral(
614 DrawablePtr /*pDraw*/,
615 int /*nbox*/,
616 BoxPtr /*pbox*/,
617 int /*alu*/,
618 PixmapPtr /*ptile*/,
619 int /*xOff*/,
620 int /*yOff*/,
621 unsigned long /*planemask*/
622);
623
624extern void afbOpaqueStippleAreaPPWCopy(
625 DrawablePtr /*pDraw*/,
626 int /*nbox*/,
627 BoxPtr /*pbox*/,
628 int /*alu*/,
629 PixmapPtr /*ptile*/,
630 unsigned char */*rropsOS*/,
631 unsigned long /*planemask*/
632);
633/* afbtileG.c */
634
635extern void afbOpaqueStippleAreaPPWGeneral(
636 DrawablePtr /*pDraw*/,
637 int /*nbox*/,
638 BoxPtr /*pbox*/,
639 int /*alu*/,
640 PixmapPtr /*ptile*/,
641 unsigned char */*rropsOS*/,
642 unsigned long /*planemask*/
643);
644
645extern void afbOpaqueStippleAreaCopy(
646 DrawablePtr /*pDraw*/,
647 int /*nbox*/,
648 BoxPtr /*pbox*/,
649 int /*alu*/,
650 PixmapPtr /*ptile*/,
651 int /*xOff*/,
652 int /*yOff*/,
653 unsigned char */*rropsOS*/,
654 unsigned long /*planemask*/
655);
656/* afbtileG.c */
657
658extern void afbOpaqueStippleAreaGeneral(
659 DrawablePtr /*pDraw*/,
660 int /*nbox*/,
661 BoxPtr /*pbox*/,
662 int /*alu*/,
663 PixmapPtr /*ptile*/,
664 int /*xOff*/,
665 int /*yOff*/,
666 unsigned char */*rropsOS*/,
667 unsigned long /*planemask*/
668);
669
670/* afbwindow.c */
671
672extern Bool afbCreateWindow(
673 WindowPtr /*pWin*/
674);
675
676extern Bool afbDestroyWindow(
677 WindowPtr /*pWin*/
678);
679
680extern Bool afbMapWindow(
681 WindowPtr /*pWindow*/
682);
683
684extern Bool afbPositionWindow(
685 WindowPtr /*pWin*/,
686 int /*x*/,
687 int /*y*/
688);
689
690extern Bool afbUnmapWindow(
691 WindowPtr /*pWindow*/
692);
693
694extern void afbCopyWindow(
695 WindowPtr /*pWin*/,
696 DDXPointRec /*ptOldOrg*/,
697 RegionPtr /*prgnSrc*/
698);
699
700extern Bool afbChangeWindowAttributes(
701 WindowPtr /*pWin*/,
702 unsigned long /*mask*/
703);
704/* afbzerarc.c */
705
706extern void afbZeroPolyArcSS(
707 DrawablePtr /*pDraw*/,
708 GCPtr /*pGC*/,
709 int /*narcs*/,
710 xArc * /*parcs*/
711);
712
713/*
714 private field of pixmap
715 pixmap.devPrivate = (PixelType *)pointer_to_bits
716 pixmap.devKind = width_of_pixmap_in_bytes
717
718 private field of screen
719 a pixmap, for which we allocate storage. devPrivate is a pointer to
720the bits in the hardware framebuffer. note that devKind can be poked to
721make the code work for framebuffers that are wider than their
722displayable screen (e.g. the early vsII, which displayed 960 pixels
723across, but was 1024 in the hardware.)
724
725 private field of GC
726*/
727
728typedef struct {
729 unsigned char rrops[AFB_MAX_DEPTH]; /* reduction of rasterop to 1 of 3 */
730 unsigned char rropOS[AFB_MAX_DEPTH]; /* rop for opaque stipple */
731} afbPrivGC;
732typedef afbPrivGC *afbPrivGCPtr;
733
734extern DevPrivateKey afbScreenPrivateKey;
735extern DevPrivateKey afbGCPrivateKey;
736extern DevPrivateKey afbWindowPrivateKey;
737#ifdef PIXMAP_PER_WINDOW
738extern DevPrivateKey frameWindowPrivateKey;
739#endif
740
741#define afbGetGCPrivate(pGC) \
742 ((afbPrivGC *)dixLookupPrivate(&(pGC)->devPrivates, afbGCPrivateKey))
743
744/* Common macros for extracting drawing information */
745
746#define afbGetTypedWidth(pDrawable,wtype)( \
747 (((pDrawable)->type == DRAWABLE_WINDOW) ? \
748 (int)(((PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey)->devKind) : \
749 (int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
750
751#define afbGetByteWidth(pDrawable) afbGetTypedWidth(pDrawable, unsigned char)
752
753#define afbGetPixelWidth(pDrawable) afbGetTypedWidth(pDrawable, PixelType)
754
755#define afbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
756 PixmapPtr _pPix; \
757 if ((pDrawable)->type == DRAWABLE_WINDOW) \
758 _pPix = (PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey); \
759 else \
760 _pPix = (PixmapPtr)(pDrawable); \
761 (pointer) = (ptype *) _pPix->devPrivate.ptr; \
762 (width) = ((int) _pPix->devKind) / sizeof (wtype); \
763}
764
765#define afbGetPixelWidthSizeDepthAndPointer(pDrawable, width, size, dep, pointer) {\
766 PixmapPtr _pPix; \
767 if ((pDrawable)->type == DRAWABLE_WINDOW) \
768 _pPix = (PixmapPtr)dixLookupPrivate(&(pDrawable)->pScreen->devPrivates, afbScreenPrivateKey); \
769 else \
770 _pPix = (PixmapPtr)(pDrawable); \
771 (pointer) = (PixelType *)_pPix->devPrivate.ptr; \
772 (width) = ((int)_pPix->devKind) / sizeof (PixelType); \
773 (size) = (width) * _pPix->drawable.height; \
774 (dep) = _pPix->drawable.depth; (void)(dep); \
775}
776
777#define afbGetByteWidthAndPointer(pDrawable, width, pointer) \
778 afbGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned char, unsigned char)
779
780#define afbGetPixelWidthAndPointer(pDrawable, width, pointer) \
781 afbGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
782
783#define afbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
784 PixmapPtr _pPix = (PixmapPtr)dixLookupPrivate(&(pWin)->drawable.pScreen->devPrivates, afbScreenPrivateKey); \
785 (pointer) = (ptype *) _pPix->devPrivate.ptr; \
786 (width) = ((int) _pPix->devKind) / sizeof (wtype); \
787}
788
789#define afbGetWindowPixelWidthAndPointer(pWin, width, pointer) \
790 afbGetWindowTypedWidthAndPointer(pWin, width, pointer, PixelType, PixelType)
791
792#define afbGetWindowByteWidthAndPointer(pWin, width, pointer) \
793 afbGetWindowTypedWidthAndPointer(pWin, width, pointer, char, char)
794
795/* afb uses the following macros to calculate addresses in drawables.
796 * To support banked framebuffers, the macros come in four flavors.
797 * All four collapse into the same definition on unbanked devices.
798 *
799 * afbScanlineFoo - calculate address and do bank switching
800 * afbScanlineFooNoBankSwitch - calculate address, don't bank switch
801 * afbScanlineFooSrc - calculate address, switch source bank
802 * afbScanlineFooDst - calculate address, switch destination bank
803 */
804
805/* The NoBankSwitch versions are the same for banked and unbanked cases */
806
807#define afbScanlineIncNoBankSwitch(_ptr, _off) _ptr += (_off)
808#define afbScanlineOffsetNoBankSwitch(_ptr, _off) ((_ptr) + (_off))
809#define afbScanlineDeltaNoBankSwitch(_ptr, _y, _w) \
810 afbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w))
811#define afbScanlineNoBankSwitch(_ptr, _x, _y, _w) \
812 afbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
813
814#ifdef MFB_LINE_BANK
815
816#include "afblinebank.h" /* get macro definitions from this file */
817
818#else /* !MFB_LINE_BANK - unbanked case */
819
820#define afbScanlineInc(_ptr, _off) afbScanlineIncNoBankSwitch(_ptr, _off)
821#define afbScanlineIncSrc(_ptr, _off) afbScanlineInc(_ptr, _off)
822#define afbScanlineIncDst(_ptr, _off) afbScanlineInc(_ptr, _off)
823
824#define afbScanlineOffset(_ptr, _off) afbScanlineOffsetNoBankSwitch(_ptr, _off)
825#define afbScanlineOffsetSrc(_ptr, _off) afbScanlineOffset(_ptr, _off)
826#define afbScanlineOffsetDst(_ptr, _off) afbScanlineOffset(_ptr, _off)
827
828#define afbScanlineSrc(_ptr, _x, _y, _w) afbScanline(_ptr, _x, _y, _w)
829#define afbScanlineDst(_ptr, _x, _y, _w) afbScanline(_ptr, _x, _y, _w)
830
831#define afbScanlineDeltaSrc(_ptr, _y, _w) afbScanlineDelta(_ptr, _y, _w)
832#define afbScanlineDeltaDst(_ptr, _y, _w) afbScanlineDelta(_ptr, _y, _w)
833
834#endif /* MFB_LINE_BANK */
835
836#define afbScanlineDelta(_ptr, _y, _w) \
837 afbScanlineOffset(_ptr, (_y) * (_w))
838
839#define afbScanline(_ptr, _x, _y, _w) \
840 afbScanlineOffset(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
841
842/* precomputed information about each glyph for GlyphBlt code.
843 this saves recalculating the per glyph information for each box.
844*/
845
846typedef struct _afbpos{
847 int xpos; /* xposition of glyph's origin */
848 int xchar; /* x position mod 32 */
849 int leftEdge;
850 int rightEdge;
851 int topEdge;
852 int bottomEdge;
853 PixelType *pdstBase; /* longword with character origin */
854 int widthGlyph; /* width in bytes of this glyph */
855} afbTEXTPOS;
856
857/* reduced raster ops for afb */
858#define RROP_BLACK GXclear
859#define RROP_WHITE GXset
860#define RROP_NOP GXnoop
861#define RROP_INVERT GXinvert
862#define RROP_COPY GXcopy
863
864/* macros for afbbitblt.c, afbfillsp.c
865 these let the code do one switch on the rop per call, rather
866 than a switch on the rop per item (span or rectangle.)
867*/
868
869#define fnCLEAR(src, dst) (0)
870#define fnAND(src, dst) (src & dst)
871#define fnANDREVERSE(src, dst) (src & ~dst)
872#define fnCOPY(src, dst) (src)
873#define fnANDINVERTED(src, dst) (~src & dst)
874#define fnNOOP(src, dst) (dst)
875#define fnXOR(src, dst) (src ^ dst)
876#define fnOR(src, dst) (src | dst)
877#define fnNOR(src, dst) (~(src | dst))
878#define fnEQUIV(src, dst) (~src ^ dst)
879#define fnINVERT(src, dst) (~dst)
880#define fnORREVERSE(src, dst) (src | ~dst)
881#define fnCOPYINVERTED(src, dst) (~src)
882#define fnORINVERTED(src, dst) (~src | dst)
883#define fnNAND(src, dst) (~(src & dst))
884#undef fnSET
885#define fnSET(src, dst) (~0)
886
887/* Using a "switch" statement is much faster in most cases
888 * since the compiler can do a look-up table or multi-way branch
889 * instruction, depending on the architecture. The result on
890 * A Sun 3/50 is at least 2.5 times faster, assuming a uniform
891 * distribution of RasterOp operation types.
892 *
893 * However, doing some profiling on a running system reveals
894 * GXcopy is the operation over 99.5% of the time and
895 * GXxor is the next most frequent (about .4%), so we make special
896 * checks for those first.
897 *
898 * Note that this requires a change to the "calling sequence"
899 * since we can't engineer a "switch" statement to have an lvalue.
900 */
901#undef DoRop
902#define DoRop(result, alu, src, dst) \
903{ \
904 if (alu == GXcopy) \
905 result = fnCOPY (src, dst); \
906 else if (alu == GXxor) \
907 result = fnXOR (src, dst); \
908 else \
909 switch (alu) { \
910 case GXclear: \
911 result = fnCLEAR (src, dst); \
912 break; \
913 case GXand: \
914 result = fnAND (src, dst); \
915 break; \
916 case GXandReverse: \
917 result = fnANDREVERSE (src, dst); \
918 break; \
919 case GXandInverted: \
920 result = fnANDINVERTED (src, dst); \
921 break; \
922 default: \
923 case GXnoop: \
924 result = fnNOOP (src, dst); \
925 break; \
926 case GXor: \
927 result = fnOR (src, dst); \
928 break; \
929 case GXnor: \
930 result = fnNOR (src, dst); \
931 break; \
932 case GXequiv: \
933 result = fnEQUIV (src, dst); \
934 break; \
935 case GXinvert: \
936 result = fnINVERT (src, dst); \
937 break; \
938 case GXorReverse: \
939 result = fnORREVERSE (src, dst); \
940 break; \
941 case GXcopyInverted: \
942 result = fnCOPYINVERTED (src, dst); \
943 break; \
944 case GXorInverted: \
945 result = fnORINVERTED (src, dst); \
946 break; \
947 case GXnand: \
948 result = fnNAND (src, dst); \
949 break; \
950 case GXset: \
951 result = fnSET (src, dst); \
952 break; \
953 } \
954}
955
956
957/* C expression fragments for various operations. These get passed in
958 * as -D's on the compile command line. See afb/Imakefile. This
959 * fixes XBUG 6319.
960 *
961 * This seems like a good place to point out that afb's use of the
962 * words black and white is an unfortunate misnomer. In afb code, black
963 * means zero, and white means one.
964 */
965#define MFB_OPEQ_WHITE |=
966#define MFB_OPEQ_BLACK &=~
967#define MFB_OPEQ_INVERT ^=
968#define MFB_EQWHOLEWORD_WHITE =~0
969#define MFB_EQWHOLEWORD_BLACK =0
970#define MFB_EQWHOLEWORD_INVERT ^=~0
971#define MFB_OP_WHITE /* nothing */
972#define MFB_OP_BLACK ~
diff --git a/afb/afbbitblt.c b/afb/afbbitblt.c
deleted file mode 100644
index d8b2ccda5..000000000
--- a/afb/afbbitblt.c
+++ /dev/null
@@ -1,343 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <stdlib.h>
55
56#include <X11/X.h>
57#include <X11/Xprotostr.h>
58
59#include "regionstr.h"
60#include "gcstruct.h"
61#include "windowstr.h"
62#include "pixmapstr.h"
63#include "scrnintstr.h"
64
65#include "mi.h"
66
67#include "afb.h"
68#include "maskbits.h"
69
70/* CopyArea and CopyPlane for a monchrome frame buffer
71
72
73 clip the source rectangle to the source's available bits. (this
74avoids copying unnecessary pieces that will just get exposed anyway.)
75this becomes the new shape of the destination.
76 clip the destination region to the composite clip in the
77GC. this requires translating the destination region to (dstx, dsty).
78 build a list of source points, one for each rectangle in the
79destination. this is a simple translation.
80 go do the multiple rectangle copies
81 do graphics exposures
82*/
83/** Optimized for drawing pixmaps into windows, especially when drawing into
84 ** unobscured windows. Calls to the general-purpose region code were
85 ** replaced with rectangle-to-rectangle clipping comparisions. This is
86 ** possible, since the pixmap is a single rectangle. In an unobscured
87 ** window, the destination clip is also a single rectangle, and region
88 ** code can be avoided entirely. This is a big savings, since the region
89 ** code uses XAlloc() and makes many function calls.
90 **
91 ** In addition, if source is a pixmap, there is no need to call the
92 ** expensive miHandleExposures() routine. Instead, we simply return NULL.
93 **
94 ** Previously, drawing a pixmap into an unobscured window executed at least
95 ** 8 XAlloc()'s, 30 function calls, and hundreds of lines of code.
96 **
97 ** Now, the same operation requires no XAlloc()'s, no region function calls,
98 ** and much less overhead. Nice for drawing lots of small pixmaps.
99 */
100
101void
102afbDoBitblt(DrawablePtr pSrc, DrawablePtr pDst, int alu, RegionPtr prgnDst, DDXPointPtr pptSrc, long unsigned int planemask)
103{
104 switch (alu) {
105 case GXcopy:
106 afbDoBitbltCopy(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
107 break;
108 case GXxor:
109 afbDoBitbltXor(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
110 break;
111 case GXcopyInverted:
112 afbDoBitbltCopyInverted(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
113 break;
114 case GXor:
115 afbDoBitbltOr(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
116 break;
117 default:
118 afbDoBitbltGeneral(pSrc, pDst, alu, prgnDst, pptSrc, planemask);
119 break;
120 }
121}
122
123typedef void (*afb_blit_func)
124 (DrawablePtr, DrawablePtr, int, RegionPtr, DDXPointPtr, unsigned long);
125
126static RegionPtr
127afbBitBlt(register DrawablePtr pSrcDrawable, register DrawablePtr pDstDrawable, register GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty, afb_blit_func doBitBlt, long unsigned int planemask)
128{
129 RegionPtr prgnSrcClip = NULL; /* may be a new region, or just a copy */
130 Bool freeSrcClip = FALSE;
131
132 RegionPtr prgnExposed;
133 RegionRec rgnDst;
134 DDXPointPtr pptSrc;
135 register DDXPointPtr ppt;
136 register BoxPtr pbox;
137 int i;
138 register int dx;
139 register int dy;
140 xRectangle origSource;
141 DDXPointRec origDest;
142 int numRects;
143 BoxRec fastBox;
144 int fastClip = 0; /* for fast clipping with pixmap source */
145 int fastExpose = 0; /* for fast exposures with pixmap source */
146
147 origSource.x = srcx;
148 origSource.y = srcy;
149 origSource.width = width;
150 origSource.height = height;
151 origDest.x = dstx;
152 origDest.y = dsty;
153
154 if ((pSrcDrawable != pDstDrawable) && pSrcDrawable->pScreen->SourceValidate)
155 (*pSrcDrawable->pScreen->SourceValidate)(pSrcDrawable, srcx, srcy, width,
156 height);
157
158 srcx += pSrcDrawable->x;
159 srcy += pSrcDrawable->y;
160
161 /* clip the source */
162
163 if (pSrcDrawable->type == DRAWABLE_PIXMAP)
164 if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
165 prgnSrcClip = pGC->pCompositeClip;
166 else
167 fastClip = 1;
168 else if (pGC->subWindowMode == IncludeInferiors)
169 if (!((WindowPtr)pSrcDrawable)->parent)
170 /*
171 * special case bitblt from root window in
172 * IncludeInferiors mode; just like from a pixmap
173 */
174 fastClip = 1;
175 else if ((pSrcDrawable == pDstDrawable) && (pGC->clientClipType == CT_NONE))
176 prgnSrcClip = pGC->pCompositeClip;
177 else {
178 prgnSrcClip = NotClippedByChildren((WindowPtr)pSrcDrawable);
179 freeSrcClip = TRUE;
180 }
181 else
182 prgnSrcClip = &((WindowPtr)pSrcDrawable)->clipList;
183
184 fastBox.x1 = srcx;
185 fastBox.y1 = srcy;
186 fastBox.x2 = srcx + width;
187 fastBox.y2 = srcy + height;
188
189 /* Don't create a source region if we are doing a fast clip */
190 if (fastClip) {
191 fastExpose = 1;
192 /*
193 * clip the source; if regions extend beyond the source size,
194 * make sure exposure events get sent
195 */
196 if (fastBox.x1 < pSrcDrawable->x) {
197 fastBox.x1 = pSrcDrawable->x;
198 fastExpose = 0;
199 }
200 if (fastBox.y1 < pSrcDrawable->y) {
201 fastBox.y1 = pSrcDrawable->y;
202 fastExpose = 0;
203 }
204 if (fastBox.x2 > pSrcDrawable->x + (int)pSrcDrawable->width) {
205 fastBox.x2 = pSrcDrawable->x + (int)pSrcDrawable->width;
206 fastExpose = 0;
207 }
208 if (fastBox.y2 > pSrcDrawable->y + (int)pSrcDrawable->height) {
209 fastBox.y2 = pSrcDrawable->y + (int)pSrcDrawable->height;
210 fastExpose = 0;
211 }
212 } else {
213 REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
214 REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst, prgnSrcClip);
215 }
216
217 dstx += pDstDrawable->x;
218 dsty += pDstDrawable->y;
219
220 if (pDstDrawable->type == DRAWABLE_WINDOW)
221 if (!((WindowPtr)pDstDrawable)->realized) {
222 if (!fastClip)
223 REGION_UNINIT(pGC->pScreen, &rgnDst);
224 if (freeSrcClip)
225 REGION_DESTROY(pGC->pScreen, prgnSrcClip);
226 return NULL;
227 }
228
229 dx = srcx - dstx;
230 dy = srcy - dsty;
231
232 /* Translate and clip the dst to the destination composite clip */
233 if (fastClip) {
234 RegionPtr cclip;
235
236 /* Translate the region directly */
237 fastBox.x1 -= dx;
238 fastBox.x2 -= dx;
239 fastBox.y1 -= dy;
240 fastBox.y2 -= dy;
241
242 /* If the destination composite clip is one rectangle we can
243 do the clip directly. Otherwise we have to create a full
244 blown region and call intersect */
245 cclip = pGC->pCompositeClip;
246 if (REGION_NUM_RECTS(cclip) == 1) {
247 BoxPtr pBox = REGION_RECTS(cclip);
248
249 if (fastBox.x1 < pBox->x1)
250 fastBox.x1 = pBox->x1;
251 if (fastBox.x2 > pBox->x2)
252 fastBox.x2 = pBox->x2;
253 if (fastBox.y1 < pBox->y1)
254 fastBox.y1 = pBox->y1;
255 if (fastBox.y2 > pBox->y2)
256 fastBox.y2 = pBox->y2;
257
258 /* Check to see if the region is empty */
259 if (fastBox.x1 >= fastBox.x2 || fastBox.y1 >= fastBox.y2) {
260 REGION_NULL(pGC->pScreen, &rgnDst);
261 } else {
262 REGION_INIT(pGC->pScreen, &rgnDst, &fastBox, 1);
263 }
264 } else {
265 /* We must turn off fastClip now, since we must create
266 a full blown region. It is intersected with the
267 composite clip below. */
268 fastClip = 0;
269 REGION_INIT(pGC->pScreen, &rgnDst, &fastBox,1);
270 }
271 } else
272 REGION_TRANSLATE(pGC->pScreen, &rgnDst, -dx, -dy);
273
274 if (!fastClip) {
275 REGION_INTERSECT(pGC->pScreen, &rgnDst, &rgnDst,
276 pGC->pCompositeClip);
277 }
278
279 /* Do bit blitting */
280 numRects = REGION_NUM_RECTS(&rgnDst);
281 if (numRects && width && height) {
282 if(!(pptSrc = (DDXPointPtr)xalloc(numRects *
283 sizeof(DDXPointRec)))) {
284 REGION_UNINIT(pGC->pScreen, &rgnDst);
285 if (freeSrcClip)
286 REGION_DESTROY(pGC->pScreen, prgnSrcClip);
287 return NULL;
288 }
289 pbox = REGION_RECTS(&rgnDst);
290 ppt = pptSrc;
291 for (i = numRects; --i >= 0; pbox++, ppt++) {
292 ppt->x = pbox->x1 + dx;
293 ppt->y = pbox->y1 + dy;
294 }
295
296 (*doBitBlt)(pSrcDrawable, pDstDrawable, pGC->alu, &rgnDst, pptSrc,
297 planemask);
298
299 xfree(pptSrc);
300 }
301
302 prgnExposed = NULL;
303 if (pGC->fExpose) {
304 /* Pixmap sources generate a NoExposed (we return NULL to do this) */
305 if (!fastExpose)
306 prgnExposed = miHandleExposures(pSrcDrawable, pDstDrawable, pGC,
307 origSource.x, origSource.y,
308 (int)origSource.width,
309 (int)origSource.height, origDest.x,
310 origDest.y, (unsigned long)0);
311 }
312 REGION_UNINIT(pGC->pScreen, &rgnDst);
313 if (freeSrcClip)
314 REGION_DESTROY(pGC->pScreen, prgnSrcClip);
315 return prgnExposed;
316}
317
318RegionPtr
319afbCopyArea(DrawablePtr pSrcDrawable, DrawablePtr pDstDrawable, GC *pGC, int srcx, int srcy, int width, int height, int dstx, int dsty)
320{
321 afb_blit_func doBitBlt;
322
323 switch (pGC->alu) {
324 case GXcopy:
325 doBitBlt = afbDoBitbltCopy;
326 break;
327 case GXxor:
328 doBitBlt = afbDoBitbltXor;
329 break;
330 case GXcopyInverted:
331 doBitBlt = afbDoBitbltCopyInverted;
332 break;
333 case GXor:
334 doBitBlt = afbDoBitbltOr;
335 break;
336 default:
337 doBitBlt = afbDoBitbltGeneral;
338 break;
339 }
340
341 return(afbBitBlt(pSrcDrawable, pDstDrawable, pGC, srcx, srcy,
342 width, height, dstx, dsty, doBitBlt, pGC->planemask));
343}
diff --git a/afb/afbblt.c b/afb/afbblt.c
deleted file mode 100644
index 4e1a49e9d..000000000
--- a/afb/afbblt.c
+++ /dev/null
@@ -1,563 +0,0 @@
1/*
2 * afb copy area
3 */
4
5/*
6
7Copyright (c) 1989 X Consortium
8
9Permission is hereby granted, free of charge, to any person obtaining a copy
10of this software and associated documentation files (the "Software"), to deal
11in the Software without restriction, including without limitation the rights
12to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13copies of the Software, and to permit persons to whom the Software is
14furnished to do so, subject to the following conditions:
15
16The above copyright notice and this permission notice shall be included in
17all copies or substantial portions of the Software.
18
19THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
22X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25
26Except as contained in this notice, the name of the X Consortium shall not be
27used in advertising or otherwise to promote the sale, use or other dealings
28in this Software without prior written authorization from the X Consortium.
29
30Author: Keith Packard
31
32*/
33
34#ifdef HAVE_DIX_CONFIG_H
35#include <dix-config.h>
36#endif
37
38#include <stdlib.h>
39
40#include <X11/X.h>
41#include <X11/Xmd.h>
42#include <X11/Xproto.h>
43#include "afb.h"
44#include "gcstruct.h"
45#include "windowstr.h"
46#include "scrnintstr.h"
47#include "pixmapstr.h"
48#include "regionstr.h"
49#include "maskbits.h"
50#include "fastblt.h"
51#include "mergerop.h"
52
53void
54MROP_NAME(afbDoBitblt)(pSrc, pDst, alu, prgnDst, pptSrc, planemask)
55 DrawablePtr pSrc, pDst;
56 int alu;
57 RegionPtr prgnDst;
58 DDXPointPtr pptSrc;
59 unsigned long planemask;
60{
61 PixelType *psrcBase, *pdstBase; /* start of src and dst bitmaps */
62 int widthSrc, widthDst; /* add to get to same position in next line */
63 int sizeSrc, sizeDst;
64
65 BoxPtr pbox;
66 int nbox;
67
68 BoxPtr pboxTmp, pboxNext, pboxBase, pboxNew1, pboxNew2;
69 /* temporaries for shuffling rectangles */
70 DDXPointPtr pptTmp, pptNew1, pptNew2;
71 /* shuffling boxes entails shuffling the
72 source points too */
73 int w, h;
74 int xdir; /* 1 = left right, -1 = right left/ */
75 int ydir; /* 1 = top down, -1 = bottom up */
76
77 PixelType *psrcLine, *pdstLine;
78 /* pointers to line with current src and dst */
79 register PixelType *psrc; /* pointer to current src longword */
80 register PixelType *pdst; /* pointer to current dst longword */
81
82 MROP_DECLARE_REG()
83
84 /* following used for looping through a line */
85 PixelType startmask, endmask; /* masks for writing ends of dst */
86 int nlMiddle; /* whole longwords in dst */
87 int xoffSrc, xoffDst;
88 register int leftShift, rightShift;
89 register PixelType bits;
90 register PixelType bits1;
91 register int nl; /* temp copy of nlMiddle */
92
93 int careful;
94 int depthSrc;
95 int depthDst;
96
97 MROP_INITIALIZE(alu,0);
98
99 afbGetPixelWidthSizeDepthAndPointer(pSrc, widthSrc, sizeSrc, depthSrc,
100 psrcBase);
101 afbGetPixelWidthSizeDepthAndPointer(pDst, widthDst, sizeDst, depthDst,
102 pdstBase);
103
104 /* Special case where depth of dest pixmap is 1 but source pixmap isn't
105 * Used for GetImage to copy a plane from a source pixmap to a particular
106 * dest pixmap plane.
107 * Note: planemask should have only one bit set or several planes from
108 * the source will be copied to the same dest plane.
109 */
110 if (depthDst == 1 && depthDst != depthSrc)
111 sizeDst = 0;
112
113 /* XXX we have to err on the side of safety when both are windows,
114 * because we don't know if IncludeInferiors is being used.
115 */
116 careful = ((pSrc == pDst) ||
117 ((pSrc->type == DRAWABLE_WINDOW) &&
118 (pDst->type == DRAWABLE_WINDOW)));
119
120 pbox = REGION_RECTS(prgnDst);
121 nbox = REGION_NUM_RECTS(prgnDst);
122
123 pboxNew1 = NULL;
124 pptNew1 = NULL;
125 pboxNew2 = NULL;
126 pptNew2 = NULL;
127 if (careful && (pptSrc->y < pbox->y1)) {
128 /* walk source botttom to top */
129 ydir = -1;
130 widthSrc = -widthSrc;
131 widthDst = -widthDst;
132
133 if (nbox > 1) {
134 /* keep ordering in each band, reverse order of bands */
135 pboxNew1 = (BoxPtr)xalloc(sizeof(BoxRec)*nbox);
136 if(!pboxNew1)
137 return;
138 pptNew1 = (DDXPointPtr)xalloc(sizeof(DDXPointRec)*nbox);
139 if(!pptNew1) {
140 xfree(pboxNew1);
141 return;
142 }
143 pboxBase = pboxNext = pbox+nbox-1;
144 while (pboxBase >= pbox) {
145 while ((pboxNext >= pbox) &&
146 (pboxBase->y1 == pboxNext->y1))
147 pboxNext--;
148 pboxTmp = pboxNext+1;
149 pptTmp = pptSrc + (pboxTmp - pbox);
150 while (pboxTmp <= pboxBase) {
151 *pboxNew1++ = *pboxTmp++;
152 *pptNew1++ = *pptTmp++;
153 }
154 pboxBase = pboxNext;
155 }
156 pboxNew1 -= nbox;
157 pbox = pboxNew1;
158 pptNew1 -= nbox;
159 pptSrc = pptNew1;
160 }
161 } else {
162 /* walk source top to bottom */
163 ydir = 1;
164 }
165
166 if (careful && (pptSrc->x < pbox->x1)) {
167 /* walk source right to left */
168 xdir = -1;
169
170 if (nbox > 1) {
171 /* reverse order of rects in each band */
172 pboxNew2 = (BoxPtr)xalloc(sizeof(BoxRec) * nbox);
173 pptNew2 = (DDXPointPtr)xalloc(sizeof(DDXPointRec) * nbox);
174 if(!pboxNew2 || !pptNew2) {
175 if (pptNew2)
176 xfree(pptNew2);
177 if (pboxNew2)
178 xfree(pboxNew2);
179 if (pboxNew1) {
180 xfree(pptNew1);
181 xfree(pboxNew1);
182 }
183 return;
184 }
185 pboxBase = pboxNext = pbox;
186 while (pboxBase < pbox+nbox) {
187 while ((pboxNext < pbox+nbox) && (pboxNext->y1 == pboxBase->y1))
188 pboxNext++;
189 pboxTmp = pboxNext;
190 pptTmp = pptSrc + (pboxTmp - pbox);
191 while (pboxTmp != pboxBase) {
192 *pboxNew2++ = *--pboxTmp;
193 *pptNew2++ = *--pptTmp;
194 }
195 pboxBase = pboxNext;
196 }
197 pboxNew2 -= nbox;
198 pbox = pboxNew2;
199 pptNew2 -= nbox;
200 pptSrc = pptNew2;
201 }
202 } else {
203 /* walk source left to right */
204 xdir = 1;
205 }
206
207 while(nbox--) {
208 int d;
209 for (d = 0; d < depthSrc; d++) {
210 PixelType *psrcB;
211 PixelType *pdstB;
212
213 if (!(planemask & (1 << d)))
214 continue;
215
216 psrcB = psrcBase + sizeSrc * d; /* @@@ NEXT PLANE @@@ */
217 pdstB = pdstBase + sizeDst * d; /* @@@ NEXT PLANE @@@ */
218
219 w = pbox->x2 - pbox->x1;
220 h = pbox->y2 - pbox->y1;
221
222 if (ydir == -1) { /* start at last scanline of rectangle */
223 psrcLine = afbScanlineDeltaSrc(psrcB, -(pptSrc->y+h-1), widthSrc);
224 pdstLine = afbScanlineDeltaDst(pdstB, -(pbox->y2-1), widthDst);
225 } else { /* start at first scanline */
226 psrcLine = afbScanlineDeltaSrc(psrcB, pptSrc->y, widthSrc);
227 pdstLine = afbScanlineDeltaDst(pdstB, pbox->y1, widthDst);
228 }
229 if ((pbox->x1 & PIM) + w <= PPW) {
230 maskpartialbits (pbox->x1, w, startmask);
231 endmask = 0;
232 nlMiddle = 0;
233 } else {
234 maskbits(pbox->x1, w, startmask, endmask, nlMiddle);
235 }
236 if (xdir == 1) {
237 xoffSrc = pptSrc->x & PIM;
238 xoffDst = pbox->x1 & PIM;
239 pdstLine += (pbox->x1 >> PWSH);
240 psrcLine += (pptSrc->x >> PWSH);
241#ifdef DO_UNALIGNED_BITBLT
242 nl = xoffSrc - xoffDst;
243 psrcLine = (PixelType *)(((unsigned char *) psrcLine) + nl);
244#else
245 if (xoffSrc == xoffDst)
246#endif
247 {
248 while (h--) {
249 psrc = psrcLine;
250 pdst = pdstLine;
251 if (startmask) {
252 *pdst = MROP_MASK(*psrc, *pdst, startmask);
253 psrc++;
254 pdst++;
255 }
256 nl = nlMiddle;
257
258#ifdef LARGE_INSTRUCTION_CACHE
259#ifdef FAST_CONSTANT_OFFSET_MODE
260
261 psrc += nl & (UNROLL-1);
262 pdst += nl & (UNROLL-1);
263
264#define BodyOdd(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
265#define BodyEven(n) pdst[-n] = MROP_SOLID (psrc[-n], pdst[-n]);
266
267#define LoopReset \
268pdst += UNROLL; \
269psrc += UNROLL;
270
271#else
272
273#define BodyOdd(n) *pdst = MROP_SOLID (*psrc, *pdst); pdst++; psrc++;
274#define BodyEven(n) BodyOdd(n)
275
276#define LoopReset ;
277
278#endif
279 PackedLoop
280
281#undef BodyOdd
282#undef BodyEven
283#undef LoopReset
284
285#else
286#ifdef NOTDEF
287 /* you'd think this would be faster --
288 * a single instruction instead of 6
289 * but measurements show it to be ~15% slower
290 */
291 while ((nl -= 6) >= 0) {
292 asm ("moveml %1+,#0x0c0f;moveml#0x0c0f,%0"
293 : "=m" (*(char *)pdst)
294 : "m" (*(char *)psrc)
295 : "d0", "d1", "d2", "d3",
296 "a2", "a3");
297 pdst += 6;
298 }
299 nl += 6;
300 while (nl--)
301 *pdst++ = *psrc++;
302#endif
303 DuffL(nl, label1,
304 *pdst = MROP_SOLID (*psrc, *pdst);
305 pdst++; psrc++;)
306#endif
307
308 if (endmask)
309 *pdst = MROP_MASK(*psrc, *pdst, endmask);
310 afbScanlineIncDst(pdstLine, widthDst);
311 afbScanlineIncSrc(psrcLine, widthSrc);
312 }
313 }
314#ifndef DO_UNALIGNED_BITBLT
315 else {
316 if (xoffSrc > xoffDst) {
317 leftShift = (xoffSrc - xoffDst);
318 rightShift = PPW - leftShift;
319 } else {
320 rightShift = (xoffDst - xoffSrc);
321 leftShift = PPW - rightShift;
322 }
323 while (h--) {
324 psrc = psrcLine;
325 pdst = pdstLine;
326 bits = 0;
327 if (xoffSrc > xoffDst)
328 bits = *psrc++;
329 if (startmask) {
330 bits1 = BitLeft(bits,leftShift);
331 bits = *psrc++;
332 bits1 |= BitRight(bits,rightShift);
333 *pdst = MROP_MASK(bits1, *pdst, startmask);
334 pdst++;
335 }
336 nl = nlMiddle;
337
338#ifdef LARGE_INSTRUCTION_CACHE
339 bits1 = bits;
340
341#ifdef FAST_CONSTANT_OFFSET_MODE
342
343 psrc += nl & (UNROLL-1);
344 pdst += nl & (UNROLL-1);
345
346#define BodyOdd(n) \
347bits = psrc[-n]; \
348pdst[-n] = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), pdst[-n]);
349
350#define BodyEven(n) \
351bits1 = psrc[-n]; \
352pdst[-n] = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), pdst[-n]);
353
354#define LoopReset \
355pdst += UNROLL; \
356psrc += UNROLL;
357
358#else
359
360#define BodyOdd(n) \
361bits = *psrc++; \
362*pdst = MROP_SOLID(BitLeft(bits1, leftShift) | BitRight(bits, rightShift), *pdst); \
363pdst++;
364
365#define BodyEven(n) \
366bits1 = *psrc++; \
367*pdst = MROP_SOLID(BitLeft(bits, leftShift) | BitRight(bits1, rightShift), *pdst); \
368pdst++;
369
370#define LoopReset ;
371
372#endif /* !FAST_CONSTANT_OFFSET_MODE */
373
374 PackedLoop
375
376#undef BodyOdd
377#undef BodyEven
378#undef LoopReset
379
380#else
381 DuffL(nl,label2,
382 bits1 = BitLeft(bits, leftShift);
383 bits = *psrc++;
384 *pdst = MROP_SOLID (bits1 | BitRight(bits, rightShift), *pdst);
385 pdst++;
386 )
387#endif
388
389 if (endmask) {
390 bits1 = BitLeft(bits, leftShift);
391 if (BitLeft(endmask, rightShift)) {
392 bits = *psrc;
393 bits1 |= BitRight(bits, rightShift);
394 }
395 *pdst = MROP_MASK (bits1, *pdst, endmask);
396 }
397 afbScanlineIncDst(pdstLine, widthDst);
398 afbScanlineIncSrc(psrcLine, widthSrc);
399 }
400 }
401#endif /* DO_UNALIGNED_BITBLT */
402 } else { /* xdir == -1 */
403 xoffSrc = (pptSrc->x + w - 1) & PIM;
404 xoffDst = (pbox->x2 - 1) & PIM;
405 pdstLine += ((pbox->x2-1) >> PWSH) + 1;
406 psrcLine += ((pptSrc->x+w - 1) >> PWSH) + 1;
407#ifdef DO_UNALIGNED_BITBLT
408 nl = xoffSrc - xoffDst;
409 psrcLine = (PixelType *)
410 (((unsigned char *) psrcLine) + nl);
411#else
412 if (xoffSrc == xoffDst)
413#endif
414 {
415 while (h--) {
416 psrc = psrcLine;
417 pdst = pdstLine;
418 if (endmask) {
419 pdst--;
420 psrc--;
421 *pdst = MROP_MASK (*psrc, *pdst, endmask);
422 }
423 nl = nlMiddle;
424
425#ifdef LARGE_INSTRUCTION_CACHE
426#ifdef FAST_CONSTANT_OFFSET_MODE
427 psrc -= nl & (UNROLL - 1);
428 pdst -= nl & (UNROLL - 1);
429
430#define BodyOdd(n) pdst[n-1] = MROP_SOLID (psrc[n-1], pdst[n-1]);
431
432#define BodyEven(n) BodyOdd(n)
433
434#define LoopReset \
435pdst -= UNROLL;\
436psrc -= UNROLL;
437
438#else
439
440#define BodyOdd(n) --pdst; --psrc; *pdst = MROP_SOLID(*psrc, *pdst);
441#define BodyEven(n) BodyOdd(n)
442#define LoopReset ;
443
444#endif
445 PackedLoop
446
447#undef BodyOdd
448#undef BodyEven
449#undef LoopReset
450
451#else
452 DuffL(nl,label3,
453 --pdst; --psrc; *pdst = MROP_SOLID (*psrc, *pdst);)
454#endif
455
456 if (startmask) {
457 --pdst;
458 --psrc;
459 *pdst = MROP_MASK(*psrc, *pdst, startmask);
460 }
461 afbScanlineIncDst(pdstLine, widthDst);
462 afbScanlineIncSrc(psrcLine, widthSrc);
463 }
464 }
465#ifndef DO_UNALIGNED_BITBLT
466 else {
467 if (xoffDst > xoffSrc) {
468 rightShift = (xoffDst - xoffSrc);
469 leftShift = PPW - rightShift;
470 } else {
471 leftShift = (xoffSrc - xoffDst);
472 rightShift = PPW - leftShift;
473 }
474 while (h--) {
475 psrc = psrcLine;
476 pdst = pdstLine;
477 bits = 0;
478 if (xoffDst > xoffSrc)
479 bits = *--psrc;
480 if (endmask) {
481 bits1 = BitRight(bits, rightShift);
482 bits = *--psrc;
483 bits1 |= BitLeft(bits, leftShift);
484 pdst--;
485 *pdst = MROP_MASK(bits1, *pdst, endmask);
486 }
487 nl = nlMiddle;
488
489#ifdef LARGE_INSTRUCTION_CACHE
490 bits1 = bits;
491#ifdef FAST_CONSTANT_OFFSET_MODE
492 psrc -= nl & (UNROLL - 1);
493 pdst -= nl & (UNROLL - 1);
494
495#define BodyOdd(n) \
496bits = psrc[n-1]; \
497pdst[n-1] = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),pdst[n-1]);
498
499#define BodyEven(n) \
500bits1 = psrc[n-1]; \
501pdst[n-1] = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),pdst[n-1]);
502
503#define LoopReset \
504pdst -= UNROLL; \
505psrc -= UNROLL;
506
507#else
508
509#define BodyOdd(n) \
510bits = *--psrc; --pdst; \
511*pdst = MROP_SOLID(BitRight(bits1, rightShift) | BitLeft(bits, leftShift),*pdst);
512
513#define BodyEven(n) \
514bits1 = *--psrc; --pdst; \
515*pdst = MROP_SOLID(BitRight(bits, rightShift) | BitLeft(bits1, leftShift),*pdst);
516
517#define LoopReset ;
518
519#endif
520
521 PackedLoop
522
523#undef BodyOdd
524#undef BodyEven
525#undef LoopReset
526
527#else
528 DuffL(nl, label4,
529 bits1 = BitRight(bits, rightShift);
530 bits = *--psrc;
531 --pdst;
532 *pdst = MROP_SOLID(bits1 | BitLeft(bits, leftShift),*pdst);
533 )
534#endif
535
536 if (startmask) {
537 bits1 = BitRight(bits, rightShift);
538 if (BitRight (startmask, leftShift)) {
539 bits = *--psrc;
540 bits1 |= BitLeft(bits, leftShift);
541 }
542 --pdst;
543 *pdst = MROP_MASK(bits1, *pdst, startmask);
544 }
545 afbScanlineIncDst(pdstLine, widthDst);
546 afbScanlineIncSrc(psrcLine, widthSrc);
547 }
548 }
549#endif
550 }
551 }
552 pbox++;
553 pptSrc++;
554 }
555 if (pboxNew2) {
556 xfree(pptNew2);
557 xfree(pboxNew2);
558 }
559 if (pboxNew1) {
560 xfree(pptNew1);
561 xfree(pboxNew1);
562 }
563}
diff --git a/afb/afbbres.c b/afb/afbbres.c
deleted file mode 100644
index dae4746a0..000000000
--- a/afb/afbbres.c
+++ /dev/null
@@ -1,323 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include "misc.h"
56#include "afb.h"
57#include "maskbits.h"
58#include "miline.h"
59
60/* Solid bresenham line */
61/* NOTES
62 e2 is used less often than e1, so it's not in a register
63*/
64
65void
66afbBresS(addrlbase, nlwidth, sizeDst, depthDst, signdx, signdy, axis, x1, y1,
67 e, e1, e2, len, rrops)
68PixelType *addrlbase; /* pointer to base of bitmap */
69int nlwidth; /* width in longwords of bitmap */
70int sizeDst;
71int depthDst;
72int signdx, signdy; /* signs of directions */
73int axis; /* major axis (Y_AXIS or X_AXIS) */
74int x1, y1; /* initial point */
75register int e; /* error accumulator */
76register int e1; /* bresenham increments */
77int e2;
78int len; /* length of line */
79unsigned char *rrops;
80{
81 register int yinc; /* increment to next scanline, in bytes */
82 register PixelType *addrl; /* bitmask long pointer */
83 register PixelType bit; /* current bit being set/cleared/etc. */
84 PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */
85 PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */
86
87 register int e3 = e2-e1;
88 PixelType tmp;
89 int saveE;
90 int saveLen;
91 int d;
92
93 /* point to longword containing first point */
94 yinc = signdy * nlwidth;
95 e = e-e1; /* to make looping easier */
96
97 if (!len)
98 return;
99
100 saveLen = len;
101 saveE = e;
102
103 for (d = 0; d < depthDst; d++) {
104 addrl = afbScanline(addrlbase, x1, y1, nlwidth);
105 addrlbase += sizeDst; /* @@@ NEXT PLANE @@@ */
106 len = saveLen;
107 e = saveE;
108 bit = mfbGetmask(x1 & PIM);
109
110 switch (rrops[d]) {
111 case RROP_BLACK:
112 if (axis == X_AXIS) {
113 if (signdx > 0) {
114 tmp = *addrl;
115 for (;;) {
116 tmp &= ~bit;
117 if (!--len)
118 break;
119 bit = SCRRIGHT(bit,1);
120 e += e1;
121 if (e >= 0) {
122 *addrl = tmp;
123 afbScanlineInc(addrl, yinc);
124 e += e3;
125 if (!bit) {
126 bit = leftbit;
127 addrl ++;
128 }
129 tmp = *addrl;
130 } else if (!bit) {
131 *addrl = tmp;
132 bit = leftbit;
133 addrl ++;
134 tmp = *addrl;
135 }
136 }
137 *addrl = tmp;
138 } else {
139 tmp = *addrl;
140 for (;;) {
141 tmp &= ~bit;
142 if (!--len)
143 break;
144 e += e1;
145 bit = SCRLEFT(bit,1);
146 if (e >= 0) {
147 *addrl = tmp;
148 afbScanlineInc(addrl, yinc);
149 e += e3;
150 if (!bit) {
151 bit = rightbit;
152 addrl --;
153 }
154 tmp = *addrl;
155 } else if (!bit) {
156 *addrl = tmp;
157 bit = rightbit;
158 addrl --;
159 tmp = *addrl;
160 }
161 }
162 *addrl = tmp;
163 }
164 } /* if X_AXIS */ else {
165 if (signdx > 0) {
166 while(len--) {
167 *addrl &= ~bit;
168 e += e1;
169 if (e >= 0) {
170 bit = SCRRIGHT(bit,1);
171 if (!bit) { bit = leftbit;addrl ++; }
172 e += e3;
173 }
174 afbScanlineInc(addrl, yinc);
175 }
176 } else {
177 while(len--) {
178 *addrl &= ~bit;
179 e += e1;
180 if (e >= 0) {
181 bit = SCRLEFT(bit,1);
182 if (!bit) { bit = rightbit;addrl --; }
183 e += e3;
184 }
185 afbScanlineInc(addrl, yinc);
186 }
187 }
188 } /* else Y_AXIS */
189 break;
190
191 case RROP_WHITE:
192 if (axis == X_AXIS) {
193 if (signdx > 0) {
194 tmp = *addrl;
195 for (;;) {
196 tmp |= bit;
197 if (!--len)
198 break;
199 e += e1;
200 bit = SCRRIGHT(bit,1);
201 if (e >= 0) {
202 *addrl = tmp;
203 afbScanlineInc(addrl, yinc);
204 e += e3;
205 if (!bit) {
206 bit = leftbit;
207 addrl ++;
208 }
209 tmp = *addrl;
210 } else if (!bit) {
211 *addrl = tmp;
212 bit = leftbit;
213 addrl ++;
214 tmp = *addrl;
215 }
216 }
217 *addrl = tmp;
218 } else {
219 tmp = *addrl;
220 for (;;) {
221 tmp |= bit;
222 if (!--len)
223 break;
224 e += e1;
225 bit = SCRLEFT(bit,1);
226 if (e >= 0) {
227 *addrl = tmp;
228 afbScanlineInc(addrl, yinc);
229 e += e3;
230 if (!bit) {
231 bit = rightbit;
232 addrl --;
233 }
234 tmp = *addrl;
235 } else if (!bit) {
236 *addrl = tmp;
237 bit = rightbit;
238 addrl --;
239 tmp = *addrl;
240 }
241 }
242 *addrl = tmp;
243 }
244 } /* if X_AXIS */ else {
245 if (signdx > 0) {
246 while(len--) {
247 *addrl |= bit;
248 e += e1;
249 if (e >= 0) {
250 bit = SCRRIGHT(bit,1);
251 if (!bit) { bit = leftbit;addrl ++; }
252 e += e3;
253 }
254 afbScanlineInc(addrl, yinc);
255 }
256 } else {
257 while(len--) {
258 *addrl |= bit;
259 e += e1;
260 if (e >= 0) {
261 bit = SCRLEFT(bit,1);
262 if (!bit) { bit = rightbit;addrl --; }
263 e += e3;
264 }
265 afbScanlineInc(addrl, yinc);
266 }
267 }
268 } /* else Y_AXIS */
269 break;
270
271 case RROP_INVERT:
272 if (axis == X_AXIS) {
273 if (signdx > 0) {
274 while(len--) {
275 *addrl ^= bit;
276 e += e1;
277 if (e >= 0) {
278 afbScanlineInc(addrl, yinc);
279 e += e3;
280 }
281 bit = SCRRIGHT(bit,1);
282 if (!bit) { bit = leftbit;addrl ++; }
283 }
284 } else {
285 while(len--) {
286 *addrl ^= bit;
287 e += e1;
288 if (e >= 0) {
289 afbScanlineInc(addrl, yinc);
290 e += e3;
291 }
292 bit = SCRLEFT(bit,1);
293 if (!bit) { bit = rightbit;addrl --; }
294 }
295 }
296 } /* if X_AXIS */ else {
297 if (signdx > 0) {
298 while(len--) {
299 *addrl ^= bit;
300 e += e1;
301 if (e >= 0) {
302 bit = SCRRIGHT(bit,1);
303 if (!bit) { bit = leftbit;addrl ++; }
304 e += e3;
305 }
306 afbScanlineInc(addrl, yinc);
307 }
308 } else {
309 while(len--) {
310 *addrl ^= bit;
311 e += e1;
312 if (e >= 0) {
313 bit = SCRLEFT(bit,1);
314 if (!bit) { bit = rightbit; addrl --; }
315 e += e3;
316 }
317 afbScanlineInc(addrl, yinc);
318 }
319 }
320 } /* else Y_AXIS */
321 } /* switch */
322 } /* for (d = ... ) */
323}
diff --git a/afb/afbbresd.c b/afb/afbbresd.c
deleted file mode 100644
index 4f07ede6c..000000000
--- a/afb/afbbresd.c
+++ /dev/null
@@ -1,214 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <X11/X.h>
54#include "misc.h"
55#include "afb.h"
56#include "maskbits.h"
57#include "miline.h"
58
59/* Dashed bresenham line */
60
61#define StepDash\
62 if (!--dashRemaining) { \
63 if (++ dashIndex == numInDashList) \
64 dashIndex = 0; \
65 dashRemaining = pDash[dashIndex]; \
66 rop = fgrop; \
67 if (dashIndex & 1) \
68 rop = bgrop; \
69 }
70
71void
72afbBresD(pdashIndex, pDash, numInDashList, pdashOffset, isDoubleDash,
73 addrlbase, nlwidth, sizeDst, depthDst,
74 signdx, signdy, axis, x1, y1, e, e1, e2, len, rrops, bgrrops)
75int *pdashIndex; /* current dash */
76unsigned char *pDash; /* dash list */
77int numInDashList; /* total length of dash list */
78int *pdashOffset; /* offset into current dash */
79int isDoubleDash;
80PixelType *addrlbase; /* pointer to base of bitmap */
81int nlwidth; /* width in longwords of bitmap */
82int sizeDst;
83int depthDst;
84int signdx, signdy; /* signs of directions */
85int axis; /* major axis (Y_AXIS or X_AXIS) */
86int x1, y1; /* initial point */
87register int e; /* error accumulator */
88register int e1; /* bresenham increments */
89int e2;
90int len; /* length of line */
91unsigned char *rrops;
92unsigned char *bgrrops;
93{
94 register int yinc; /* increment to next scanline, in bytes */
95 register PixelType *addrl;
96 register int e3 = e2-e1;
97 register unsigned long bit;
98 PixelType leftbit = mfbGetmask(0); /* leftmost bit to process in new word */
99 PixelType rightbit = mfbGetmask(PPW-1); /* rightmost bit to process in new word */
100 int dashIndex;
101 int dashOffset;
102 int dashRemaining;
103 int rop;
104 int fgrop;
105 int bgrop;
106 int saveE;
107 int saveLen;
108 int d;
109
110 dashOffset = *pdashOffset;
111 dashIndex = *pdashIndex;
112 dashRemaining = pDash[dashIndex] - dashOffset;
113 /* point to longword containing first point */
114
115 yinc = signdy * nlwidth;
116 e = e-e1; /* to make looping easier */
117
118 saveE = e;
119 saveLen = len;
120
121 for (d = 0; d < depthDst; d++) {
122 addrl = afbScanline(addrlbase, x1, y1, nlwidth);
123 addrlbase += sizeDst; /* @@@ NEXT PLANE @@@ */
124
125 fgrop = rrops[d];
126 bgrop = bgrrops[d];
127
128 e = saveE;
129 len = saveLen;
130 bit = mfbGetmask(x1 & PIM);
131
132 rop = fgrop;
133 if (!isDoubleDash)
134 bgrop = -1;
135 if (dashIndex & 1)
136 rop = bgrop;
137
138 if (axis == X_AXIS) {
139 if (signdx > 0) {
140 while(len--) {
141 if (rop == RROP_BLACK)
142 *addrl &= ~bit;
143 else if (rop == RROP_WHITE)
144 *addrl |= bit;
145 else if (rop == RROP_INVERT)
146 *addrl ^= bit;
147 e += e1;
148 if (e >= 0) {
149 afbScanlineInc(addrl, yinc);
150 e += e3;
151 }
152 bit = SCRRIGHT(bit,1);
153 if (!bit) { bit = leftbit;addrl ++; }
154 StepDash
155 }
156 } else {
157 while(len--) {
158 if (rop == RROP_BLACK)
159 *addrl &= ~bit;
160 else if (rop == RROP_WHITE)
161 *addrl |= bit;
162 else if (rop == RROP_INVERT)
163 *addrl ^= bit;
164 e += e1;
165 if (e >= 0) {
166 afbScanlineInc(addrl, yinc);
167 e += e3;
168 }
169 bit = SCRLEFT(bit,1);
170 if (!bit) { bit = rightbit;addrl --; }
171 StepDash
172 }
173 }
174 } /* if X_AXIS */ else {
175 if (signdx > 0) {
176 while(len--) {
177 if (rop == RROP_BLACK)
178 *addrl &= ~bit;
179 else if (rop == RROP_WHITE)
180 *addrl |= bit;
181 else if (rop == RROP_INVERT)
182 *addrl ^= bit;
183 e += e1;
184 if (e >= 0) {
185 bit = SCRRIGHT(bit,1);
186 if (!bit) { bit = leftbit;addrl ++; }
187 e += e3;
188 }
189 afbScanlineInc(addrl, yinc);
190 StepDash
191 }
192 } else {
193 while(len--) {
194 if (rop == RROP_BLACK)
195 *addrl &= ~bit;
196 else if (rop == RROP_WHITE)
197 *addrl |= bit;
198 else if (rop == RROP_INVERT)
199 *addrl ^= bit;
200 e += e1;
201 if (e >= 0) {
202 bit = SCRLEFT(bit,1);
203 if (!bit) { bit = rightbit;addrl --; }
204 e += e3;
205 }
206 afbScanlineInc(addrl, yinc);
207 StepDash
208 }
209 }
210 } /* else Y_AXIS */
211 } /* for (d = ...) */
212 *pdashIndex = dashIndex;
213 *pdashOffset = pDash[dashIndex] - dashRemaining;
214}
diff --git a/afb/afbclip.c b/afb/afbclip.c
deleted file mode 100644
index 15be4051c..000000000
--- a/afb/afbclip.c
+++ /dev/null
@@ -1,248 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <stdlib.h>
54
55#include <X11/X.h>
56#include "regionstr.h"
57#include "pixmapstr.h"
58#include "scrnintstr.h"
59#include "gc.h"
60#include "maskbits.h"
61#include "mi.h"
62#include "afb.h"
63
64#define ADDRECT(reg,r,fr,rx1,ry1,rx2,ry2) \
65if (((rx1) < (rx2)) && ((ry1) < (ry2)) && \
66 (!((reg)->data->numRects && \
67 ((r-1)->y1 == (ry1)) && \
68 ((r-1)->y2 == (ry2)) && \
69 ((r-1)->x1 <= (rx1)) && \
70 ((r-1)->x2 >= (rx2))))) \
71{ \
72 if ((reg)->data->numRects == (reg)->data->size) \
73 { \
74 miRectAlloc(reg, 1); \
75 fr = REGION_BOXPTR(reg); \
76 r = fr + (reg)->data->numRects; \
77 } \
78 r->x1 = (rx1); \
79 r->y1 = (ry1); \
80 r->x2 = (rx2); \
81 r->y2 = (ry2); \
82 (reg)->data->numRects++; \
83 if(r->x1 < (reg)->extents.x1) \
84 (reg)->extents.x1 = r->x1; \
85 if(r->x2 > (reg)->extents.x2) \
86 (reg)->extents.x2 = r->x2; \
87 r++; \
88}
89
90/* Convert bitmap clip mask into clipping region.
91 * First, goes through each line and makes boxes by noting the transitions
92 * from 0 to 1 and 1 to 0.
93 * Then it coalesces the current line with the previous if they have boxes
94 * at the same X coordinates.
95 */
96RegionPtr
97afbPixmapToRegion(pPix)
98 PixmapPtr pPix;
99{
100 register RegionPtr pReg;
101 register PixelType *pw, w;
102 register int ib;
103 int width, h, base, rx1 = 0, crects;
104 PixelType *pwLineEnd;
105 int irectPrevStart, irectLineStart;
106 register BoxPtr prectO, prectN;
107 BoxPtr FirstRect, rects, prectLineStart;
108 Bool fInBox, fSame;
109 register PixelType mask0 = mfbGetmask(0);
110 PixelType *pwLine;
111 int nWidth;
112
113 pReg = REGION_CREATE(pPix->drawable.pScreen, NULL, 1);
114 if(!pReg)
115 return NullRegion;
116 FirstRect = REGION_BOXPTR(pReg);
117 rects = FirstRect;
118
119 pwLine = (PixelType *) pPix->devPrivate.ptr;
120 nWidth = pPix->devKind / PGSZB;
121
122 width = pPix->drawable.width;
123 pReg->extents.x1 = width - 1;
124 pReg->extents.x2 = 0;
125 irectPrevStart = -1;
126 for(h = 0; h < pPix->drawable.height; h++) {
127 pw = pwLine;
128 pwLine += nWidth;
129 irectLineStart = rects - FirstRect;
130 /* If the Screen left most bit of the word is set, we're starting in
131 * a box */
132 if(*pw & mask0) {
133 fInBox = TRUE;
134 rx1 = 0;
135 }
136 else
137 fInBox = FALSE;
138 /* Process all words which are fully in the pixmap */
139 pwLineEnd = pw + (width >> PWSH);
140 for (base = 0; pw < pwLineEnd; base += PPW) {
141 w = *pw++;
142 if (fInBox) {
143 if (!~w)
144 continue;
145 } else {
146 if (!w)
147 continue;
148 }
149 for(ib = 0; ib < PPW; ib++) {
150 /* If the Screen left most bit of the word is set, we're
151 * starting a box */
152 if(w & mask0) {
153 if(!fInBox) {
154 rx1 = base + ib;
155 /* start new box */
156 fInBox = TRUE;
157 }
158 } else {
159 if(fInBox) {
160 /* end box */
161 ADDRECT(pReg, rects, FirstRect,
162 rx1, h, base + ib, h + 1);
163 fInBox = FALSE;
164 }
165 }
166 /* Shift the word VISUALLY left one. */
167 w = SCRLEFT(w, 1);
168 }
169 }
170 if(width & PIM) {
171 /* Process final partial word on line */
172 w = *pw++;
173 for(ib = 0; ib < (width & PIM); ib++) {
174 /* If the Screen left most bit of the word is set, we're
175 * starting a box */
176 if(w & mask0) {
177 if(!fInBox) {
178 rx1 = base + ib;
179 /* start new box */
180 fInBox = TRUE;
181 }
182 } else {
183 if(fInBox) {
184 /* end box */
185 ADDRECT(pReg, rects, FirstRect,
186 rx1, h, base + ib, h + 1);
187 fInBox = FALSE;
188 }
189 }
190 /* Shift the word VISUALLY left one. */
191 w = SCRLEFT(w, 1);
192 }
193 }
194 /* If scanline ended with last bit set, end the box */
195 if(fInBox) {
196 ADDRECT(pReg, rects, FirstRect,
197 rx1, h, base + (width & PIM), h + 1);
198 }
199 /* if all rectangles on this line have the same x-coords as
200 * those on the previous line, then add 1 to all the previous y2s and
201 * throw away all the rectangles from this line
202 */
203 fSame = FALSE;
204 if(irectPrevStart != -1) {
205 crects = irectLineStart - irectPrevStart;
206 if(crects == ((rects - FirstRect) - irectLineStart)) {
207 prectO = FirstRect + irectPrevStart;
208 prectN = prectLineStart = FirstRect + irectLineStart;
209 fSame = TRUE;
210 while(prectO < prectLineStart) {
211 if((prectO->x1 != prectN->x1) || (prectO->x2 != prectN->x2)) {
212 fSame = FALSE;
213 break;
214 }
215 prectO++;
216 prectN++;
217 }
218 if (fSame) {
219 prectO = FirstRect + irectPrevStart;
220 while(prectO < prectLineStart) {
221 prectO->y2 += 1;
222 prectO++;
223 }
224 rects -= crects;
225 pReg->data->numRects -= crects;
226 }
227 }
228 }
229 if(!fSame)
230 irectPrevStart = irectLineStart;
231 }
232 if (!pReg->data->numRects)
233 pReg->extents.x1 = pReg->extents.x2 = 0;
234 else
235 {
236 pReg->extents.y1 = REGION_BOXPTR(pReg)->y1;
237 pReg->extents.y2 = REGION_END(pReg)->y2;
238 if (pReg->data->numRects == 1) {
239 xfree(pReg->data);
240 pReg->data = (RegDataPtr)NULL;
241 }
242 }
243#ifdef DEBUG
244 if (!miValidRegion(pReg))
245 FatalError("Assertion failed file %s, line %d: expr\n", __FILE__, __LINE__);
246#endif
247 return(pReg);
248}
diff --git a/afb/afbcmap.c b/afb/afbcmap.c
deleted file mode 100644
index 9608a3653..000000000
--- a/afb/afbcmap.c
+++ /dev/null
@@ -1,84 +0,0 @@
1/************************************************************
2Copyright 1987 by Sun Microsystems, Inc. Mountain View, CA.
3
4 All Rights Reserved
5
6Permission to use, copy, modify, and distribute this
7software and its documentation for any purpose and without
8fee is hereby granted, provided that the above copyright no-
9tice appear in all copies and that both that copyright no-
10tice and this permission notice appear in supporting docu-
11mentation, and that the names of Sun or X Consortium
12not be used in advertising or publicity pertaining to
13distribution of the software without specific prior
14written permission. Sun and X Consortium make no
15representations about the suitability of this software for
16any purpose. It is provided "as is" without any express or
17implied warranty.
18
19SUN DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
20INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FIT-
21NESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL SUN BE LI-
22ABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
23ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
24PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
25OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH
26THE USE OR PERFORMANCE OF THIS SOFTWARE.
27
28********************************************************/
29
30#ifdef HAVE_DIX_CONFIG_H
31#include <dix-config.h>
32#endif
33
34#include <X11/X.h>
35#include <X11/Xproto.h>
36#include "scrnintstr.h"
37#include "colormapst.h"
38#include "resource.h"
39#include "micmap.h"
40#include "afb.h"
41
42int
43afbListInstalledColormaps(ScreenPtr pScreen, Colormap *pmaps)
44{
45 return miListInstalledColormaps(pScreen, pmaps);
46}
47
48
49void
50afbInstallColormap(ColormapPtr pmap)
51{
52 miInstallColormap(pmap);
53}
54
55void
56afbUninstallColormap(ColormapPtr pmap)
57{
58 miUninstallColormap(pmap);
59}
60
61void
62afbResolveColor(short unsigned int *pred, short unsigned int *pgreen, short unsigned int *pblue, register VisualPtr pVisual)
63{
64 miResolveColor(pred, pgreen, pblue, pVisual);
65}
66
67Bool
68afbInitializeColormap(register ColormapPtr pmap)
69{
70 return miInitializeColormap(pmap);
71}
72
73/*
74 * Given a list of formats for a screen, create a list
75 * of visuals and depths for the screen which correspond to
76 * the set which can be used with this version of afb.
77 */
78
79Bool
80afbInitVisuals(VisualPtr *visualp, DepthPtr *depthp, int *nvisualp, int *ndepthp, int *rootDepthp, VisualID *defaultVisp, long unsigned int sizes, int bitsPerRGB)
81{
82 return miInitVisuals(visualp, depthp, nvisualp, ndepthp, rootDepthp,
83 defaultVisp, sizes, bitsPerRGB, -1);
84}
diff --git a/afb/afbfillarc.c b/afb/afbfillarc.c
deleted file mode 100644
index cfc3133ee..000000000
--- a/afb/afbfillarc.c
+++ /dev/null
@@ -1,347 +0,0 @@
1/************************************************************
2
3Copyright (c) 1989 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26********************************************************/
27
28
29#ifdef HAVE_DIX_CONFIG_H
30#include <dix-config.h>
31#endif
32
33#include <X11/X.h>
34#include <X11/Xprotostr.h>
35#include "regionstr.h"
36#include "gcstruct.h"
37#include "pixmapstr.h"
38#include "scrnintstr.h"
39#include "afb.h"
40#include "maskbits.h"
41#include "mifillarc.h"
42#include "mi.h"
43
44static void
45afbFillEllipseSolid(DrawablePtr pDraw, xArc *arc, register unsigned char *rrops)
46{
47 int x, y, e;
48 int yk, xk, ym, xm, dx, dy, xorg, yorg;
49 register int slw;
50 miFillArcRec info;
51 PixelType *addrlt, *addrlb;
52 register PixelType *pdst;
53 PixelType *addrl;
54 register int n;
55 register int d;
56 int nlwidth;
57 register int xpos;
58 PixelType startmask, endmask;
59 int nlmiddle;
60 int depthDst;
61 int sizeDst;
62
63 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
64 addrlt);
65 miFillArcSetup(arc, &info);
66 MIFILLARCSETUP();
67 xorg += pDraw->x;
68 yorg += pDraw->y;
69 addrlb = addrlt;
70 addrlt += nlwidth * (yorg - y);
71 addrlb += nlwidth * (yorg + y + dy);
72 while (y) {
73 addrlt += nlwidth;
74 addrlb -= nlwidth;
75 MIFILLARCSTEP(slw);
76 if (!slw)
77 continue;
78 xpos = xorg - x;
79 pdst = addrl = afbScanlineOffset(addrlt, (xpos >> PWSH));
80 if (((xpos & PIM) + slw) < PPW) {
81 maskpartialbits(xpos, slw, startmask);
82 for (d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
83 switch (rrops[d]) {
84 case RROP_BLACK:
85 *pdst &= ~startmask;
86 break;
87 case RROP_WHITE:
88 *pdst |= startmask;
89 break;
90 case RROP_INVERT:
91 *pdst ^= startmask;
92 break;
93 case RROP_NOP:
94 break;
95 }
96 }
97 if (miFillArcLower(slw)) {
98 pdst = afbScanlineOffset(addrlb, (xpos >> PWSH));
99
100 for (d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
101 switch (rrops[d]) {
102 case RROP_BLACK:
103 *pdst &= ~startmask;
104 break;
105 case RROP_WHITE:
106 *pdst |= startmask;
107 break;
108 case RROP_INVERT:
109 *pdst ^= startmask;
110 break;
111 case RROP_NOP:
112 break;
113 }
114 }
115 }
116 continue;
117 }
118 maskbits(xpos, slw, startmask, endmask, nlmiddle);
119 for (d = 0; d < depthDst; d++, addrl += sizeDst) { /* @@@ NEXT PLANE @@@ */
120 n = nlmiddle;
121 pdst = addrl;
122
123 switch (rrops[d]) {
124 case RROP_BLACK:
125 if (startmask)
126 *pdst++ &= ~startmask;
127 while (n--)
128 *pdst++ = 0;
129 if (endmask)
130 *pdst &= ~endmask;
131 break;
132
133 case RROP_WHITE:
134 if (startmask)
135 *pdst++ |= startmask;
136 while (n--)
137 *pdst++ = ~0;
138 if (endmask)
139 *pdst |= endmask;
140 break;
141
142 case RROP_INVERT:
143 if (startmask)
144 *pdst++ ^= startmask;
145 while (n--)
146 *pdst++ ^= ~0;
147 if (endmask)
148 *pdst ^= endmask;
149 break;
150
151 case RROP_NOP:
152 break;
153 }
154 }
155 if (!miFillArcLower(slw))
156 continue;
157 addrl = afbScanlineOffset(addrlb, (xpos >> PWSH));
158 for (d = 0; d < depthDst; d++, addrl += sizeDst) { /* @@@ NEXT PLANE @@@ */
159 n = nlmiddle;
160 pdst = addrl;
161
162 switch (rrops[d]) {
163 case RROP_BLACK:
164 if (startmask)
165 *pdst++ &= ~startmask;
166 while (n--)
167 *pdst++ = 0;
168 if (endmask)
169 *pdst &= ~endmask;
170 break;
171
172 case RROP_WHITE:
173 if (startmask)
174 *pdst++ |= startmask;
175 while (n--)
176 *pdst++ = ~0;
177 if (endmask)
178 *pdst |= endmask;
179 break;
180
181 case RROP_INVERT:
182 if (startmask)
183 *pdst++ ^= startmask;
184 while (n--)
185 *pdst++ ^= ~0;
186 if (endmask)
187 *pdst ^= endmask;
188 break;
189
190 case RROP_NOP:
191 break;
192 }
193 }
194 }
195}
196
197#define FILLSPAN(xl,xr,addr) \
198 if (xr >= xl) { \
199 width = xr - xl + 1; \
200 addrl = afbScanlineOffset(addr, (xl >> PWSH)); \
201 if (((xl & PIM) + width) < PPW) { \
202 maskpartialbits(xl, width, startmask); \
203 for (pdst = addrl, d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */ \
204 switch (rrops[d]) { \
205 case RROP_BLACK: \
206 *pdst &= ~startmask; \
207 break; \
208 case RROP_WHITE: \
209 *pdst |= startmask; \
210 break; \
211 case RROP_INVERT: \
212 *pdst ^= startmask; \
213 break; \
214 case RROP_NOP: \
215 break; \
216 } \
217 } \
218 } else { \
219 maskbits(xl, width, startmask, endmask, nlmiddle); \
220 for (d = 0; d < depthDst; d++, addrl += sizeDst) { /* @@@ NEXT PLANE @@@ */ \
221 n = nlmiddle; \
222 pdst = addrl; \
223 switch (rrops[d]) { \
224 case RROP_BLACK: \
225 if (startmask) \
226 *pdst++ &= ~startmask; \
227 while (n--) \
228 *pdst++ = 0; \
229 if (endmask) \
230 *pdst &= ~endmask; \
231 break; \
232 case RROP_WHITE: \
233 if (startmask) \
234 *pdst++ |= startmask; \
235 while (n--) \
236 *pdst++ = ~0; \
237 if (endmask) \
238 *pdst |= endmask; \
239 break; \
240 case RROP_INVERT: \
241 if (startmask) \
242 *pdst++ ^= startmask; \
243 while (n--) \
244 *pdst++ ^= ~0; \
245 if (endmask) \
246 *pdst ^= endmask; \
247 break; \
248 case RROP_NOP: \
249 break; \
250 } \
251 } \
252 } \
253 }
254
255#define FILLSLICESPANS(flip,addr) \
256 if (!flip) { \
257 FILLSPAN(xl, xr, addr); \
258 } else { \
259 xc = xorg - x; \
260 FILLSPAN(xc, xr, addr); \
261 xc += slw - 1; \
262 FILLSPAN(xl, xc, addr); \
263 }
264
265static void
266afbFillArcSliceSolidCopy(DrawablePtr pDraw, GCPtr pGC, xArc *arc, register unsigned char *rrops)
267{
268 PixelType *addrl;
269 register PixelType *pdst;
270 register int n;
271 register int d;
272 int yk, xk, ym, xm, dx, dy, xorg, yorg, slw;
273 register int x, y, e;
274 miFillArcRec info;
275 miArcSliceRec slice;
276 int xl, xr, xc;
277 PixelType *addrlt, *addrlb;
278 int nlwidth;
279 int width;
280 PixelType startmask, endmask;
281 int nlmiddle;
282 int sizeDst;
283 int depthDst;
284
285 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
286 addrlt);
287 miFillArcSetup(arc, &info);
288 miFillArcSliceSetup(arc, &slice, pGC);
289 MIFILLARCSETUP();
290 xorg += pDraw->x;
291 yorg += pDraw->y;
292 addrlb = addrlt;
293 addrlt = afbScanlineDeltaNoBankSwitch(addrlt, yorg - y, nlwidth);
294 addrlb = afbScanlineDeltaNoBankSwitch(addrlb, yorg + y + dy, nlwidth);
295 slice.edge1.x += pDraw->x;
296 slice.edge2.x += pDraw->x;
297 while (y > 0) {
298 afbScanlineIncNoBankSwitch(addrlt, nlwidth);
299 afbScanlineIncNoBankSwitch(addrlb, -nlwidth);
300 MIFILLARCSTEP(slw);
301 MIARCSLICESTEP(slice.edge1);
302 MIARCSLICESTEP(slice.edge2);
303 if (miFillSliceUpper(slice)) {
304 MIARCSLICEUPPER(xl, xr, slice, slw);
305 FILLSLICESPANS(slice.flip_top, addrlt);
306 }
307 if (miFillSliceLower(slice)) {
308 MIARCSLICELOWER(xl, xr, slice, slw);
309 FILLSLICESPANS(slice.flip_bot, addrlb);
310 }
311 }
312}
313
314void
315afbPolyFillArcSolid(register DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
316{
317 afbPrivGC *priv;
318 register xArc *arc;
319 register int i;
320 BoxRec box;
321 RegionPtr cclip;
322 unsigned char *rrops;
323
324 priv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
325 afbGCPrivateKey);
326 rrops = priv->rrops;
327 cclip = pGC->pCompositeClip;
328 for (arc = parcs, i = narcs; --i >= 0; arc++) {
329 if (miFillArcEmpty(arc))
330 continue;
331 if (miCanFillArc(arc)) {
332 box.x1 = arc->x + pDraw->x;
333 box.y1 = arc->y + pDraw->y;
334 box.x2 = box.x1 + (int)arc->width + 1;
335 box.y2 = box.y1 + (int)arc->height + 1;
336 if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN) {
337 if ((arc->angle2 >= FULLCIRCLE) ||
338 (arc->angle2 <= -FULLCIRCLE))
339 afbFillEllipseSolid(pDraw, arc, rrops);
340 else
341 afbFillArcSliceSolidCopy(pDraw, pGC, arc, rrops);
342 continue;
343 }
344 }
345 miPolyFillArc(pDraw, pGC, 1, arc);
346 }
347}
diff --git a/afb/afbfillrct.c b/afb/afbfillrct.c
deleted file mode 100644
index 4dff9576f..000000000
--- a/afb/afbfillrct.c
+++ /dev/null
@@ -1,292 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xprotostr.h>
56#include "pixmapstr.h"
57#include "gcstruct.h"
58#include "windowstr.h"
59#include "regionstr.h"
60#include "scrnintstr.h"
61
62#include "afb.h"
63#include "maskbits.h"
64
65#define MODEQ(a, b) ((a) %= (b))
66
67/*
68 filled rectangles.
69 translate the rectangles, clip them, and call the
70helper function in the GC.
71*/
72
73#define NUM_STACK_RECTS 1024
74
75void
76afbPolyFillRect(DrawablePtr pDrawable, GCPtr pGC, int nrectFill, xRectangle *prectInit)
77
78
79 /* number of rectangles to fill */
80 /* Pointer to first rectangle to fill */
81{
82 xRectangle *prect;
83 RegionPtr prgnClip;
84 register BoxPtr pbox;
85 register BoxPtr pboxClipped;
86 BoxPtr pboxClippedBase;
87 BoxPtr pextent;
88 BoxRec stackRects[NUM_STACK_RECTS];
89 int numRects;
90 int n;
91 int xorg, yorg;
92 afbPrivGC *priv;
93 unsigned char *rrops;
94 unsigned char *rropsOS;
95
96 priv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
97 afbGCPrivateKey);
98 prgnClip = pGC->pCompositeClip;
99 rrops = priv->rrops;
100 rropsOS = priv->rropOS;
101
102 prect = prectInit;
103 xorg = pDrawable->x;
104 yorg = pDrawable->y;
105 if (xorg || yorg) {
106 prect = prectInit;
107 n = nrectFill;
108 Duff(n, prect->x += xorg; prect->y += yorg; prect++);
109 }
110
111 prect = prectInit;
112
113 numRects = REGION_NUM_RECTS(prgnClip) * nrectFill;
114 if (numRects > NUM_STACK_RECTS) {
115 pboxClippedBase = (BoxPtr)xalloc(numRects * sizeof(BoxRec));
116 if (!pboxClippedBase)
117 return;
118 }
119 else
120 pboxClippedBase = stackRects;
121
122 pboxClipped = pboxClippedBase;
123
124 if (REGION_NUM_RECTS(prgnClip) == 1) {
125 int x1, y1, x2, y2, bx2, by2;
126
127 pextent = REGION_RECTS(prgnClip);
128 x1 = pextent->x1;
129 y1 = pextent->y1;
130 x2 = pextent->x2;
131 y2 = pextent->y2;
132 while (nrectFill--) {
133 if ((pboxClipped->x1 = prect->x) < x1)
134 pboxClipped->x1 = x1;
135
136 if ((pboxClipped->y1 = prect->y) < y1)
137 pboxClipped->y1 = y1;
138
139 bx2 = (int) prect->x + (int) prect->width;
140 if (bx2 > x2)
141 bx2 = x2;
142 pboxClipped->x2 = bx2;
143
144 by2 = (int) prect->y + (int) prect->height;
145 if (by2 > y2)
146 by2 = y2;
147 pboxClipped->y2 = by2;
148
149 prect++;
150 if ((pboxClipped->x1 < pboxClipped->x2) &&
151 (pboxClipped->y1 < pboxClipped->y2)) {
152 pboxClipped++;
153 }
154 }
155 } else {
156 int x1, y1, x2, y2, bx2, by2;
157
158 pextent = REGION_EXTENTS(pGC->pScreen, prgnClip);
159 x1 = pextent->x1;
160 y1 = pextent->y1;
161 x2 = pextent->x2;
162 y2 = pextent->y2;
163 while (nrectFill--) {
164 BoxRec box;
165
166 if ((box.x1 = prect->x) < x1)
167 box.x1 = x1;
168
169 if ((box.y1 = prect->y) < y1)
170 box.y1 = y1;
171
172 bx2 = (int) prect->x + (int) prect->width;
173 if (bx2 > x2)
174 bx2 = x2;
175 box.x2 = bx2;
176
177 by2 = (int) prect->y + (int) prect->height;
178 if (by2 > y2)
179 by2 = y2;
180 box.y2 = by2;
181
182 prect++;
183
184 if ((box.x1 >= box.x2) || (box.y1 >= box.y2))
185 continue;
186
187 n = REGION_NUM_RECTS (prgnClip);
188 pbox = REGION_RECTS(prgnClip);
189
190 /* clip the rectangle to each box in the clip region
191 this is logically equivalent to calling Intersect()
192 */
193 while(n--) {
194 pboxClipped->x1 = max(box.x1, pbox->x1);
195 pboxClipped->y1 = max(box.y1, pbox->y1);
196 pboxClipped->x2 = min(box.x2, pbox->x2);
197 pboxClipped->y2 = min(box.y2, pbox->y2);
198 pbox++;
199
200 /* see if clipping left anything */
201 if(pboxClipped->x1 < pboxClipped->x2 &&
202 pboxClipped->y1 < pboxClipped->y2) {
203 pboxClipped++;
204 }
205 }
206 }
207 }
208 if (pboxClipped != pboxClippedBase) {
209 switch (pGC->fillStyle) {
210 case FillSolid:
211 afbSolidFillArea(pDrawable, pboxClipped-pboxClippedBase,
212 pboxClippedBase, rrops);
213 break;
214 case FillTiled:
215 switch (pGC->alu) {
216 case GXcopy:
217 if (pGC->pRotatedPixmap)
218 afbTileAreaPPWCopy(pDrawable, pboxClipped-pboxClippedBase,
219 pboxClippedBase, GXcopy,
220 pGC->pRotatedPixmap, pGC->planemask);
221 else
222 afbTileAreaCopy (pDrawable, pboxClipped-pboxClippedBase,
223 pboxClippedBase, GXcopy,
224 pGC->tile.pixmap,
225 pGC->patOrg.x, pGC->patOrg.y,
226 pGC->planemask);
227 break;
228
229 default:
230 if (pGC->pRotatedPixmap)
231 afbTileAreaPPWGeneral(pDrawable, pboxClipped-pboxClippedBase,
232 pboxClippedBase, pGC->alu,
233 pGC->pRotatedPixmap,
234 pGC->planemask);
235 else
236 afbTileAreaGeneral(pDrawable, pboxClipped-pboxClippedBase,
237 pboxClippedBase, pGC->alu,
238 pGC->tile.pixmap,
239 pGC->patOrg.x, pGC->patOrg.y,
240 pGC->planemask);
241 break;
242 } /* switch (alu) */
243 break;
244
245 case FillStippled:
246 if (pGC->pRotatedPixmap)
247 afbStippleAreaPPW(pDrawable, pboxClipped-pboxClippedBase,
248 pboxClippedBase, pGC->pRotatedPixmap, rrops);
249 else
250 afbStippleArea(pDrawable, pboxClipped-pboxClippedBase,
251 pboxClippedBase, pGC->stipple,
252 pGC->patOrg.x, pGC->patOrg.y, rrops);
253 break;
254
255 case FillOpaqueStippled:
256 switch (pGC->alu) {
257 case GXcopy:
258 if (pGC->pRotatedPixmap)
259 afbOpaqueStippleAreaPPWCopy(pDrawable, pboxClipped-pboxClippedBase,
260 pboxClippedBase, GXcopy,
261 pGC->pRotatedPixmap,
262 rropsOS, pGC->planemask);
263 else
264 afbOpaqueStippleAreaCopy(pDrawable, pboxClipped-pboxClippedBase,
265 pboxClippedBase, GXcopy,
266 pGC->stipple,
267 pGC->patOrg.x, pGC->patOrg.y, rropsOS,
268 pGC->planemask);
269 break;
270
271 default:
272 if (pGC->pRotatedPixmap)
273 afbOpaqueStippleAreaPPWGeneral(pDrawable, pboxClipped-pboxClippedBase,
274 pboxClippedBase, pGC->alu,
275 pGC->pRotatedPixmap,
276 rropsOS,
277 pGC->planemask);
278 else
279 afbOpaqueStippleAreaGeneral(pDrawable, pboxClipped-pboxClippedBase,
280 pboxClippedBase, pGC->alu,
281 pGC->stipple,
282 pGC->patOrg.x, pGC->patOrg.y,
283 rropsOS,
284 pGC->planemask);
285 break;
286 } /* switch (alu) */
287 break;
288 }
289 }
290 if (pboxClippedBase != stackRects)
291 xfree(pboxClippedBase);
292}
diff --git a/afb/afbfillsp.c b/afb/afbfillsp.c
deleted file mode 100644
index 16295067b..000000000
--- a/afb/afbfillsp.c
+++ /dev/null
@@ -1,1130 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xmd.h>
56#include "gcstruct.h"
57#include "window.h"
58#include "pixmapstr.h"
59#include "scrnintstr.h"
60#include "windowstr.h"
61#include "afb.h"
62
63#include "maskbits.h"
64
65#include "mergerop.h"
66
67#include "servermd.h"
68#include "mi.h"
69#include "mispans.h"
70
71/* scanline filling for monochrome frame buffer
72 written by drewry, oct 1986
73
74 these routines all clip. they assume that anything that has called
75them has already translated the points (i.e. pGC->miTranslate is
76non-zero, which is howit gets set in afbCreateGC().)
77
78 the number of new scnalines created by clipping ==
79MaxRectsPerBand * nSpans.
80
81*/
82
83
84void
85afbSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
86 DrawablePtr pDrawable;
87 GCPtr pGC;
88 int nInit; /* number of spans to fill */
89 DDXPointPtr pptInit; /* pointer to list of start points */
90 int *pwidthInit; /* pointer to list of n widths */
91 int fSorted;
92{
93 /* next three parameters are post-clip */
94 int n; /* number of spans to fill */
95 register DDXPointPtr ppt; /* pointer to list of start points */
96 register int *pwidth; /* pointer to list of n widths */
97 PixelType *addrlBase; /* pointer to start of bitmap */
98 PixelType *pBase;
99 int nlwidth; /* width in longwords of bitmap */
100 register PixelType *addrl;/* pointer to current longword in bitmap */
101 register int nlmiddle;
102 register PixelType startmask;
103 register PixelType endmask;
104 int *pwidthFree; /* copies of the pointers to free */
105 DDXPointPtr pptFree;
106 int depthDst;
107 int sizeDst;
108 int d;
109 unsigned char *rrops;
110
111 n = nInit * miFindMaxBand(pGC->pCompositeClip);
112 pwidthFree = (int *)xalloc(n * sizeof(int));
113 pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
114 if(!pptFree || !pwidthFree) {
115 if (pptFree) xfree(pptFree);
116 if (pwidthFree) xfree(pwidthFree);
117 return;
118 }
119 pwidth = pwidthFree;
120 ppt = pptFree;
121 n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
122 ppt, pwidth, fSorted);
123
124 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
125 pBase);
126 rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
127 afbGCPrivateKey))->rrops;
128 while (n--) {
129 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
130
131 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
132 if (*pwidth) {
133 addrl = addrlBase;
134
135 switch (rrops[d]) {
136 case RROP_BLACK:
137 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
138 /* all bits inside same longword */
139 maskpartialbits(ppt->x, *pwidth, startmask);
140 *addrl &= ~startmask;
141 } else {
142 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
143 if (startmask)
144 *addrl++ &= ~startmask;
145 Duff (nlmiddle, *addrl++ = 0x0);
146 if (endmask)
147 *addrl &= ~endmask;
148 }
149 break;
150
151 case RROP_WHITE:
152 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
153 /* all bits inside same longword */
154 maskpartialbits(ppt->x, *pwidth, startmask);
155 *addrl |= startmask;
156 } else {
157 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
158 if (startmask)
159 *addrl++ |= startmask;
160 Duff (nlmiddle, *addrl++ = ~0);
161 if (endmask)
162 *addrl |= endmask;
163 }
164 break;
165 case RROP_INVERT:
166 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
167 /* all bits inside same longword */
168 maskpartialbits(ppt->x, *pwidth, startmask);
169 *addrl ^= startmask;
170 } else {
171 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
172 if (startmask)
173 *addrl++ ^= startmask;
174 Duff (nlmiddle, *addrl++ ^= ~0);
175 if (endmask)
176 *addrl ^= endmask;
177 }
178 break;
179 case RROP_NOP:
180 break;
181 }
182 }
183 }
184 pwidth++;
185 ppt++;
186 }
187 xfree(pptFree);
188 xfree(pwidthFree);
189}
190
191void
192afbStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
193 DrawablePtr pDrawable;
194 GC *pGC;
195 int nInit; /* number of spans to fill */
196 DDXPointPtr pptInit; /* pointer to list of start points */
197 int *pwidthInit; /* pointer to list of n widths */
198 int fSorted;
199{
200 /* next three parameters are post-clip */
201 int n; /* number of spans to fill */
202 register DDXPointPtr ppt; /* pointer to list of start points */
203 register int *pwidth; /* pointer to list of n widths */
204 PixelType *addrlBase; /* pointer to start of bitmap */
205 PixelType *pBase;
206 int nlwidth; /* width in longwords of bitmap */
207 register PixelType *addrl;/* pointer to current longword in bitmap */
208 register PixelType src;
209 register int nlmiddle;
210 register PixelType startmask;
211 register PixelType endmask;
212 PixmapPtr pStipple;
213 PixelType *psrc;
214 int tileHeight;
215 int *pwidthFree; /* copies of the pointers to free */
216 DDXPointPtr pptFree;
217 int d;
218 int depthDst;
219 int sizeDst;
220 unsigned char *rrops;
221
222 n = nInit * miFindMaxBand(pGC->pCompositeClip);
223 pwidthFree = (int *)xalloc(n * sizeof(int));
224 pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
225 if(!pptFree || !pwidthFree) {
226 if (pptFree) xfree(pptFree);
227 if (pwidthFree) xfree(pwidthFree);
228 return;
229 }
230 pwidth = pwidthFree;
231 ppt = pptFree;
232 n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
233 ppt, pwidth, fSorted);
234
235 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
236 pBase);
237
238 pStipple = pGC->pRotatedPixmap;
239 tileHeight = pStipple->drawable.height;
240 psrc = (PixelType *)(pStipple->devPrivate.ptr);
241
242 rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
243 afbGCPrivateKey))->rrops;
244 while (n--) {
245 src = psrc[ppt->y % tileHeight];
246 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
247 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
248 addrl = addrlBase;
249
250 switch (rrops[d]) {
251 case RROP_BLACK:
252 /* all bits inside same longword */
253 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
254 maskpartialbits(ppt->x, *pwidth, startmask);
255 *addrl &= ~(src & startmask);
256 } else {
257 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
258 if (startmask)
259 *addrl++ &= ~(src & startmask);
260 Duff (nlmiddle, *addrl++ &= ~src);
261 if (endmask)
262 *addrl &= ~(src & endmask);
263 }
264 break;
265 case RROP_WHITE:
266 /* all bits inside same longword */
267 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
268 maskpartialbits(ppt->x, *pwidth, startmask);
269 *addrl |= (src & startmask);
270 } else {
271 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
272 if (startmask)
273 *addrl++ |= (src & startmask);
274 Duff (nlmiddle, *addrl++ |= src);
275 if (endmask)
276 *addrl |= (src & endmask);
277 }
278 break;
279 case RROP_INVERT:
280 /* all bits inside same longword */
281 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
282 maskpartialbits(ppt->x, *pwidth, startmask);
283 *addrl ^= (src & startmask);
284 } else {
285 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
286 if (startmask)
287 *addrl++ ^= (src & startmask);
288 Duff (nlmiddle, *addrl++ ^= src);
289 if (endmask)
290 *addrl ^= (src & endmask);
291 }
292 break;
293
294 case RROP_NOP:
295 break;
296 }
297 }
298 pwidth++;
299 ppt++;
300 }
301 xfree(pptFree);
302 xfree(pwidthFree);
303}
304
305void
306afbTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
307 DrawablePtr pDrawable;
308 GC *pGC;
309 int nInit; /* number of spans to fill */
310 DDXPointPtr pptInit; /* pointer to list of start points */
311 int *pwidthInit; /* pointer to list of n widths */
312 int fSorted;
313{
314 /* next three parameters are post-clip */
315 int n; /* number of spans to fill */
316 register DDXPointPtr ppt; /* pointer to list of start points */
317 register int *pwidth; /* pointer to list of n widths */
318 PixelType *addrlBase; /* pointer to start of bitmap */
319 PixelType *pBase;
320 int nlwidth; /* width in longwords of bitmap */
321 register PixelType *addrl; /* pointer to current longword in bitmap */
322 register PixelType src;
323 register int nlmiddle;
324 register PixelType startmask;
325 register PixelType endmask;
326 PixmapPtr pTile;
327 PixelType *psrc;
328 int tileHeight;
329 int rop;
330 int *pwidthFree; /* copies of the pointers to free */
331 DDXPointPtr pptFree;
332 int sizeDst;
333 int depthDst;
334 int d;
335
336 n = nInit * miFindMaxBand(pGC->pCompositeClip);
337 pwidthFree = (int *)xalloc(n * sizeof(int));
338 pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
339 if(!pptFree || !pwidthFree) {
340 if (pptFree) xfree(pptFree);
341 if (pwidthFree) xfree(pwidthFree);
342 return;
343 }
344 pwidth = pwidthFree;
345 ppt = pptFree;
346 n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
347 ppt, pwidth, fSorted);
348
349 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
350 pBase);
351
352 pTile = pGC->pRotatedPixmap;
353 tileHeight = pTile->drawable.height;
354 psrc = (PixelType *)(pTile->devPrivate.ptr);
355 rop = pGC->alu;
356
357 switch(rop) {
358 case GXcopy:
359#define DoMaskCopyRop(src,dst,mask) (((dst) & ~(mask)) | ((src) & (mask)))
360 while (n--) {
361 if (*pwidth) {
362 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
363
364 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
365 if (!(pGC->planemask & (1 << d)))
366 continue;
367
368 addrl = addrlBase;
369 src = psrc[ppt->y % tileHeight + tileHeight * d];
370 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
371 maskpartialbits(ppt->x, *pwidth, startmask);
372 *addrl = DoMaskCopyRop (src, *addrl, startmask);
373 } else {
374 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
375 if (startmask) {
376 *addrl = DoMaskCopyRop (src, *addrl, startmask);
377 addrl++;
378 }
379 while (nlmiddle--) {
380 *addrl = src;
381 addrl++;
382 }
383 if (endmask)
384 *addrl = DoMaskCopyRop (src, *addrl, endmask);
385 }
386 }
387 }
388 pwidth++;
389 ppt++;
390 }
391 break;
392
393 default:
394 {
395 register DeclareMergeRop ();
396
397 InitializeMergeRop(rop,~0);
398 while (n--) {
399 if (*pwidth) {
400 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
401 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
402 if (!(pGC->planemask & (1 << d)))
403 continue;
404
405 addrl = addrlBase;
406
407 src = psrc[ppt->y % tileHeight + tileHeight * d];
408 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
409 maskpartialbits(ppt->x, *pwidth, startmask);
410 *addrl = DoMaskMergeRop (src, *addrl, startmask);
411 } else {
412 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
413 if (startmask) {
414 *addrl = DoMaskMergeRop (src, *addrl, startmask);
415 addrl++;
416 }
417 while (nlmiddle--) {
418 *addrl = DoMergeRop (src, *addrl);
419 addrl++;
420 }
421 if (endmask)
422 *addrl = DoMaskMergeRop (src, *addrl, endmask);
423 }
424 }
425 }
426 pwidth++;
427 ppt++;
428 }
429 break;
430 }
431 }
432 xfree(pptFree);
433 xfree(pwidthFree);
434}
435
436void
437afbOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
438 DrawablePtr pDrawable;
439 GC *pGC;
440 int nInit; /* number of spans to fill */
441 DDXPointPtr pptInit; /* pointer to list of start points */
442 int *pwidthInit; /* pointer to list of n widths */
443 int fSorted;
444{
445 /* next three parameters are post-clip */
446 int n; /* number of spans to fill */
447 register DDXPointPtr ppt; /* pointer to list of start points */
448 register int *pwidth; /* pointer to list of n widths */
449 PixelType *addrlBase; /* pointer to start of bitmap */
450 PixelType *pBase;
451 int nlwidth; /* width in longwords of bitmap */
452 register PixelType *addrl; /* pointer to current longword in bitmap */
453 register PixelType src = 0;
454 register int nlmiddle;
455 register PixelType startmask;
456 register PixelType endmask;
457 PixmapPtr pTile;
458 PixelType *psrc;
459 int tileHeight;
460 int rop;
461 unsigned char *rropsOS;
462 int *pwidthFree; /* copies of the pointers to free */
463 DDXPointPtr pptFree;
464 int sizeDst;
465 int depthDst;
466 int d;
467
468 n = nInit * miFindMaxBand(pGC->pCompositeClip);
469 pwidthFree = (int *)xalloc(n * sizeof(int));
470 pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
471 if(!pptFree || !pwidthFree) {
472 if (pptFree) xfree(pptFree);
473 if (pwidthFree) xfree(pwidthFree);
474 return;
475 }
476 pwidth = pwidthFree;
477 ppt = pptFree;
478 n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
479 ppt, pwidth, fSorted);
480
481 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
482 pBase);
483
484 pTile = pGC->pRotatedPixmap;
485 tileHeight = pTile->drawable.height;
486 psrc = (PixelType *)(pTile->devPrivate.ptr);
487 rop = pGC->alu;
488 rropsOS = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
489 afbGCPrivateKey))->rropOS;
490 switch(rop) {
491 case GXcopy:
492 while (n--) {
493 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
494 if (*pwidth) {
495 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
496 switch (rropsOS[d]) {
497 case RROP_BLACK:
498 src = 0;
499 break;
500 case RROP_WHITE:
501 src = ~0;
502 break;
503 case RROP_INVERT:
504 src = ~psrc[ppt->y % tileHeight];
505 break;
506 case RROP_COPY:
507 src = psrc[ppt->y % tileHeight];
508 break;
509 case RROP_NOP:
510 continue;
511 }
512
513 addrl = addrlBase;
514
515 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
516 maskpartialbits(ppt->x, *pwidth, startmask);
517 *addrl = DoMaskCopyRop (src, *addrl, startmask);
518 } else {
519 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
520 if (startmask) {
521 *addrl = DoMaskCopyRop (src, *addrl, startmask);
522 addrl++;
523 }
524 while (nlmiddle--) {
525 *addrl = src;
526 addrl++;
527 }
528 if (endmask)
529 *addrl = DoMaskCopyRop (src, *addrl, endmask);
530 }
531 } /* for (d = ...) */
532 }
533
534 pwidth++;
535 ppt++;
536 }
537 break;
538
539 default:
540 {
541 register DeclareMergeRop ();
542
543 InitializeMergeRop(rop,~0);
544 while (n--) {
545 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
546 if (*pwidth) {
547 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
548 switch (rropsOS[d]) {
549 case RROP_BLACK:
550 src = 0;
551 break;
552 case RROP_WHITE:
553 src = ~0;
554 break;
555 case RROP_INVERT:
556 src = ~psrc[ppt->y % tileHeight];
557 break;
558 case RROP_COPY:
559 src = psrc[ppt->y % tileHeight];
560 break;
561 case RROP_NOP:
562 continue;
563 }
564
565 addrl = addrlBase;
566
567 if ( ((ppt->x & PIM) + *pwidth) < PPW) {
568 maskpartialbits(ppt->x, *pwidth, startmask);
569 *addrl = DoMaskMergeRop (src, *addrl, startmask);
570 } else {
571 maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle);
572 if (startmask) {
573 *addrl = DoMaskMergeRop (src, *addrl, startmask);
574 addrl++;
575 }
576 while (nlmiddle--) {
577 *addrl = DoMergeRop (src, *addrl);
578 addrl++;
579 }
580 if (endmask)
581 *addrl = DoMaskMergeRop (src, *addrl, endmask);
582 }
583 } /* for (d = ...) */
584 }
585 pwidth++;
586 ppt++;
587 } /* while (n) */
588 break;
589 }
590 } /* switch (rop) */
591 xfree(pptFree);
592 xfree(pwidthFree);
593}
594
595/* Fill spans with tiles that aren't PPW bits wide */
596void
597afbUnnaturalTileFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
598 DrawablePtr pDrawable;
599 GC *pGC;
600 int nInit; /* number of spans to fill */
601 DDXPointPtr pptInit; /* pointer to list of start points */
602 int *pwidthInit; /* pointer to list of n widths */
603 int fSorted;
604{
605 int iline; /* first line of tile to use */
606 /* next three parameters are post-clip */
607 int n; /* number of spans to fill */
608 register DDXPointPtr ppt; /* pointer to list of start points */
609 register int *pwidth; /* pointer to list of n widths */
610 PixelType *addrlBase; /* pointer to start of bitmap */
611 PixelType *pBase;
612 int nlwidth; /* width in longwords of bitmap */
613 register PixelType *pdst;/* pointer to current word in bitmap */
614 register PixelType *psrc;/* pointer to current word in tile */
615 register int nlMiddle;
616 register int rop, nstart;
617 PixelType startmask;
618 PixmapPtr pTile; /* pointer to tile we want to fill with */
619 int w, width, x, xSrc, ySrc, srcStartOver, nend;
620 int tlwidth, rem, tileWidth, tileHeight, endinc;
621 PixelType endmask, *psrcT;
622 int *pwidthFree; /* copies of the pointers to free */
623 DDXPointPtr pptFree;
624 int sizeDst;
625 int sizeTile;
626 int depthDst;
627 register int d;
628
629 n = nInit * miFindMaxBand(pGC->pCompositeClip);
630 pwidthFree = (int *)xalloc(n * sizeof(int));
631 pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
632 if(!pptFree || !pwidthFree) {
633 if (pptFree) xfree(pptFree);
634 if (pwidthFree) xfree(pwidthFree);
635 return;
636 }
637 pwidth = pwidthFree;
638 ppt = pptFree;
639 n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
640 ppt, pwidth, fSorted);
641
642 pTile = pGC->tile.pixmap;
643 tlwidth = pTile->devKind / PGSZB;
644 rop = pGC->alu;
645
646 xSrc = pDrawable->x;
647 ySrc = pDrawable->y;
648
649 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
650 pBase);
651
652 tileWidth = pTile->drawable.width;
653 tileHeight = pTile->drawable.height;
654 sizeTile = tlwidth * tileHeight;
655
656 /* this replaces rotating the tile. Instead we just adjust the offset
657 * at which we start grabbing bits from the tile.
658 * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
659 * so that iline and rem always stay within the tile bounds.
660 */
661 xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
662 ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
663
664 while (n--) {
665 iline = (ppt->y - ySrc) % tileHeight;
666 psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
667 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
668
669 for (d = 0; d < depthDst; d++, psrcT += sizeTile, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
670 if (!(pGC->planemask & (1 << d)))
671 continue;
672
673 if (*pwidth) {
674 x = ppt->x;
675 pdst = addrlBase;
676 width = *pwidth;
677 while(width > 0) {
678 psrc = psrcT;
679 w = min(tileWidth, width);
680 if((rem = (x - xSrc) % tileWidth) != 0) {
681 /* if we're in the middle of the tile, get
682 as many bits as will finish the span, or
683 as many as will get to the left edge of the tile,
684 or a longword worth, starting at the appropriate
685 offset in the tile.
686 */
687 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
688 endinc = rem / BITMAP_SCANLINE_PAD;
689 getandputrop((psrc+endinc), (rem&PIM), (x & PIM), w, pdst, rop);
690 if((x & PIM) + w >= PPW)
691 pdst++;
692 } else if(((x & PIM) + w) < PPW) {
693 /* doing < PPW bits is easy, and worth special-casing */
694 putbitsrop(*psrc, x & PIM, w, pdst, rop);
695 } else {
696 /* start at the left edge of the tile,
697 and put down as much as we can
698 */
699 maskbits(x, w, startmask, endmask, nlMiddle);
700
701 if (startmask)
702 nstart = PPW - (x & PIM);
703 else
704 nstart = 0;
705 if (endmask)
706 nend = (x + w) & PIM;
707 else
708 nend = 0;
709
710 srcStartOver = nstart > PLST;
711
712 if(startmask) {
713 putbitsrop(*psrc, (x & PIM), nstart, pdst, rop);
714 pdst++;
715 if(srcStartOver)
716 psrc++;
717 }
718
719 while(nlMiddle--) {
720 getandputrop0(psrc, nstart, PPW, pdst, rop);
721 pdst++;
722 psrc++;
723 }
724 if(endmask) {
725 getandputrop0(psrc, nstart, nend, pdst, rop);
726 }
727 }
728 x += w;
729 width -= w;
730 }
731 }
732 }
733 ppt++;
734 pwidth++;
735 }
736 xfree(pptFree);
737 xfree(pwidthFree);
738}
739
740/* Fill spans with stipples that aren't PPW bits wide */
741void
742afbUnnaturalStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
743 DrawablePtr pDrawable;
744 GC *pGC;
745 int nInit; /* number of spans to fill */
746 DDXPointPtr pptInit; /* pointer to list of start points */
747 int *pwidthInit; /* pointer to list of n widths */
748 int fSorted;
749{
750 /* next three parameters are post-clip */
751 int n; /* number of spans to fill */
752 register DDXPointPtr ppt; /* pointer to list of start points */
753 register int *pwidth; /* pointer to list of n widths */
754 int iline; /* first line of tile to use */
755 PixelType *addrlBase; /* pointer to start of bitmap */
756 PixelType *pBase;
757 int nlwidth; /* width in longwords of bitmap */
758 register PixelType *pdst; /* pointer to current word in bitmap */
759 register PixelType *psrc; /* pointer to current word in tile */
760 register int nlMiddle;
761 register int rop, nstart;
762 PixelType startmask;
763 PixmapPtr pTile; /* pointer to tile we want to fill with */
764 int w, width, x, xSrc, ySrc, srcStartOver, nend;
765 PixelType endmask, *psrcT;
766 int tlwidth, rem, tileWidth, endinc;
767 int tileHeight;
768 int *pwidthFree; /* copies of the pointers to free */
769 DDXPointPtr pptFree;
770 unsigned char *rrops;
771 register int d;
772 int sizeDst;
773 int depthDst;
774
775 n = nInit * miFindMaxBand(pGC->pCompositeClip);
776 pwidthFree = (int *)xalloc(n * sizeof(int));
777 pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
778 if(!pptFree || !pwidthFree) {
779 if (pptFree) xfree(pptFree);
780 if (pwidthFree) xfree(pwidthFree);
781 return;
782 }
783 pwidth = pwidthFree;
784 ppt = pptFree;
785 n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
786 ppt, pwidth, fSorted);
787
788 pTile = pGC->stipple;
789 tlwidth = pTile->devKind / PGSZB;
790 xSrc = pDrawable->x;
791 ySrc = pDrawable->y;
792 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
793 pBase);
794
795 tileWidth = pTile->drawable.width;
796 tileHeight = pTile->drawable.height;
797 rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
798 afbGCPrivateKey))->rrops;
799 /* this replaces rotating the stipple. Instead, we just adjust the offset
800 * at which we start grabbing bits from the stipple.
801 * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
802 * so that iline and rem always stay within the tile bounds.
803 */
804 xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
805 ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
806 while (n--) {
807 iline = (ppt->y - ySrc) % tileHeight;
808 psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
809 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
810
811 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
812 rop = rrops[d];
813 if (rop == RROP_NOP)
814 continue;
815
816 pdst = addrlBase;
817 x = ppt->x;
818
819 if (*pwidth) {
820 width = *pwidth;
821 while(width > 0) {
822 psrc = psrcT;
823 w = min(tileWidth, width);
824 if((rem = (x - xSrc) % tileWidth) != 0) {
825 /* if we're in the middle of the tile, get
826 as many bits as will finish the span, or
827 as many as will get to the left edge of the tile,
828 or a longword worth, starting at the appropriate
829 offset in the tile.
830 */
831 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
832 endinc = rem / BITMAP_SCANLINE_PAD;
833 getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
834 w, pdst, rop)
835 if((x & PIM) + w >= PPW)
836 pdst++;
837 } else if(((x & PIM) + w) < PPW) {
838 /* doing < PPW bits is easy, and worth special-casing */
839 putbitsrrop(*psrc, x & PIM, w, pdst, rop);
840 } else {
841 /* start at the left edge of the tile,
842 and put down as much as we can
843 */
844 maskbits(x, w, startmask, endmask, nlMiddle);
845
846 if (startmask)
847 nstart = PPW - (x & PIM);
848 else
849 nstart = 0;
850 if (endmask)
851 nend = (x + w) & PIM;
852 else
853 nend = 0;
854
855 srcStartOver = nstart > PLST;
856
857 if(startmask) {
858 putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
859 pdst++;
860 if(srcStartOver)
861 psrc++;
862 }
863
864 while(nlMiddle--) {
865 getandputrrop0(psrc, nstart, PPW, pdst, rop);
866 pdst++;
867 psrc++;
868 }
869 if(endmask) {
870 getandputrrop0(psrc, nstart, nend, pdst, rop);
871 }
872 }
873 x += w;
874 width -= w;
875 }
876 }
877 }
878 ppt++;
879 pwidth++;
880 }
881 xfree(pptFree);
882 xfree(pwidthFree);
883}
884
885/* Fill spans with OpaqueStipples that aren't PPW bits wide */
886void
887afbUnnaturalOpaqueStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted)
888 DrawablePtr pDrawable;
889 GC *pGC;
890 int nInit; /* number of spans to fill */
891 DDXPointPtr pptInit; /* pointer to list of start points */
892 int *pwidthInit; /* pointer to list of n widths */
893 int fSorted;
894{
895 int iline; /* first line of tile to use */
896 /* next three parameters are post-clip */
897 int n; /* number of spans to fill */
898 register DDXPointPtr ppt; /* pointer to list of start points */
899 register int *pwidth; /* pointer to list of n widths */
900 PixelType *addrlBase; /* pointer to start of bitmap */
901 PixelType *pBase;
902 int nlwidth; /* width in longwords of bitmap */
903 register PixelType *pdst;/* pointer to current word in bitmap */
904 register PixelType *psrc;/* pointer to current word in tile */
905 register int nlMiddle;
906 register int d;
907 register PixelType tmpsrc = 0;
908 register PixelType tmpdst;
909 register int alu, nstart;
910 register unsigned char *rropsOS;
911 PixelType startmask;
912 PixmapPtr pTile; /* pointer to tile we want to fill with */
913 int w, width, x, xSrc, ySrc, srcStartOver, nend;
914 int tlwidth, rem, tileWidth, tileHeight, endinc;
915 PixelType endmask, *psrcT;
916 int *pwidthFree; /* copies of the pointers to free */
917 DDXPointPtr pptFree;
918 int sizeDst;
919 int depthDst;
920
921 n = nInit * miFindMaxBand(pGC->pCompositeClip);
922 pwidthFree = (int *)xalloc(n * sizeof(int));
923 pptFree = (DDXPointRec *)xalloc(n * sizeof(DDXPointRec));
924 if(!pptFree || !pwidthFree) {
925 if (pptFree) xfree(pptFree);
926 if (pwidthFree) xfree(pwidthFree);
927 return;
928 }
929 pwidth = pwidthFree;
930 ppt = pptFree;
931 n = miClipSpans(pGC->pCompositeClip, pptInit, pwidthInit, nInit,
932 ppt, pwidth, fSorted);
933
934 pTile = pGC->stipple;
935 tlwidth = pTile->devKind / PGSZB;
936 alu = pGC->alu;
937
938 xSrc = pDrawable->x;
939 ySrc = pDrawable->y;
940
941 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
942 pBase);
943
944 tileWidth = pTile->drawable.width;
945 tileHeight = pTile->drawable.height;
946 rropsOS = afbGetGCPrivate(pGC)->rropOS;
947
948 /* this replaces rotating the tile. Instead we just adjust the offset
949 * at which we start grabbing bits from the tile.
950 * Ensure that ppt->x - xSrc >= 0 and ppt->y - ySrc >= 0,
951 * so that iline and rem always stay within the tile bounds.
952 */
953 xSrc += (pGC->patOrg.x % tileWidth) - tileWidth;
954 ySrc += (pGC->patOrg.y % tileHeight) - tileHeight;
955
956 while (n--) {
957 iline = (ppt->y - ySrc) % tileHeight;
958 psrcT = (PixelType *) pTile->devPrivate.ptr + (iline * tlwidth);
959 addrlBase = afbScanline(pBase, ppt->x, ppt->y, nlwidth);
960
961 for (d = 0; d < depthDst; d++, addrlBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
962 if (!(pGC->planemask & (1 << d)))
963 continue;
964
965 if (*pwidth) {
966 x = ppt->x;
967 pdst = addrlBase;
968 width = *pwidth;
969 while(width > 0) {
970 psrc = psrcT;
971 w = min(tileWidth, width);
972 if((rem = (x - xSrc) % tileWidth) != 0) {
973 /* if we're in the middle of the tile, get
974 as many bits as will finish the span, or
975 as many as will get to the left edge of the tile,
976 or a longword worth, starting at the appropriate
977 offset in the tile.
978 */
979 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
980 endinc = rem / BITMAP_SCANLINE_PAD;
981 switch (rropsOS[d]) {
982 case RROP_BLACK:
983 tmpsrc = 0;
984 break;
985 case RROP_WHITE:
986 tmpsrc = ~0;
987 break;
988
989 case RROP_COPY:
990 getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
991 break;
992
993 case RROP_INVERT:
994 getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
995 tmpsrc = ~tmpsrc;
996 break;
997 }
998
999 if (alu != GXcopy) {
1000 getbits (pdst, (x & PIM), w, tmpdst);
1001 DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1002 }
1003
1004 putbits (tmpsrc, (x & PIM), w, pdst);
1005 if((x & PIM) + w >= PPW)
1006 pdst++;
1007 } else if(((x & PIM) + w) < PPW) {
1008 /* doing < PPW bits is easy, and worth special-casing */
1009 switch (rropsOS[d]) {
1010 case RROP_BLACK:
1011 tmpsrc = 0;
1012 break;
1013 case RROP_WHITE:
1014 tmpsrc = ~0;
1015 break;
1016 case RROP_COPY:
1017 tmpsrc = *psrc;
1018 break;
1019 case RROP_INVERT:
1020 tmpsrc = ~*psrc;
1021 break;
1022 }
1023 if (alu != GXcopy) {
1024 getbits (pdst, (x & PIM), w, tmpdst);
1025 DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1026 }
1027 putbits (tmpsrc, (x & PIM), w, pdst);
1028 } else {
1029 /* start at the left edge of the tile,
1030 and put down as much as we can
1031 */
1032 maskbits(x, w, startmask, endmask, nlMiddle);
1033
1034 if (startmask)
1035 nstart = PPW - (x & PIM);
1036 else
1037 nstart = 0;
1038 if (endmask)
1039 nend = (x + w) & PIM;
1040 else
1041 nend = 0;
1042
1043 srcStartOver = nstart > PLST;
1044
1045 if(startmask) {
1046 switch (rropsOS[d]) {
1047 case RROP_BLACK:
1048 tmpsrc = 0;
1049 break;
1050 case RROP_WHITE:
1051 tmpsrc = ~0;
1052 break;
1053 case RROP_COPY:
1054 tmpsrc = *psrc;
1055 break;
1056 case RROP_INVERT:
1057 tmpsrc = ~*psrc;
1058 break;
1059 }
1060 if (alu != GXcopy) {
1061 getbits (pdst, (x & PIM), nstart, tmpdst);
1062 DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1063 }
1064 putbits (tmpsrc, (x & PIM), nstart, pdst);
1065 pdst++;
1066 if(srcStartOver)
1067 psrc++;
1068 }
1069
1070 while(nlMiddle--) {
1071 switch (rropsOS[d]) {
1072 case RROP_BLACK:
1073 tmpsrc = 0;
1074 break;
1075 case RROP_WHITE:
1076 tmpsrc = ~0;
1077 break;
1078 case RROP_COPY:
1079 getbits (psrc, nstart, PPW, tmpsrc);
1080 break;
1081 case RROP_INVERT:
1082 getbits (psrc, nstart, PPW, tmpsrc);
1083 tmpsrc = ~tmpsrc;
1084 break;
1085 }
1086 if (alu != GXcopy) {
1087 tmpdst = *pdst;
1088 DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1089 }
1090 *pdst++ = tmpsrc;
1091 /*putbits (tmpsrc, 0, PPW, pdst);
1092 pdst++;*/
1093 psrc++;
1094 }
1095 if(endmask) {
1096 switch (rropsOS[d]) {
1097 case RROP_BLACK:
1098 tmpsrc = 0;
1099 break;
1100 case RROP_WHITE:
1101 tmpsrc = ~0;
1102 break;
1103
1104 case RROP_COPY:
1105 getbits (psrc, nstart, nend, tmpsrc);
1106 break;
1107
1108 case RROP_INVERT:
1109 getbits (psrc, nstart, nend, tmpsrc);
1110 tmpsrc = ~tmpsrc;
1111 break;
1112 }
1113 if (alu != GXcopy) {
1114 tmpdst = *pdst;
1115 DoRop (tmpsrc, alu, tmpsrc, tmpdst);
1116 }
1117 putbits (tmpsrc, 0, nend, pdst);
1118 }
1119 }
1120 x += w;
1121 width -= w;
1122 }
1123 }
1124 }
1125 ppt++;
1126 pwidth++;
1127 }
1128 xfree(pptFree);
1129 xfree(pwidthFree);
1130}
diff --git a/afb/afbfont.c b/afb/afbfont.c
deleted file mode 100644
index 11a449423..000000000
--- a/afb/afbfont.c
+++ /dev/null
@@ -1,77 +0,0 @@
1/*
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47*/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <X11/X.h>
54#include <X11/Xmd.h>
55#include <X11/Xproto.h>
56#include "afb.h"
57#include <X11/fonts/fontstruct.h>
58#include "dixfontstr.h"
59#include "scrnintstr.h"
60
61/*ARGSUSED*/
62Bool
63afbRealizeFont( pscr, pFont)
64 ScreenPtr pscr;
65 FontPtr pFont;
66{
67 return (TRUE);
68}
69
70/*ARGSUSED*/
71Bool
72afbUnrealizeFont( pscr, pFont)
73 ScreenPtr pscr;
74 FontPtr pFont;
75{
76 return (TRUE);
77}
diff --git a/afb/afbgc.c b/afb/afbgc.c
deleted file mode 100644
index 1d1fdc58b..000000000
--- a/afb/afbgc.c
+++ /dev/null
@@ -1,685 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <string.h>
54
55#include <X11/X.h>
56#include <X11/Xmd.h>
57#include <X11/Xproto.h>
58#include "afb.h"
59#include "dixfontstr.h"
60#include <X11/fonts/fontstruct.h>
61#include "gcstruct.h"
62#include "windowstr.h"
63#include "pixmapstr.h"
64#include "scrnintstr.h"
65#include "region.h"
66
67#include "mistruct.h"
68#include "migc.h"
69
70#include "maskbits.h"
71
72static void afbDestroyGC(GCPtr);
73static void afbValidateGC(GCPtr, unsigned long, DrawablePtr);
74
75static GCFuncs afbFuncs = {
76 afbValidateGC,
77 miChangeGC,
78 miCopyGC,
79 afbDestroyGC,
80 miChangeClip,
81 miDestroyClip,
82 miCopyClip
83};
84
85static GCOps afbGCOps = {
86 afbSolidFS,
87 afbSetSpans,
88 afbPutImage,
89 afbCopyArea,
90 miCopyPlane,
91 afbPolyPoint,
92 afbLineSS,
93 afbSegmentSS,
94 miPolyRectangle,
95 afbZeroPolyArcSS,
96 afbFillPolygonSolid,
97 afbPolyFillRect,
98 afbPolyFillArcSolid,
99 miPolyText8,
100 miPolyText16,
101 miImageText8,
102 miImageText16,
103 afbTEGlyphBlt,
104 afbPolyGlyphBlt,
105 afbPushPixels
106};
107
108static void
109afbReduceOpaqueStipple(PixelType fg, PixelType bg, unsigned long planemask,
110 int depth, unsigned char *rop)
111{
112 register int d;
113 register Pixel mask = 1;
114
115 bg ^= fg;
116
117 for (d = 0; d < depth; d++, mask <<= 1) {
118 if (!(planemask & mask))
119 rop[d] = RROP_NOP;
120 else if (!(bg & mask)) {
121 /* Both fg and bg have a 0 or 1 in this plane */
122 if (fg & mask)
123 rop[d] = RROP_WHITE;
124 else
125 rop[d] = RROP_BLACK;
126 } else {
127 /* Both fg and bg have different bits on this plane */
128 if (fg & mask)
129 rop[d] = RROP_COPY;
130 else
131 rop[d] = RROP_INVERT;
132 }
133 }
134}
135
136Bool
137afbCreateGC(pGC)
138 register GCPtr pGC;
139{
140 afbPrivGC *pPriv;
141
142 pGC->clientClip = NULL;
143 pGC->clientClipType = CT_NONE;
144
145 /* some of the output primitives aren't really necessary, since
146 they will be filled in ValidateGC because of dix/CreateGC()
147 setting all the change bits. Others are necessary because although
148 they depend on being a monochrome frame buffer, they don't change
149 */
150
151 pGC->ops = &afbGCOps;
152 pGC->funcs = &afbFuncs;
153
154 /* afb wants to translate before scan convesion */
155 pGC->miTranslate = 1;
156
157 pPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
158 afbGCPrivateKey);
159 afbReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
160 pPriv->rrops);
161 afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
162 pGC->depth, pPriv->rropOS);
163
164 pGC->fExpose = TRUE;
165 pGC->pRotatedPixmap = NullPixmap;
166 pGC->freeCompClip = FALSE;
167 return TRUE;
168}
169
170static void
171afbComputeCompositeClip(GCPtr pGC, DrawablePtr pDrawable)
172{
173 if (pDrawable->type == DRAWABLE_WINDOW) {
174 WindowPtr pWin = (WindowPtr) pDrawable;
175 RegionPtr pregWin;
176 Bool freeTmpClip, freeCompClip;
177
178 if (pGC->subWindowMode == IncludeInferiors) {
179 pregWin = NotClippedByChildren(pWin);
180 freeTmpClip = TRUE;
181 } else {
182 pregWin = &pWin->clipList;
183 freeTmpClip = FALSE;
184 }
185 freeCompClip = pGC->freeCompClip;
186
187 /*
188 * if there is no client clip, we can get by with just keeping the
189 * pointer we got, and remembering whether or not should destroy (or
190 * maybe re-use) it later. this way, we avoid unnecessary copying of
191 * regions. (this wins especially if many clients clip by children
192 * and have no client clip.)
193 */
194 if (pGC->clientClipType == CT_NONE) {
195 if (freeCompClip)
196 REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
197 pGC->pCompositeClip = pregWin;
198 pGC->freeCompClip = freeTmpClip;
199 } else {
200 /*
201 * we need one 'real' region to put into the composite clip. if
202 * pregWin the current composite clip are real, we can get rid of
203 * one. if pregWin is real and the current composite clip isn't,
204 * use pregWin for the composite clip. if the current composite
205 * clip is real and pregWin isn't, use the current composite
206 * clip. if neither is real, create a new region.
207 */
208
209 REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
210 pDrawable->x + pGC->clipOrg.x,
211 pDrawable->y + pGC->clipOrg.y);
212
213 if (freeCompClip) {
214 REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip, pregWin,
215 pGC->clientClip);
216 if (freeTmpClip)
217 REGION_DESTROY(pGC->pScreen, pregWin);
218 } else if (freeTmpClip) {
219 REGION_INTERSECT(pGC->pScreen, pregWin, pregWin, pGC->clientClip);
220 pGC->pCompositeClip = pregWin;
221 } else {
222 pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, NullBox, 0);
223 REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
224 pregWin, pGC->clientClip);
225 }
226 pGC->freeCompClip = TRUE;
227 REGION_TRANSLATE(pGC->pScreen, pGC->clientClip,
228 -(pDrawable->x + pGC->clipOrg.x),
229 -(pDrawable->y + pGC->clipOrg.y));
230 }
231 } /* end of composite clip for a window */
232 else {
233 BoxRec pixbounds;
234
235 /* XXX should we translate by drawable.x/y here ? */
236 pixbounds.x1 = 0;
237 pixbounds.y1 = 0;
238 pixbounds.x2 = pDrawable->width;
239 pixbounds.y2 = pDrawable->height;
240
241 if (pGC->freeCompClip) {
242 REGION_RESET(pGC->pScreen, pGC->pCompositeClip, &pixbounds);
243 } else {
244 pGC->freeCompClip = TRUE;
245 pGC->pCompositeClip = REGION_CREATE(pGC->pScreen, &pixbounds, 1);
246 }
247
248 if (pGC->clientClipType == CT_REGION) {
249 REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, -pGC->clipOrg.x,
250 -pGC->clipOrg.y);
251 REGION_INTERSECT(pGC->pScreen, pGC->pCompositeClip,
252 pGC->pCompositeClip, pGC->clientClip);
253 REGION_TRANSLATE(pGC->pScreen, pGC->pCompositeClip, pGC->clipOrg.x,
254 pGC->clipOrg.y);
255 }
256 } /* end of composite clip for pixmap */
257} /* end afbComputeCompositeClip */
258
259/* Clipping conventions
260 if the drawable is a window
261 CT_REGION ==> pCompositeClip really is the composite
262 CT_other ==> pCompositeClip is the window clip region
263 if the drawable is a pixmap
264 CT_REGION ==> pCompositeClip is the translated client region
265 clipped to the pixmap boundary
266 CT_other ==> pCompositeClip is the pixmap bounding box
267*/
268
269/*ARGSUSED*/
270static void
271afbValidateGC(pGC, changes, pDrawable)
272 register GCPtr pGC;
273 unsigned long changes;
274 DrawablePtr pDrawable;
275{
276 register afbPrivGCPtr devPriv;
277 int mask; /* stateChanges */
278 int index; /* used for stepping through bitfields */
279 int xrot, yrot; /* rotations for tile and stipple pattern */
280 /* flags for changing the proc vector
281 and updating things in devPriv
282 */
283 int new_rotate, new_rrop, new_line, new_text, new_fill;
284 DDXPointRec oldOrg; /* origin of thing GC was last used with */
285
286 oldOrg = pGC->lastWinOrg;
287
288 pGC->lastWinOrg.x = pDrawable->x;
289 pGC->lastWinOrg.y = pDrawable->y;
290
291 /* we need to re-rotate the tile if the previous window/pixmap
292 origin (oldOrg) differs from the new window/pixmap origin
293 (pGC->lastWinOrg)
294 */
295 new_rotate = (oldOrg.x != pGC->lastWinOrg.x) ||
296 (oldOrg.y != pGC->lastWinOrg.y);
297
298
299 devPriv = (afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
300 afbGCPrivateKey);
301
302 /*
303 if the client clip is different or moved OR
304 the subwindowMode has changed OR
305 the window's clip has changed since the last validation
306 we need to recompute the composite clip
307 */
308 if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
309 (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS)))
310 afbComputeCompositeClip(pGC, pDrawable);
311
312 new_rrop = FALSE;
313 new_line = FALSE;
314 new_text = FALSE;
315 new_fill = FALSE;
316
317 mask = changes;
318 while (mask) {
319 index = lowbit(mask);
320 mask &= ~index;
321
322 /* this switch acculmulates a list of which procedures
323 might have to change due to changes in the GC. in
324 some cases (e.g. changing one 16 bit tile for another)
325 we might not really need a change, but the code is
326 being paranoid.
327 this sort of batching wins if, for example, the alu
328 and the font have been changed, or any other pair
329 of items that both change the same thing.
330 */
331 switch (index) {
332 case GCPlaneMask:
333 case GCFunction:
334 case GCForeground:
335 new_rrop = TRUE;
336 break;
337 case GCBackground:
338 new_rrop = TRUE; /* for opaque stipples */
339 break;
340 case GCLineStyle:
341 case GCLineWidth:
342 case GCJoinStyle:
343 new_line = TRUE;
344 break;
345 case GCCapStyle:
346 break;
347 case GCFillStyle:
348 new_fill = TRUE;
349 break;
350 case GCFillRule:
351 break;
352 case GCTile:
353 if(pGC->tileIsPixel)
354 break;
355 new_rotate = TRUE;
356 new_fill = TRUE;
357 break;
358
359 case GCStipple:
360 if(pGC->stipple == (PixmapPtr)NULL)
361 break;
362 new_rotate = TRUE;
363 new_fill = TRUE;
364 break;
365
366 case GCTileStipXOrigin:
367 new_rotate = TRUE;
368 break;
369
370 case GCTileStipYOrigin:
371 new_rotate = TRUE;
372 break;
373
374 case GCFont:
375 new_text = TRUE;
376 break;
377 case GCSubwindowMode:
378 break;
379 case GCGraphicsExposures:
380 break;
381 case GCClipXOrigin:
382 break;
383 case GCClipYOrigin:
384 break;
385 case GCClipMask:
386 break;
387 case GCDashOffset:
388 break;
389 case GCDashList:
390 break;
391 case GCArcMode:
392 break;
393 default:
394 break;
395 }
396 }
397
398 /* deal with the changes we've collected .
399 new_rrop must be done first because subsequent things
400 depend on it.
401 */
402
403 if(new_rotate || new_fill) {
404 Bool new_pix = FALSE;
405
406 /* figure out how much to rotate */
407 xrot = pGC->patOrg.x;
408 yrot = pGC->patOrg.y;
409 xrot += pDrawable->x;
410 yrot += pDrawable->y;
411
412 switch (pGC->fillStyle) {
413 case FillTiled:
414 /* copy current tile and stipple */
415 if (!pGC->tileIsPixel &&
416 (pGC->tile.pixmap->drawable.width <= PPW) &&
417 !(pGC->tile.pixmap->drawable.width &
418 (pGC->tile.pixmap->drawable.width - 1))) {
419 afbCopyRotatePixmap(pGC->tile.pixmap, &pGC->pRotatedPixmap,
420 xrot, yrot);
421 new_pix = TRUE;
422 }
423 break;
424 case FillStippled:
425 case FillOpaqueStippled:
426 if (pGC->stipple && (pGC->stipple->drawable.width <= PPW) &&
427 !(pGC->stipple->drawable.width &
428 (pGC->stipple->drawable.width - 1))) {
429 afbCopyRotatePixmap(pGC->stipple, &pGC->pRotatedPixmap,
430 xrot, yrot);
431 new_pix = TRUE;
432 }
433 }
434 /* destroy any previously rotated tile or stipple */
435 if (!new_pix && pGC->pRotatedPixmap) {
436 (*pDrawable->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
437 pGC->pRotatedPixmap = (PixmapPtr)NULL;
438 }
439 }
440
441 /*
442 * duck out here when the GC is unchanged
443 */
444
445 if (!changes)
446 return;
447
448 if (new_rrop || new_fill) {
449 afbReduceRop(pGC->alu, pGC->fgPixel, pGC->planemask, pDrawable->depth,
450 devPriv->rrops);
451 afbReduceOpaqueStipple(pGC->fgPixel, pGC->bgPixel, pGC->planemask,
452 pGC->depth, devPriv->rropOS);
453 new_fill = TRUE;
454 }
455
456 if (new_line || new_fill || new_text) {
457 if (!pGC->ops->devPrivate.val) {
458 pGC->ops = miCreateGCOps(pGC->ops);
459 pGC->ops->devPrivate.val = 1;
460 }
461 }
462
463 if (new_line || new_fill) {
464 if (pGC->lineWidth == 0) {
465 if (pGC->lineStyle == LineSolid && pGC->fillStyle == FillSolid)
466 pGC->ops->PolyArc = afbZeroPolyArcSS;
467 else
468 pGC->ops->PolyArc = miZeroPolyArc;
469 } else
470 pGC->ops->PolyArc = miPolyArc;
471 if (pGC->lineStyle == LineSolid) {
472 if(pGC->lineWidth == 0) {
473 if (pGC->fillStyle == FillSolid) {
474 pGC->ops->PolySegment = afbSegmentSS;
475 pGC->ops->Polylines = afbLineSS;
476 }
477 else
478 {
479 pGC->ops->PolySegment = miPolySegment;
480 pGC->ops->Polylines = miZeroLine;
481 }
482 } else {
483 pGC->ops->PolySegment = miPolySegment;
484 pGC->ops->Polylines = miWideLine;
485 }
486 } else {
487 if(pGC->lineWidth == 0 && pGC->fillStyle == FillSolid) {
488 pGC->ops->PolySegment = afbSegmentSD;
489 pGC->ops->Polylines = afbLineSD;
490 } else {
491 pGC->ops->PolySegment = miPolySegment;
492 pGC->ops->Polylines = miWideDash;
493 }
494 }
495 }
496
497 if (new_text || new_fill) {
498 if ((pGC->font) &&
499 (FONTMAXBOUNDS(pGC->font,rightSideBearing) -
500 FONTMINBOUNDS(pGC->font,leftSideBearing) > 32 ||
501 FONTMINBOUNDS(pGC->font,characterWidth) < 0)) {
502 pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
503 pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
504 } else {
505 /* special case ImageGlyphBlt for terminal emulator fonts */
506 if ((pGC->font) &&
507 TERMINALFONT(pGC->font)) {
508 pGC->ops->ImageGlyphBlt = afbTEGlyphBlt;
509 } else {
510 pGC->ops->ImageGlyphBlt = afbImageGlyphBlt;
511 }
512
513 /* now do PolyGlyphBlt */
514 if (pGC->fillStyle == FillSolid) {
515 pGC->ops->PolyGlyphBlt = afbPolyGlyphBlt;
516 } else {
517 pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
518 }
519 }
520 }
521
522 if (new_fill) {
523 /* install a suitable fillspans and pushpixels */
524 pGC->ops->PushPixels = afbPushPixels;
525 pGC->ops->FillPolygon = miFillPolygon;
526 pGC->ops->PolyFillArc = miPolyFillArc;
527
528 switch (pGC->fillStyle) {
529 case FillSolid:
530 pGC->ops->FillSpans = afbSolidFS;
531 pGC->ops->FillPolygon = afbFillPolygonSolid;
532 pGC->ops->PolyFillArc = afbPolyFillArcSolid;
533 break;
534 case FillTiled:
535 if (pGC->pRotatedPixmap)
536 pGC->ops->FillSpans = afbTileFS;
537 else
538 pGC->ops->FillSpans = afbUnnaturalTileFS;
539 break;
540 case FillOpaqueStippled:
541 if (pGC->pRotatedPixmap)
542 pGC->ops->FillSpans = afbOpaqueStippleFS;
543 else
544 pGC->ops->FillSpans = afbUnnaturalOpaqueStippleFS;
545 break;
546
547 case FillStippled:
548 if (pGC->pRotatedPixmap)
549 pGC->ops->FillSpans = afbStippleFS;
550 else
551 pGC->ops->FillSpans = afbUnnaturalStippleFS;
552 break;
553 }
554 } /* end of new_fill */
555}
556
557static void
558afbDestroyGC(pGC)
559 GCPtr pGC;
560{
561 if (pGC->pRotatedPixmap)
562 (*pGC->pScreen->DestroyPixmap)(pGC->pRotatedPixmap);
563 if (pGC->freeCompClip)
564 REGION_DESTROY(pGC->pScreen, pGC->pCompositeClip);
565 miDestroyGCOps(pGC->ops);
566}
567
568void
569afbReduceRop(alu, src, planemask, depth, rop)
570 register int alu;
571 register Pixel src;
572 register unsigned long planemask;
573 int depth;
574 register unsigned char *rop;
575{
576 register int d;
577 register Pixel mask = 1;
578
579 for (d = 0; d < depth; d++, mask <<= 1) {
580 if (!(planemask & mask))
581 rop[d] = RROP_NOP;
582 else if ((src & mask) == 0) /* src is black */
583 switch (alu) {
584 case GXclear:
585 rop[d] = RROP_BLACK;
586 break;
587 case GXand:
588 rop[d] = RROP_BLACK;
589 break;
590 case GXandReverse:
591 rop[d] = RROP_BLACK;
592 break;
593 case GXcopy:
594 rop[d] = RROP_BLACK;
595 break;
596 case GXandInverted:
597 rop[d] = RROP_NOP;
598 break;
599 case GXnoop:
600 rop[d] = RROP_NOP;
601 break;
602 case GXxor:
603 rop[d] = RROP_NOP;
604 break;
605 case GXor:
606 rop[d] = RROP_NOP;
607 break;
608 case GXnor:
609 rop[d] = RROP_INVERT;
610 break;
611 case GXequiv:
612 rop[d] = RROP_INVERT;
613 break;
614 case GXinvert:
615 rop[d] = RROP_INVERT;
616 break;
617 case GXorReverse:
618 rop[d] = RROP_INVERT;
619 break;
620 case GXcopyInverted:
621 rop[d] = RROP_WHITE;
622 break;
623 case GXorInverted:
624 rop[d] = RROP_WHITE;
625 break;
626 case GXnand:
627 rop[d] = RROP_WHITE;
628 break;
629 case GXset:
630 rop[d] = RROP_WHITE;
631 break;
632 }
633 else /* src is white */
634 switch (alu) {
635 case GXclear:
636 rop[d] = RROP_BLACK;
637 break;
638 case GXand:
639 rop[d] = RROP_NOP;
640 break;
641 case GXandReverse:
642 rop[d] = RROP_INVERT;
643 break;
644 case GXcopy:
645 rop[d] = RROP_WHITE;
646 break;
647 case GXandInverted:
648 rop[d] = RROP_BLACK;
649 break;
650 case GXnoop:
651 rop[d] = RROP_NOP;
652 break;
653 case GXxor:
654 rop[d] = RROP_INVERT;
655 break;
656 case GXor:
657 rop[d] = RROP_WHITE;
658 break;
659 case GXnor:
660 rop[d] = RROP_BLACK;
661 break;
662 case GXequiv:
663 rop[d] = RROP_NOP;
664 break;
665 case GXinvert:
666 rop[d] = RROP_INVERT;
667 break;
668 case GXorReverse:
669 rop[d] = RROP_WHITE;
670 break;
671 case GXcopyInverted:
672 rop[d] = RROP_BLACK;
673 break;
674 case GXorInverted:
675 rop[d] = RROP_NOP;
676 break;
677 case GXnand:
678 rop[d] = RROP_INVERT;
679 break;
680 case GXset:
681 rop[d] = RROP_WHITE;
682 break;
683 }
684 }
685}
diff --git a/afb/afbgetsp.c b/afb/afbgetsp.c
deleted file mode 100644
index 8d1db1482..000000000
--- a/afb/afbgetsp.c
+++ /dev/null
@@ -1,165 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xmd.h>
56
57#include "misc.h"
58#include "region.h"
59#include "gc.h"
60#include "windowstr.h"
61#include "pixmapstr.h"
62#include "scrnintstr.h"
63
64#include "afb.h"
65#include "maskbits.h"
66
67#include "servermd.h"
68
69/* GetSpans -- for each span, gets bits from drawable starting at ppt[i]
70 * and continuing for pwidth[i] bits
71 * Each scanline returned will be server scanline padded, i.e., it will come
72 * out to an integral number of words.
73 */
74/*ARGSUSED*/
75void
76afbGetSpans(pDrawable, wMax, ppt, pwidth, nspans, pchardstStart)
77 DrawablePtr pDrawable; /* drawable from which to get bits */
78 int wMax; /* largest value of all *pwidths */
79 register DDXPointPtr ppt; /* points to start copying from */
80 int *pwidth; /* list of number of bits to copy */
81 int nspans; /* number of scanlines to copy */
82 char *pchardstStart; /* where to put the bits */
83{
84 PixelType *pdstStart = (PixelType *)pchardstStart;
85 register PixelType *pdst; /* where to put the bits */
86 register PixelType *psrc; /* where to get the bits */
87 register PixelType tmpSrc; /* scratch buffer for bits */
88 PixelType *psrcBase; /* start of src bitmap */
89 int widthSrc; /* width of pixmap in bytes */
90 int sizeSrc;
91 int depthSrc;
92 register DDXPointPtr pptLast; /* one past last point to get */
93 int xEnd; /* last pixel to copy from */
94 register int nstart;
95 register int d;
96 int nend = 0;
97 int srcStartOver;
98 PixelType startmask, endmask;
99 unsigned int srcBit;
100 int nlMiddle, nl;
101 int w;
102
103 pptLast = ppt + nspans;
104
105 afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthSrc, sizeSrc, depthSrc,
106 psrcBase);
107 pdst = pdstStart;
108
109 while(ppt < pptLast) {
110 /* XXX should this really be << PWSH, or * 8, or * PGSZB? */
111 xEnd = min(ppt->x + *pwidth, widthSrc << PWSH);
112 pwidth++;
113 for (d = 0; d < depthSrc; d++) {
114 psrc = afbScanline(psrcBase, ppt->x, ppt->y, widthSrc);
115 psrcBase += sizeSrc; /* @@@ NEXT PLANE @@@ */
116 w = xEnd - ppt->x;
117 srcBit = ppt->x & PIM;
118
119 if (srcBit + w <= PPW)
120 {
121 getandputbits0(psrc, srcBit, w, pdst);
122 pdst++;
123 }
124 else
125 {
126
127 maskbits(ppt->x, w, startmask, endmask, nlMiddle);
128 if (startmask)
129 nstart = PPW - srcBit;
130 else
131 nstart = 0;
132 if (endmask)
133 nend = xEnd & PIM;
134 srcStartOver = srcBit + nstart > PLST;
135 if (startmask)
136 {
137 getandputbits0(psrc, srcBit, nstart, pdst);
138 if(srcStartOver)
139 psrc++;
140 }
141 nl = nlMiddle;
142#ifdef FASTPUTBITS
143 Duff(nl, putbits(*psrc, nstart, PPW, pdst); psrc++; pdst++;);
144#else
145 while (nl--)
146 {
147 tmpSrc = *psrc;
148 putbits(tmpSrc, nstart, PPW, pdst);
149 psrc++;
150 pdst++;
151 }
152#endif
153 if (endmask)
154 {
155 putbits(*psrc, nstart, nend, pdst);
156 if(nstart + nend > PPW)
157 pdst++;
158 }
159 if (startmask || endmask)
160 pdst++;
161 }
162 }
163 ppt++;
164 }
165}
diff --git a/afb/afbhrzvert.c b/afb/afbhrzvert.c
deleted file mode 100644
index 8f332e6d8..000000000
--- a/afb/afbhrzvert.c
+++ /dev/null
@@ -1,209 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55
56#include "gc.h"
57#include "window.h"
58#include "pixmap.h"
59#include "region.h"
60
61#include "afb.h"
62#include "maskbits.h"
63
64/* horizontal solid line
65 abs(len) > 1
66*/
67void
68afbHorzS(pbase, nlwidth, sizeDst, depthDst, x1, y1, len, rrops)
69PixelType *pbase; /* pointer to base of bitmap */
70register int nlwidth; /* width in longwords of bitmap */
71int sizeDst;
72int depthDst;
73int x1; /* initial point */
74int y1;
75int len; /* length of line */
76register unsigned char *rrops;
77{
78 register PixelType *addrl;
79 register PixelType startmask;
80 register PixelType endmask;
81 register int nlmiddle;
82 register int d;
83 int saveNLmiddle;
84
85 /* force the line to go left to right
86 but don't draw the last point
87 */
88 if (len < 0) {
89 x1 += len;
90 x1 += 1;
91 len = -len;
92 }
93
94 /* all bits inside same longword */
95 if ( ((x1 & PIM) + len) < PPW) {
96 maskpartialbits(x1, len, startmask);
97
98 for (d = 0; d < depthDst; d++) {
99 addrl = afbScanline(pbase, x1, y1, nlwidth);
100 pbase += sizeDst; /* @@@ NEXT PLANE @@@ */
101
102 switch (rrops[d]) {
103 case RROP_BLACK:
104 *addrl &= ~startmask;
105 break;
106 case RROP_WHITE:
107 *addrl |= startmask;
108 break;
109 case RROP_INVERT:
110 *addrl ^= startmask;
111 break;
112 case RROP_NOP:
113 break;
114 } /* switch */
115 } /* for (d = ...) */
116 } else {
117 maskbits(x1, len, startmask, endmask, nlmiddle);
118 saveNLmiddle = nlmiddle;
119
120 for (d = 0; d < depthDst; d++) {
121 addrl = afbScanline(pbase, x1, y1, nlwidth);
122 pbase += sizeDst; /* @@@ NEXT PLANE @@@ */
123 nlmiddle = saveNLmiddle;
124
125 switch (rrops[d]) {
126 case RROP_BLACK:
127 if (startmask)
128 *addrl++ &= ~startmask;
129 Duff (nlmiddle, *addrl++ = 0x0);
130 if (endmask)
131 *addrl &= ~endmask;
132 break;
133
134 case RROP_WHITE:
135 if (startmask)
136 *addrl++ |= startmask;
137 Duff (nlmiddle, *addrl++ = ~0);
138 if (endmask)
139 *addrl |= endmask;
140 break;
141
142 case RROP_INVERT:
143 if (startmask)
144 *addrl++ ^= startmask;
145 Duff (nlmiddle, *addrl++ ^= ~0);
146 if (endmask)
147 *addrl ^= endmask;
148 break;
149
150 case RROP_NOP:
151 break;
152 } /* switch */
153 } /* for (d = ... ) */
154 }
155}
156
157/* vertical solid line
158 this uses do loops because pcc (Ultrix 1.2, bsd 4.2) generates
159 better code. sigh. we know that len will never be 0 or 1, so
160 it's OK to use it.
161*/
162void
163afbVertS(pbase, nlwidth, sizeDst, depthDst, x1, y1, len, rrops)
164PixelType *pbase; /* pointer to base of bitmap */
165register int nlwidth; /* width in longwords of bitmap */
166int sizeDst;
167int depthDst;
168int x1, y1; /* initial point */
169register int len; /* length of line */
170unsigned char *rrops;
171{
172 register PixelType *addrl;
173 register PixelType bitmask;
174 int saveLen;
175 int d;
176
177 if (len < 0) {
178 nlwidth = -nlwidth;
179 len = -len;
180 }
181
182 saveLen = len;
183
184 for (d = 0; d < depthDst; d++) {
185 addrl = afbScanline(pbase, x1, y1, nlwidth);
186 pbase += sizeDst; /* @@@ NEXT PLANE @@@ */
187 len = saveLen;
188
189 switch (rrops[d]) {
190 case RROP_BLACK:
191 bitmask = mfbGetrmask(x1 & PIM);
192 Duff(len, *addrl &= bitmask; afbScanlineInc(addrl, nlwidth) );
193 break;
194
195 case RROP_WHITE:
196 bitmask = mfbGetmask(x1 & PIM);
197 Duff(len, *addrl |= bitmask; afbScanlineInc(addrl, nlwidth) );
198 break;
199
200 case RROP_INVERT:
201 bitmask = mfbGetmask(x1 & PIM);
202 Duff(len, *addrl ^= bitmask; afbScanlineInc(addrl, nlwidth) );
203 break;
204
205 case RROP_NOP:
206 break;
207 } /* switch */
208 } /* for (d = ...) */
209}
diff --git a/afb/afbimage.c b/afb/afbimage.c
deleted file mode 100644
index 890429fe6..000000000
--- a/afb/afbimage.c
+++ /dev/null
@@ -1,272 +0,0 @@
1
2#ifdef HAVE_DIX_CONFIG_H
3#include <dix-config.h>
4#endif
5
6#include <string.h>
7
8#include <X11/X.h>
9#include "windowstr.h"
10#include "pixmapstr.h"
11#include "scrnintstr.h"
12#include "gcstruct.h"
13#include "afb.h"
14#include "maskbits.h"
15#include "servermd.h"
16#include "mfb.h"
17
18void
19afbPutImage(pDraw, pGC, depth, x, y, width, height, leftPad, format, pImage)
20 DrawablePtr pDraw;
21 GCPtr pGC;
22 int depth, x, y, width, height;
23 int leftPad;
24 int format;
25 char *pImage;
26{
27 PixmapPtr pPixmap;
28
29 if ((width == 0) || (height == 0))
30 return;
31
32 if (format != ZPixmap || depth == 1 || pDraw->depth == 1) {
33 pPixmap = GetScratchPixmapHeader(pDraw->pScreen, width+leftPad, height,
34 depth, depth,
35 BitmapBytePad(width+leftPad),
36 (pointer)pImage);
37 if (!pPixmap)
38 return;
39
40 pGC->fExpose = FALSE;
41 if (format == XYBitmap)
42 (void)(*pGC->ops->CopyPlane)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
43 0, width, height, x, y, 1);
44 else {
45 (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC, leftPad,
46 0, width, height, x, y);
47 }
48
49 pGC->fExpose = TRUE;
50 FreeScratchPixmapHeader(pPixmap);
51 } else {
52 /* Chunky to planar conversion required */
53
54 PixmapPtr pPixmap;
55 ScreenPtr pScreen = pDraw->pScreen;
56 int widthSrc;
57 int start_srcshift;
58 register int b;
59 register int dstshift;
60 register int shift_step;
61 register PixelType dst;
62 register PixelType srcbits;
63 register PixelType *pdst;
64 register PixelType *psrc;
65 int start_bit;
66 register int nl;
67 register int h;
68 register int d;
69 int sizeDst;
70 PixelType *pdstBase;
71 int widthDst;
72 int depthDst;
73
74 /* Create a tmp pixmap */
75 pPixmap = (pScreen->CreatePixmap)(pScreen, width, height, depth,
76 CREATE_PIXMAP_USAGE_SCRATCH);
77 if (!pPixmap)
78 return;
79
80 afbGetPixelWidthSizeDepthAndPointer((DrawablePtr)pPixmap, widthDst,
81 sizeDst, depthDst, pdstBase);
82
83 widthSrc = PixmapWidthInPadUnits(width, depth);
84 /* XXX: if depth == 8, use fast chunky to planar assembly function.*/
85 if (depth > 4) {
86 start_srcshift = 24;
87 shift_step = 8;
88 } else {
89 start_srcshift = 28;
90 shift_step = 4;
91 }
92
93 for (d = 0; d < depth; d++, pdstBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
94 start_bit = start_srcshift + d;
95 psrc = (PixelType *)pImage;
96 pdst = pdstBase;
97 h = height;
98
99 while (h--) {
100 dstshift = PPW - 1;
101 dst = 0;
102 nl = widthSrc;
103 while (nl--) {
104 srcbits = *psrc++;
105 for (b = start_bit; b >= 0; b -= shift_step) {
106 dst |= ((srcbits >> b) & 1) << dstshift;
107 if (--dstshift < 0) {
108 dstshift = PPW - 1;
109 *pdst++ = dst;
110 dst = 0;
111 }
112 }
113 }
114 if (dstshift != PPW - 1)
115 *pdst++ = dst;
116 }
117 } /* for (d = ...) */
118
119 pGC->fExpose = FALSE;
120 (void)(*pGC->ops->CopyArea)((DrawablePtr)pPixmap, pDraw, pGC, leftPad, 0,
121 width, height, x, y);
122 pGC->fExpose = TRUE;
123 (*pScreen->DestroyPixmap)(pPixmap);
124 }
125}
126
127void
128afbGetImage(pDrawable, sx, sy, width, height, format, planemask, pdstLine)
129 DrawablePtr pDrawable;
130 int sx, sy, width, height;
131 unsigned int format;
132 unsigned long planemask;
133 char *pdstLine;
134{
135 BoxRec box;
136 DDXPointRec ptSrc;
137 RegionRec rgnDst;
138 ScreenPtr pScreen;
139 PixmapPtr pPixmap;
140
141 if ((width == 0) || (height == 0))
142 return;
143
144 pScreen = pDrawable->pScreen;
145 sx += pDrawable->x;
146 sy += pDrawable->y;
147
148 if (format == XYPixmap || pDrawable->depth == 1) {
149 pPixmap = GetScratchPixmapHeader(pScreen, width, height, 1, 1,
150 BitmapBytePad(width), (pointer)pdstLine);
151 if (!pPixmap)
152 return;
153
154 ptSrc.x = sx;
155 ptSrc.y = sy;
156 box.x1 = 0;
157 box.y1 = 0;
158 box.x2 = width;
159 box.y2 = height;
160 REGION_INIT(pScreen, &rgnDst, &box, 1);
161
162 pPixmap->drawable.depth = 1;
163 pPixmap->drawable.bitsPerPixel = 1;
164 /* dix layer only ever calls GetImage with 1 bit set in planemask
165 * when format is XYPixmap.
166 */
167 afbDoBitblt(pDrawable, (DrawablePtr)pPixmap, GXcopy, &rgnDst, &ptSrc,
168 planemask);
169
170 FreeScratchPixmapHeader(pPixmap);
171 REGION_UNINIT(pScreen, &rgnDst);
172 } else {
173 /* Planar to chunky conversion required */
174
175 PixelType *psrcBits;
176 PixelType *psrcLine;
177 PixelType startmask, endmask;
178 int depthSrc;
179 int widthSrc;
180 int sizeSrc;
181 int sizeDst;
182 int widthDst;
183 register PixelType *psrc;
184 register PixelType *pdst;
185 register PixelType dst;
186 register PixelType srcbits;
187 register int d;
188 register int b;
189 register int dstshift;
190 register int shift_step;
191 register int start_endbit;
192 int start_startbit;
193 register int end_endbit = 0;
194 register int start_dstshift;
195 register int nl;
196 register int h;
197 int nlmiddle;
198
199 widthDst = PixmapWidthInPadUnits(width, pDrawable->depth);
200 sizeDst = widthDst * height;
201
202 /* Clear the dest image */
203 bzero(pdstLine, sizeDst << 2);
204
205 afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthSrc, sizeSrc,
206 depthSrc, psrcBits);
207
208 psrcBits = afbScanline(psrcBits, sx, sy, widthSrc);
209
210 start_startbit = PPW - 1 - (sx & PIM);
211 if ((sx & PIM) + width < PPW) {
212 maskpartialbits(sx, width, startmask);
213 nlmiddle = 0;
214 endmask = 0;
215 start_endbit = PPW - ((sx + width) & PIM);
216 } else {
217 maskbits(sx, width, startmask, endmask, nlmiddle);
218 start_endbit = 0;
219 end_endbit = PPW - ((sx + width) & PIM);
220 }
221 /* ZPixmap images have either 4 or 8 bits per pixel dependent on
222 * depth.
223 */
224 if (depthSrc > 4) {
225 start_dstshift = 24;
226 shift_step = 8;
227 } else {
228 start_dstshift = 28;
229 shift_step = 4;
230 }
231#define SHIFT_BITS(start_bit,end_bit) \
232for (b = (start_bit); b >= (end_bit); b--) { \
233 dst |= ((srcbits >> b) & 1) << dstshift; \
234 if ((dstshift -= shift_step) < 0) { \
235 dstshift = start_dstshift + d; \
236 *pdst++ = dst; \
237 dst = *pdst; \
238 } \
239} \
240
241 for (d = 0; d < depthSrc; d++, psrcBits += sizeSrc) { /* @@@ NEXT PLANE @@@ */
242 psrcLine = psrcBits;
243 pdst = (PixelType *)pdstLine;
244 h = height;
245
246 while (h--) {
247 psrc = psrcLine;
248 psrcLine += widthSrc;
249 dst = *pdst;
250 dstshift = start_dstshift + d;
251
252 if (startmask) {
253 srcbits = *psrc++ & startmask;
254 SHIFT_BITS(start_startbit, start_endbit);
255 }
256
257 nl = nlmiddle;
258 while (nl--) {
259 srcbits = *psrc++;
260 SHIFT_BITS(PPW - 1, 0);
261 }
262 if (endmask) {
263 srcbits = *psrc & endmask;
264 SHIFT_BITS(PPW - 1, end_endbit);
265 }
266
267 if (dstshift != start_dstshift + d)
268 *pdst++ = dst;
269 } /* while (h--) */
270 } /* for (d = ...) */
271 }
272}
diff --git a/afb/afbimggblt.c b/afb/afbimggblt.c
deleted file mode 100644
index 36818ac50..000000000
--- a/afb/afbimggblt.c
+++ /dev/null
@@ -1,472 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xmd.h>
56#include <X11/Xproto.h>
57#include "afb.h"
58#include <X11/fonts/fontstruct.h>
59#include "dixfontstr.h"
60#include "gcstruct.h"
61#include "windowstr.h"
62#include "scrnintstr.h"
63#include "pixmapstr.h"
64#include "regionstr.h"
65#include "maskbits.h"
66
67/*
68 we should eventually special-case fixed-width fonts for ImageText.
69
70 this works for fonts with glyphs <= 32 bits wide.
71
72 the clipping calculations are done for worst-case fonts.
73we make no assumptions about the heights, widths, or bearings
74of the glyphs. if we knew that the glyphs are all the same height,
75we could clip the tops and bottoms per clipping box, rather
76than per character per clipping box. if we knew that the glyphs'
77left and right bearings were wlle-behaved, we could clip a single
78character at the start, output until the last unclipped
79character, and then clip the last one. this is all straightforward
80to determine based on max-bounds and min-bounds from the font.
81 there is some inefficiency introduced in the per-character
82clipping to make what's going on clearer.
83
84 (it is possible, for example, for a font to be defined in which the
85next-to-last character in a font would be clipped out, but the last
86one wouldn't. the code below deals with this.)
87
88 Image text looks at the bits in the glyph and the fg and bg in the
89GC. it paints a rectangle, as defined in the protocol dcoument,
90and the paints the characters.
91
92 the register allocations for startmask and endmask may not
93be the right thing. are there two other deserving candidates?
94xoff, pdst, pglyph, and tmpSrc seem like the right things, though.
95*/
96
97void
98afbImageGlyphBlt(pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
99 DrawablePtr pDrawable;
100 GC *pGC;
101 int x, y;
102 unsigned int nglyph;
103 CharInfoPtr *ppci; /* array of character info */
104 pointer pglyphBase; /* start of array of glyphs */
105{
106 ExtentInfoRec info; /* used by QueryGlyphExtents() */
107 BoxRec bbox; /* string's bounding box */
108 xRectangle backrect;/* backing rectangle to paint.
109 in the general case, NOT necessarily
110 the same as the string's bounding box
111 */
112
113 CharInfoPtr pci;
114 int xorg, yorg; /* origin of drawable in bitmap */
115 int widthDst; /* width of dst in longwords */
116
117 /* these keep track of the character origin */
118 PixelType *pdstBase;
119 /* points to longword with character origin */
120 int xchar; /* xorigin of char (mod 32) */
121
122 /* these are used for placing the glyph */
123 register int xoff; /* x offset of left edge of glyph (mod 32) */
124 register PixelType *pdst;
125 /* pointer to current longword in dst */
126
127 register int d;
128 int depthDst;
129 int sizeDst;
130 int hSave;
131 int w; /* width of glyph in bits */
132 int h; /* height of glyph */
133 int widthGlyph; /* width of glyph, in bytes */
134 unsigned char rrops[AFB_MAX_DEPTH];
135 register unsigned char *pglyph;
136 /* pointer to current row of glyph */
137 unsigned char *pglyphSave;
138
139 /* used for putting down glyph */
140 register PixelType tmpSrc;
141 /* for getting bits from glyph */
142 register PixelType startmask;
143 register PixelType endmask;
144
145 register int nFirst;/* bits of glyph in current longword */
146 PixelType *pdstSave;
147 int oldFill;
148 afbPrivGC *pPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
149 afbGCPrivateKey);
150 xorg = pDrawable->x;
151 yorg = pDrawable->y;
152 afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
153 pdstBase);
154
155 QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
156
157 backrect.x = x;
158 backrect.y = y - FONTASCENT(pGC->font);
159 backrect.width = info.overallWidth;
160 backrect.height = FONTASCENT(pGC->font) + FONTDESCENT(pGC->font);
161
162 x += xorg;
163 y += yorg;
164
165 bbox.x1 = x + info.overallLeft;
166 bbox.x2 = x + info.overallRight;
167 bbox.y1 = y - info.overallAscent;
168 bbox.y2 = y + info.overallDescent;
169
170 oldFill = pGC->fillStyle;
171 pGC->fillStyle = FillSolid;
172 afbReduceRop (pGC->alu, pGC->bgPixel, pGC->planemask, pGC->depth,
173 pPriv->rrops);
174 afbPolyFillRect(pDrawable, pGC, 1, &backrect);
175 pGC->fillStyle = oldFill;
176 afbReduceRop (pGC->alu, pGC->fgPixel, pGC->planemask, pGC->depth,
177 pPriv->rrops);
178 afbReduceRop (GXcopy, pGC->fgPixel, pGC->planemask, pGC->depth, rrops);
179
180 /* the faint-hearted can open their eyes now */
181
182 switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
183 case rgnOUT:
184 break;
185 case rgnIN:
186 pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
187 xchar = x & PIM;
188
189 while(nglyph--) {
190 pci = *ppci;
191 pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
192 w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
193 hSave = pci->metrics.ascent + pci->metrics.descent;
194 widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
195 /* start at top scanline of glyph */
196 pdstSave = afbScanlineDelta(pdstBase, -pci->metrics.ascent,
197 widthDst);
198
199 /* find correct word in scanline and x offset within it
200 for left edge of glyph
201 */
202 xoff = xchar + pci->metrics.leftSideBearing;
203 if (xoff > PLST) {
204 pdstSave++;
205 xoff &= PIM;
206 } else if (xoff < 0) {
207 xoff += PPW;
208 pdstSave--;
209 }
210
211 for (d = 0; d < depthDst; d++) {
212 h = hSave;
213 pdst = pdstSave;
214 pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
215 pglyph = pglyphSave;
216
217 if ((xoff + w) <= PPW) {
218 /* glyph all in one longword */
219 maskpartialbits(xoff, w, startmask);
220
221 switch (rrops[d]) {
222 case RROP_BLACK:
223 while (h--) {
224 getleftbits(pglyph, w, tmpSrc);
225 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
226 pglyph += widthGlyph;
227 afbScanlineInc(pdst, widthDst);
228 }
229 break;
230 case RROP_WHITE:
231 while (h--) {
232 getleftbits(pglyph, w, tmpSrc);
233 *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
234 pglyph += widthGlyph;
235 afbScanlineInc(pdst, widthDst);
236 }
237 break;
238 case RROP_NOP:
239 break;
240 }
241 } else {
242 /* glyph crosses longword boundary */
243 maskPPWbits(xoff, w, startmask, endmask);
244 nFirst = PPW - xoff;
245
246 switch (rrops[d]) {
247 case RROP_BLACK:
248 while (h--) {
249 getleftbits(pglyph, w, tmpSrc);
250 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
251 *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
252 pglyph += widthGlyph;
253 afbScanlineInc(pdst, widthDst);
254 }
255 break;
256 case RROP_WHITE:
257 while (h--) {
258 getleftbits(pglyph, w, tmpSrc);
259 *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
260 *(pdst+1) |= SCRLEFT(tmpSrc, nFirst) & endmask;
261 pglyph += widthGlyph;
262 afbScanlineInc(pdst, widthDst);
263 }
264 break;
265 case RROP_NOP:
266 break;
267 }
268 } /* glyph crosses longwords boundary */
269 } /* depth loop */
270 /* update character origin */
271 x += pci->metrics.characterWidth;
272 xchar += pci->metrics.characterWidth;
273 if (xchar > PLST) {
274 xchar -= PPW;
275 pdstBase++;
276 } else if (xchar < 0) {
277 xchar += PPW;
278 pdstBase--;
279 }
280 ppci++;
281 } /* while nglyph-- */
282 break;
283 case rgnPART:
284 {
285 afbTEXTPOS *ppos;
286 int nbox;
287 BoxPtr pbox;
288 RegionPtr cclip;
289 int xpos; /* x position of char origin */
290 int i;
291 BoxRec clip;
292 int leftEdge, rightEdge;
293 int topEdge, bottomEdge;
294 int glyphRow; /* first row of glyph not wholly
295 clipped out */
296 int glyphCol; /* leftmost visible column of glyph */
297#if GETLEFTBITS_ALIGNMENT > 1
298 int getWidth; /* bits to get from glyph */
299#endif
300
301 if(!(ppos = (afbTEXTPOS *)xalloc(nglyph * sizeof(afbTEXTPOS))))
302 return;
303
304 pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
305 xpos = x;
306 xchar = xpos & PIM;
307
308 for (i = 0; i < nglyph; i++) {
309 pci = ppci[i];
310
311 ppos[i].xpos = xpos;
312 ppos[i].xchar = xchar;
313 ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
314 ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
315 ppos[i].topEdge = y - pci->metrics.ascent;
316 ppos[i].bottomEdge = y + pci->metrics.descent;
317 ppos[i].pdstBase = pdstBase;
318 ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
319
320 xpos += pci->metrics.characterWidth;
321 xchar += pci->metrics.characterWidth;
322 if (xchar > PLST) {
323 xchar &= PIM;
324 pdstBase++;
325 } else if (xchar < 0) {
326 xchar += PPW;
327 pdstBase--;
328 }
329 }
330
331 cclip = pGC->pCompositeClip;
332 pbox = REGION_RECTS(cclip);
333 nbox = REGION_NUM_RECTS(cclip);
334
335 /* HACK ALERT
336 since we continue out of the loop below so often, it
337 is easier to increment pbox at the top than at the end.
338 don't try this at home.
339 */
340 pbox--;
341 while(nbox--) {
342 pbox++;
343 clip.x1 = max(bbox.x1, pbox->x1);
344 clip.y1 = max(bbox.y1, pbox->y1);
345 clip.x2 = min(bbox.x2, pbox->x2);
346 clip.y2 = min(bbox.y2, pbox->y2);
347 if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
348 continue;
349
350 for(i=0; i<nglyph; i++) {
351 pci = ppci[i];
352 xchar = ppos[i].xchar;
353
354 /* clip the left and right edges */
355 if (ppos[i].leftEdge < clip.x1)
356 leftEdge = clip.x1;
357 else
358 leftEdge = ppos[i].leftEdge;
359
360 if (ppos[i].rightEdge > clip.x2)
361 rightEdge = clip.x2;
362 else
363 rightEdge = ppos[i].rightEdge;
364
365 w = rightEdge - leftEdge;
366 if (w <= 0)
367 continue;
368
369 /* clip the top and bottom edges */
370 if (ppos[i].topEdge < clip.y1)
371 topEdge = clip.y1;
372 else
373 topEdge = ppos[i].topEdge;
374
375 if (ppos[i].bottomEdge > clip.y2)
376 bottomEdge = clip.y2;
377 else
378 bottomEdge = ppos[i].bottomEdge;
379
380 hSave = bottomEdge - topEdge;
381 if (hSave <= 0)
382 continue;
383
384 glyphRow = (topEdge - y) + pci->metrics.ascent;
385 widthGlyph = ppos[i].widthGlyph;
386 pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
387 pglyphSave += (glyphRow * widthGlyph);
388
389 glyphCol = (leftEdge - ppos[i].xpos) -
390 (pci->metrics.leftSideBearing);
391#if GETLEFTBITS_ALIGNMENT > 1
392 getWidth = w + glyphCol;
393#endif
394
395 pdstSave = afbScanlineDelta(ppos[i].pdstBase, -(y-topEdge),
396 widthDst);
397 xoff = xchar + (leftEdge - ppos[i].xpos);
398 if (xoff > PLST) {
399 xoff &= PIM;
400 pdstSave++;
401 } else if (xoff < 0) {
402 xoff += PPW;
403 pdstSave--;
404 }
405
406 for (d = 0; d < depthDst; d++) {
407 h = hSave;
408 pdst = pdstSave;
409 pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
410 pglyph = pglyphSave;
411
412 if ((xoff + w) <= PPW) {
413 maskpartialbits(xoff, w, startmask);
414
415 switch (rrops[d]) {
416 case RROP_BLACK:
417 while (h--) {
418 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
419 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
420 pglyph += widthGlyph;
421 afbScanlineInc(pdst, widthDst);
422 }
423 break;
424 case RROP_WHITE:
425 while (h--) {
426 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
427 *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
428 pglyph += widthGlyph;
429 afbScanlineInc(pdst, widthDst);
430 }
431 break;
432 case RROP_NOP:
433 break;
434 }
435 } else {
436 maskPPWbits(xoff, w, startmask, endmask);
437 nFirst = PPW - xoff;
438
439 switch (rrops[d]) {
440 case RROP_BLACK:
441 while (h--) {
442 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
443 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
444 *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
445 pglyph += widthGlyph;
446 afbScanlineInc(pdst, widthDst);
447 }
448 break;
449 case RROP_WHITE:
450 while (h--) {
451 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
452 *pdst |= SCRRIGHT(tmpSrc, xoff) & startmask;
453 *(pdst+1) |= SCRLEFT(tmpSrc, nFirst) & endmask;
454 pglyph += widthGlyph;
455 afbScanlineInc(pdst, widthDst);
456 }
457 break;
458 case RROP_NOP:
459 break;
460 }
461 }
462 } /* depth */
463 } /* for each glyph */
464 } /* while nbox-- */
465 xfree(ppos);
466 break;
467 }
468
469 default:
470 break;
471 }
472}
diff --git a/afb/afbline.c b/afb/afbline.c
deleted file mode 100644
index d05675869..000000000
--- a/afb/afbline.c
+++ /dev/null
@@ -1,707 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <X11/X.h>
54#include <stdlib.h>
55
56#include "gcstruct.h"
57#include "windowstr.h"
58#include "pixmapstr.h"
59#include "regionstr.h"
60#include "scrnintstr.h"
61#include "mistruct.h"
62
63#include "afb.h"
64#include "maskbits.h"
65#include "miline.h"
66
67/* single-pixel lines on a color frame buffer
68
69 NON-SLOPED LINES
70 horizontal lines are always drawn left to right; we have to
71move the endpoints right by one after they're swapped.
72 horizontal lines will be confined to a single band of a
73region. the code finds that band (giving up if the lower
74bound of the band is above the line we're drawing); then it
75finds the first box in that band that contains part of the
76line. we clip the line to subsequent boxes in that band.
77 vertical lines are always drawn top to bottom (y-increasing.)
78this requires adding one to the y-coordinate of each endpoint
79after swapping.
80
81 SLOPED LINES
82 when clipping a sloped line, we bring the second point inside
83the clipping box, rather than one beyond it, and then add 1 to
84the length of the line before drawing it. this lets us use
85the same box for finding the outcodes for both endpoints. since
86the equation for clipping the second endpoint to an edge gives us
871 beyond the edge, we then have to move the point towards the
88first point by one step on the major axis.
89 eventually, there will be a diagram here to explain what's going
90on. the method uses Cohen-Sutherland outcodes to determine
91outsideness, and a method similar to Pike's layers for doing the
92actual clipping.
93
94*/
95
96void
97#ifdef POLYSEGMENT
98afbSegmentSS(pDrawable, pGC, nseg, pSeg)
99 DrawablePtr pDrawable;
100 GCPtr pGC;
101 int nseg;
102 register xSegment *pSeg;
103#else
104afbLineSS(pDrawable, pGC, mode, npt, pptInit)
105 DrawablePtr pDrawable;
106 GCPtr pGC;
107 int mode; /* Origin or Previous */
108 int npt; /* number of points */
109 DDXPointPtr pptInit;
110#endif
111{
112 int nboxInit;
113 register int nbox;
114 BoxPtr pboxInit;
115 register BoxPtr pbox;
116#ifndef POLYSEGMENT
117 register DDXPointPtr ppt; /* pointer to list of translated points */
118#endif
119
120 unsigned int oc1; /* outcode of point 1 */
121 unsigned int oc2; /* outcode of point 2 */
122
123 PixelType *addrlBase; /* pointer to start of drawable */
124 int nlwidth; /* width in longwords of destination pixmap */
125 int xorg, yorg; /* origin of window */
126
127 int adx; /* abs values of dx and dy */
128 int ady;
129 int signdx; /* sign of dx and dy */
130 int signdy;
131 int e, e1, e2; /* bresenham error and increments */
132 int len; /* length of segment */
133 int axis; /* major axis */
134 int octant;
135 unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
136 int depthDst;
137#ifndef POLYSEGMENT
138 PixelType *addrl; /* address of destination pixmap */
139 int d;
140#endif
141 int sizeDst;
142 unsigned char *rrops;
143
144 /* a bunch of temporaries */
145 register int y1, y2;
146 register int x1, x2;
147 RegionPtr cclip;
148
149 cclip = pGC->pCompositeClip;
150 rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
151 afbGCPrivateKey))->rrops;
152 pboxInit = REGION_RECTS(cclip);
153 nboxInit = REGION_NUM_RECTS(cclip);
154
155 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
156 addrlBase);
157
158 xorg = pDrawable->x;
159 yorg = pDrawable->y;
160#ifdef POLYSEGMENT
161 while (nseg--)
162#else
163 ppt = pptInit;
164 x2 = ppt->x + xorg;
165 y2 = ppt->y + yorg;
166 while(--npt)
167#endif
168 {
169 nbox = nboxInit;
170 pbox = pboxInit;
171
172#ifdef POLYSEGMENT
173 x1 = pSeg->x1 + xorg;
174 y1 = pSeg->y1 + yorg;
175 x2 = pSeg->x2 + xorg;
176 y2 = pSeg->y2 + yorg;
177 pSeg++;
178#else
179 x1 = x2;
180 y1 = y2;
181 ++ppt;
182 if (mode == CoordModePrevious) {
183 xorg = x1;
184 yorg = y1;
185 }
186 x2 = ppt->x + xorg;
187 y2 = ppt->y + yorg;
188#endif
189
190 if (x1 == x2) /* vertical line */
191 {
192 /* make the line go top to bottom of screen, keeping
193 endpoint semantics
194 */
195 if (y1 > y2) {
196 register int tmp;
197
198 tmp = y2;
199 y2 = y1 + 1;
200 y1 = tmp + 1;
201#ifdef POLYSEGMENT
202 if (pGC->capStyle != CapNotLast)
203 y1--;
204#endif
205 }
206#ifdef POLYSEGMENT
207 else if (pGC->capStyle != CapNotLast)
208 y2++;
209#endif
210 /* get to first band that might contain part of line */
211 while ((nbox) && (pbox->y2 <= y1)) {
212 pbox++;
213 nbox--;
214 }
215
216 if (nbox) {
217 /* stop when lower edge of box is beyond end of line */
218 while((nbox) && (y2 >= pbox->y1)) {
219 if ((x1 >= pbox->x1) && (x1 < pbox->x2)) {
220 int y1t, y2t;
221 /* this box has part of the line in it */
222 y1t = max(y1, pbox->y1);
223 y2t = min(y2, pbox->y2);
224 if (y1t != y2t)
225 afbVertS(addrlBase, nlwidth, sizeDst, depthDst, x1, y1t,
226 y2t-y1t, rrops); /* @@@ NEXT PLANE PASSED @@@ */
227 }
228 nbox--;
229 pbox++;
230 }
231 }
232#ifndef POLYSEGMENT
233 y2 = ppt->y + yorg;
234#endif
235 } else if (y1 == y2) /* horizontal line */ {
236 /* force line from left to right, keeping
237 endpoint semantics
238 */
239 if (x1 > x2) {
240 register int tmp;
241
242 tmp = x2;
243 x2 = x1 + 1;
244 x1 = tmp + 1;
245#ifdef POLYSEGMENT
246 if (pGC->capStyle != CapNotLast)
247 x1--;
248#endif
249 }
250#ifdef POLYSEGMENT
251 else if (pGC->capStyle != CapNotLast)
252 x2++;
253#endif
254
255 /* find the correct band */
256 while( (nbox) && (pbox->y2 <= y1)) {
257 pbox++;
258 nbox--;
259 }
260
261 /* try to draw the line, if we haven't gone beyond it */
262 if ((nbox) && (pbox->y1 <= y1)) {
263 int tmp;
264
265 /* when we leave this band, we're done */
266 tmp = pbox->y1;
267 while((nbox) && (pbox->y1 == tmp)) {
268 int x1t, x2t;
269
270 if (pbox->x2 <= x1) {
271 /* skip boxes until one might contain start point */
272 nbox--;
273 pbox++;
274 continue;
275 }
276
277 /* stop if left of box is beyond right of line */
278 if (pbox->x1 >= x2) {
279 nbox = 0;
280 break;
281 }
282
283 x1t = max(x1, pbox->x1);
284 x2t = min(x2, pbox->x2);
285 if (x1t != x2t)
286 afbHorzS(addrlBase, nlwidth, sizeDst, depthDst, x1t, y1,
287 x2t-x1t, rrops); /* @@@ NEXT PLANE PASSED @@@ */
288 nbox--;
289 pbox++;
290 }
291 }
292#ifndef POLYSEGMENT
293 x2 = ppt->x + xorg;
294#endif
295 }
296 else /* sloped line */
297 {
298 CalcLineDeltas(x1, y1, x2, y2, adx, ady,
299 signdx, signdy, 1, 1, octant);
300
301 if (adx > ady) {
302 axis = X_AXIS;
303 e1 = ady << 1;
304 e2 = e1 - (adx << 1);
305 e = e1 - adx;
306 } else {
307 axis = Y_AXIS;
308 e1 = adx << 1;
309 e2 = e1 - (ady << 1);
310 e = e1 - ady;
311 SetYMajorOctant(octant);
312 }
313
314 FIXUP_ERROR(e, octant, bias);
315
316 /* we have bresenham parameters and two points.
317 all we have to do now is clip and draw.
318 */
319
320 while(nbox--) {
321 oc1 = 0;
322 oc2 = 0;
323 OUTCODES(oc1, x1, y1, pbox);
324 OUTCODES(oc2, x2, y2, pbox);
325 if ((oc1 | oc2) == 0) {
326 if (axis == X_AXIS)
327 len = adx;
328 else
329 len = ady;
330#ifdef POLYSEGMENT
331 if (pGC->capStyle != CapNotLast)
332 len++;
333#endif
334 afbBresS(addrlBase, nlwidth, sizeDst, depthDst, signdx, signdy,
335 axis, x1, y1, e, e1, e2, len, rrops); /* @@@ NEXT PLANE PASSED @@@ */
336 break;
337 } else if (oc1 & oc2) {
338 pbox++;
339 } else {
340 int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
341 int clip1 = 0, clip2 = 0;
342 int clipdx, clipdy;
343 int err;
344
345 if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1,
346 pbox->y2-1,
347 &new_x1, &new_y1, &new_x2, &new_y2,
348 adx, ady, &clip1, &clip2,
349 octant, bias, oc1, oc2) == -1) {
350 pbox++;
351 continue;
352 }
353
354 if (axis == X_AXIS)
355 len = abs(new_x2 - new_x1);
356 else
357 len = abs(new_y2 - new_y1);
358#ifdef POLYSEGMENT
359 if (clip2 != 0 || pGC->capStyle != CapNotLast)
360 len++;
361#else
362 len += (clip2 != 0);
363#endif
364 if (len) {
365 /* unwind bresenham error term to first point */
366 if (clip1) {
367 clipdx = abs(new_x1 - x1);
368 clipdy = abs(new_y1 - y1);
369 if (axis == X_AXIS)
370 err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
371 else
372 err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
373 }
374 else
375 err = e;
376 afbBresS(addrlBase, nlwidth, sizeDst, depthDst, signdx,
377 signdy, axis, new_x1, new_y1, err, e1, e2, len,
378 rrops); /* @@@ NEXT PLANE PASSED @@@ */
379 }
380 pbox++;
381 }
382 } /* while (nbox--) */
383 } /* sloped line */
384 } /* while (nline--) */
385
386#ifndef POLYSEGMENT
387
388 /* paint the last point if the end style isn't CapNotLast.
389 (Assume that a projecting, butt, or round cap that is one
390 pixel wide is the same as the single pixel of the endpoint.)
391 */
392
393 if ((pGC->capStyle != CapNotLast) &&
394 ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
395 (ppt->y + yorg != pptInit->y + pDrawable->y) ||
396 (ppt == pptInit + 1))) {
397 nbox = nboxInit;
398 pbox = pboxInit;
399 while (nbox--) {
400 if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && (x2 < pbox->x2) &&
401 (y2 < pbox->y2)) {
402 for (d = 0; d < depthDst; d++) {
403 addrl = afbScanline(addrlBase, x2, y2, nlwidth);
404 addrlBase += sizeDst; /* @@@ NEXT PLANE @@@ */
405
406 switch(rrops[d]) {
407 case RROP_BLACK:
408 *addrl &= mfbGetrmask(x2 & PIM);
409 break;
410 case RROP_WHITE:
411 *addrl |= mfbGetmask(x2 & PIM);
412 break;
413 case RROP_INVERT:
414 *addrl ^= mfbGetmask(x2 & PIM);
415 break;
416 case RROP_NOP:
417 break;
418 } /* switch */
419 } /* for (d = ...) */
420 break;
421 } else
422 pbox++;
423 }
424 }
425#endif
426}
427
428/*
429 * Draw dashed 1-pixel lines.
430 */
431
432void
433#ifdef POLYSEGMENT
434afbSegmentSD(pDrawable, pGC, nseg, pSeg)
435 DrawablePtr pDrawable;
436 register GCPtr pGC;
437 int nseg;
438 register xSegment *pSeg;
439#else
440afbLineSD(pDrawable, pGC, mode, npt, pptInit)
441 DrawablePtr pDrawable;
442 register GCPtr pGC;
443 int mode; /* Origin or Previous */
444 int npt; /* number of points */
445 DDXPointPtr pptInit;
446#endif
447{
448 int nboxInit;
449 register int nbox;
450 BoxPtr pboxInit;
451 register BoxPtr pbox;
452#ifndef POLYSEGMENT
453 register DDXPointPtr ppt; /* pointer to list of translated points */
454#endif
455
456 register unsigned int oc1; /* outcode of point 1 */
457 register unsigned int oc2; /* outcode of point 2 */
458
459 PixelType *addrlBase; /* address of destination pixmap */
460 int nlwidth; /* width in longwords of destination pixmap */
461 int sizeDst;
462 int depthDst;
463 int xorg, yorg; /* origin of window */
464
465 int adx; /* abs values of dx and dy */
466 int ady;
467 int signdx; /* sign of dx and dy */
468 int signdy;
469 int e, e1, e2; /* bresenham error and increments */
470 int len; /* length of segment */
471 int axis; /* major axis */
472 int octant;
473 unsigned int bias = miGetZeroLineBias(pDrawable->pScreen);
474 int x1, x2, y1, y2;
475 RegionPtr cclip;
476 unsigned char *rrops;
477 unsigned char bgrrops[AFB_MAX_DEPTH];
478 unsigned char *pDash;
479 int dashOffset;
480 int numInDashList;
481 int dashIndex;
482 int isDoubleDash;
483 int dashIndexTmp, dashOffsetTmp;
484 int unclippedlen;
485#ifndef POLYSEGMENT
486 PixelType *addrl;
487 int d;
488#endif
489
490 cclip = pGC->pCompositeClip;
491 rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
492 afbGCPrivateKey))->rrops;
493 pboxInit = REGION_RECTS(cclip);
494 nboxInit = REGION_NUM_RECTS(cclip);
495
496 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
497 addrlBase);
498
499 /* compute initial dash values */
500
501 pDash = (unsigned char *) pGC->dash;
502 numInDashList = pGC->numInDashList;
503 isDoubleDash = (pGC->lineStyle == LineDoubleDash);
504 dashIndex = 0;
505 dashOffset = 0;
506 miStepDash ((int)pGC->dashOffset, &dashIndex, pDash,
507 numInDashList, &dashOffset);
508
509 if (isDoubleDash)
510 afbReduceRop (pGC->alu, pGC->bgPixel, pGC->planemask, pGC->depth,
511 bgrrops);
512
513 xorg = pDrawable->x;
514 yorg = pDrawable->y;
515#ifdef POLYSEGMENT
516 while (nseg--)
517#else
518 ppt = pptInit;
519 x2 = ppt->x + xorg;
520 y2 = ppt->y + yorg;
521 while(--npt)
522#endif
523 {
524 nbox = nboxInit;
525 pbox = pboxInit;
526
527#ifdef POLYSEGMENT
528 x1 = pSeg->x1 + xorg;
529 y1 = pSeg->y1 + yorg;
530 x2 = pSeg->x2 + xorg;
531 y2 = pSeg->y2 + yorg;
532 pSeg++;
533#else
534 x1 = x2;
535 y1 = y2;
536 ++ppt;
537 if (mode == CoordModePrevious) {
538 xorg = x1;
539 yorg = y1;
540 }
541 x2 = ppt->x + xorg;
542 y2 = ppt->y + yorg;
543#endif
544
545 CalcLineDeltas(x1, y1, x2, y2, adx, ady, signdx, signdy,
546 1, 1, octant);
547
548 if (adx > ady) {
549 axis = X_AXIS;
550 e1 = ady << 1;
551 e2 = e1 - (adx << 1);
552 e = e1 - adx;
553 unclippedlen = adx;
554 } else {
555 axis = Y_AXIS;
556 e1 = adx << 1;
557 e2 = e1 - (ady << 1);
558 e = e1 - ady;
559 unclippedlen = ady;
560 SetYMajorOctant(octant);
561 }
562
563 FIXUP_ERROR(e, octant, bias);
564
565 /* we have bresenham parameters and two points.
566 all we have to do now is clip and draw.
567 */
568
569 while(nbox--) {
570 oc1 = 0;
571 oc2 = 0;
572 OUTCODES(oc1, x1, y1, pbox);
573 OUTCODES(oc2, x2, y2, pbox);
574 if ((oc1 | oc2) == 0) {
575#ifdef POLYSEGMENT
576 if (pGC->capStyle != CapNotLast)
577 unclippedlen++;
578 dashIndexTmp = dashIndex;
579 dashOffsetTmp = dashOffset;
580 afbBresD(&dashIndexTmp, pDash, numInDashList, &dashOffsetTmp,
581 isDoubleDash, addrlBase, nlwidth, sizeDst, depthDst,
582 signdx, signdy, axis, x1, y1, e, e1, e2, unclippedlen,
583 rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
584 break;
585#else
586 afbBresD(&dashIndex, pDash, numInDashList, &dashOffset,
587 isDoubleDash, addrlBase, nlwidth, sizeDst, depthDst,
588 signdx, signdy, axis, x1, y1, e, e1, e2, unclippedlen,
589 rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
590 goto dontStep;
591#endif
592 } else if (oc1 & oc2) {
593 pbox++;
594 } else /* have to clip */ {
595 int new_x1 = x1, new_y1 = y1, new_x2 = x2, new_y2 = y2;
596 int clip1 = 0, clip2 = 0;
597 int clipdx, clipdy;
598 int err;
599
600 if (miZeroClipLine(pbox->x1, pbox->y1, pbox->x2-1, pbox->y2-1,
601 &new_x1, &new_y1, &new_x2, &new_y2,
602 adx, ady, &clip1, &clip2,
603 octant, bias, oc1, oc2) == -1) {
604 pbox++;
605 continue;
606 }
607 dashIndexTmp = dashIndex;
608 dashOffsetTmp = dashOffset;
609 if (clip1) {
610 int dlen;
611
612 if (axis == X_AXIS)
613 dlen = abs(new_x1 - x1);
614 else
615 dlen = abs(new_y1 - y1);
616 miStepDash (dlen, &dashIndexTmp, pDash,
617 numInDashList, &dashOffsetTmp);
618 }
619 if (axis == X_AXIS)
620 len = abs(new_x2 - new_x1);
621 else
622 len = abs(new_y2 - new_y1);
623#ifdef POLYSEGMENT
624 if (clip2 != 0 || pGC->capStyle != CapNotLast)
625 len++;
626#else
627 len += (clip2 != 0);
628#endif
629 if (len) {
630 /* unwind bresenham error term to first point */
631 if (clip1) {
632 clipdx = abs(new_x1 - x1);
633 clipdy = abs(new_y1 - y1);
634 if (axis == X_AXIS)
635 err = e+((clipdy*e2) + ((clipdx-clipdy)*e1));
636 else
637 err = e+((clipdx*e2) + ((clipdy-clipdx)*e1));
638 }
639 else
640 err = e;
641 afbBresD(&dashIndexTmp, pDash, numInDashList, &dashOffsetTmp,
642 isDoubleDash, addrlBase, nlwidth, sizeDst, depthDst,
643 signdx, signdy, axis, new_x1, new_y1, err, e1, e2,
644 len, rrops, bgrrops); /* @@@ NEXT PLANE PASSED @@@ */
645 }
646 pbox++;
647 }
648 } /* while (nbox--) */
649#ifndef POLYSEGMENT
650 /*
651 * walk the dash list around to the next line
652 */
653 miStepDash (unclippedlen, &dashIndex, pDash,
654 numInDashList, &dashOffset);
655dontStep: ;
656#endif
657 } /* while (nline--) */
658
659#ifndef POLYSEGMENT
660 /* paint the last point if the end style isn't CapNotLast.
661 (Assume that a projecting, butt, or round cap that is one
662 pixel wide is the same as the single pixel of the endpoint.)
663 */
664
665 if ((pGC->capStyle != CapNotLast) &&
666 ((dashIndex & 1) == 0 || isDoubleDash) &&
667 ((ppt->x + xorg != pptInit->x + pDrawable->x) ||
668 (ppt->y + yorg != pptInit->y + pDrawable->y) ||
669 (ppt == pptInit + 1))) {
670 nbox = nboxInit;
671 pbox = pboxInit;
672 while (nbox--) {
673 if ((x2 >= pbox->x1) && (y2 >= pbox->y1) && (x2 < pbox->x2) &&
674 (y2 < pbox->y2)) {
675 int rop;
676
677 for (d = 0; d < depthDst; d++) {
678 addrl = afbScanline(addrlBase, x2, y2, nlwidth);
679 addrlBase += sizeDst; /* @@@ NEXT PLANE @@@ */
680
681 rop = rrops[d];
682 if (dashIndex & 1)
683 rop = bgrrops[d];
684
685 switch (rop) {
686 case RROP_BLACK:
687 *addrl &= mfbGetrmask(x2 & PIM);
688 break;
689 case RROP_WHITE:
690 *addrl |= mfbGetmask(x2 & PIM);
691 break;
692
693 case RROP_INVERT:
694 *addrl ^= mfbGetmask(x2 & PIM);
695 break;
696
697 case RROP_NOP:
698 break;
699 }
700 } /* for (d = ...) */
701 break;
702 } else
703 pbox++;
704 }
705 }
706#endif
707}
diff --git a/afb/afbmisc.c b/afb/afbmisc.c
deleted file mode 100644
index 8e9c9e8e9..000000000
--- a/afb/afbmisc.c
+++ /dev/null
@@ -1,94 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <X11/X.h>
54#include "misc.h"
55#include "cursor.h"
56#include "scrnintstr.h"
57
58#include "afb.h"
59
60/*ARGSUSED*/
61void
62afbQueryBestSize(class, pwidth, pheight, pScreen)
63int class;
64unsigned short *pwidth;
65unsigned short *pheight;
66ScreenPtr pScreen;
67{
68 unsigned width, test;
69
70 switch(class) {
71 case CursorShape:
72 if (*pwidth > pScreen->width)
73 *pwidth = pScreen->width;
74 if (*pheight > pScreen->height)
75 *pheight = pScreen->height;
76 break;
77 case TileShape:
78 case StippleShape:
79 width = *pwidth;
80 if (!width) break;
81 /* Return the closes power of two not less than what they gave me */
82 test = 0x80000000;
83 /* Find the highest 1 bit in the width given */
84 while(!(test & width))
85 test >>= 1;
86 /* If their number is greater than that, bump up to the next
87 * power of two */
88 if((test - 1) & width)
89 test <<= 1;
90 *pwidth = test;
91 /* We don't care what height they use */
92 break;
93 }
94}
diff --git a/afb/afbpixmap.c b/afb/afbpixmap.c
deleted file mode 100644
index ad591a1af..000000000
--- a/afb/afbpixmap.c
+++ /dev/null
@@ -1,299 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49/* pixmap management
50 written by drewry, september 1986
51
52 on a monchrome device, a pixmap is a bitmap.
53*/
54
55#ifdef HAVE_DIX_CONFIG_H
56#include <dix-config.h>
57#endif
58
59#include <string.h>
60
61#include <X11/Xmd.h>
62#include "scrnintstr.h"
63#include "pixmapstr.h"
64#include "maskbits.h"
65
66#include "afb.h"
67#include "mi.h"
68
69#include "servermd.h"
70#include "mfb.h"
71
72PixmapPtr
73afbCreatePixmap(pScreen, width, height, depth, usage_hint)
74 ScreenPtr pScreen;
75 int width;
76 int height;
77 int depth;
78 unsigned usage_hint;
79{
80 PixmapPtr pPixmap;
81 size_t datasize;
82 size_t paddedWidth;
83
84 paddedWidth = BitmapBytePad(width);
85
86 if (paddedWidth > 32767 || height > 32767 || depth > 4)
87 return NullPixmap;
88
89 datasize = height * paddedWidth * depth;
90 pPixmap = AllocatePixmap(pScreen, datasize);
91 if (!pPixmap)
92 return(NullPixmap);
93 pPixmap->drawable.type = DRAWABLE_PIXMAP;
94 pPixmap->drawable.class = 0;
95 pPixmap->drawable.pScreen = pScreen;
96 pPixmap->drawable.depth = depth;
97 pPixmap->drawable.bitsPerPixel = depth;
98 pPixmap->drawable.id = 0;
99 pPixmap->drawable.serialNumber = NEXT_SERIAL_NUMBER;
100 pPixmap->drawable.x = 0;
101 pPixmap->drawable.y = 0;
102 pPixmap->drawable.width = width;
103 pPixmap->drawable.height = height;
104 pPixmap->devKind = paddedWidth;
105 pPixmap->refcnt = 1;
106 pPixmap->devPrivate.ptr = datasize ?
107 (pointer)((char *)pPixmap + pScreen->totalPixmapSize) : NULL;
108 pPixmap->usage_hint = usage_hint;
109 return(pPixmap);
110}
111
112Bool
113afbDestroyPixmap(pPixmap)
114 PixmapPtr pPixmap;
115{
116 if(--pPixmap->refcnt)
117 return(TRUE);
118 dixFreePrivates(pPixmap->devPrivates);
119 xfree(pPixmap);
120 return(TRUE);
121}
122
123
124static PixmapPtr
125afbCopyPixmap(PixmapPtr pSrc)
126{
127 register PixmapPtr pDst;
128 int size;
129 ScreenPtr pScreen;
130
131 size = pSrc->drawable.height * pSrc->devKind * pSrc->drawable.depth;
132 pScreen = pSrc->drawable.pScreen;
133 pDst = (*pScreen->CreatePixmap)(pScreen,
134 pSrc->drawable.width,
135 pSrc->drawable.height,
136 pSrc->drawable.depth, 0);
137 if (!pDst)
138 return(NullPixmap);
139 memmove((char *)pDst->devPrivate.ptr, (char *)pSrc->devPrivate.ptr, size);
140 return(pDst);
141}
142
143
144/* replicates a pattern to be a full 32 bits wide.
145 relies on the fact that each scnaline is longword padded.
146 doesn't do anything if pixmap is not a factor of 32 wide.
147 changes width field of pixmap if successful, so that the fast
148 XRotatePixmap code gets used if we rotate the pixmap later.
149
150 calculate number of times to repeat
151 for each scanline of pattern
152 zero out area to be filled with replicate
153 left shift and or in original as many times as needed
154*/
155static void
156afbPadPixmap(PixmapPtr pPixmap)
157{
158 register int width = pPixmap->drawable.width;
159 register int h;
160 register PixelType mask;
161 register PixelType *p;
162 register PixelType bits; /* real pattern bits */
163 register int i;
164 int d;
165 int rep; /* repeat count for pattern */
166
167 if (width >= PPW)
168 return;
169
170 rep = PPW/width;
171 if (rep*width != PPW)
172 return;
173
174 mask = mfbGetendtab(width);
175
176 p = (PixelType *)(pPixmap->devPrivate.ptr);
177
178 for (d = 0; d < pPixmap->drawable.depth; d++) {
179 for (h = 0; h < pPixmap->drawable.height; h++) {
180 *p &= mask;
181 bits = *p;
182 for(i = 1; i < rep; i++) {
183 bits = SCRRIGHT(bits, width);
184 *p |= bits;
185 }
186 p++; /* @@@ NEXT PLANE @@@ */
187 }
188 }
189 pPixmap->drawable.width = PPW;
190}
191
192/* Rotates pixmap pPix by w pixels to the right on the screen. Assumes that
193 * words are PPW bits wide, and that the least significant bit appears on the
194 * left.
195 */
196void
197afbXRotatePixmap(pPix, rw)
198 PixmapPtr pPix;
199 register int rw;
200{
201 register PixelType *pw, *pwFinal;
202 register PixelType t;
203
204 if (pPix == NullPixmap)
205 return;
206
207 pw = (PixelType *)pPix->devPrivate.ptr;
208 rw %= (int)pPix->drawable.width;
209 if (rw < 0)
210 rw += (int)pPix->drawable.width;
211 if(pPix->drawable.width == PPW) {
212 pwFinal = pw + pPix->drawable.height * pPix->drawable.depth;
213 while(pw < pwFinal) {
214 t = *pw;
215 *pw++ = SCRRIGHT(t, rw) |
216 (SCRLEFT(t, (PPW-rw)) & mfbGetendtab(rw));
217 }
218 } else {
219 /* We no longer do this. Validate doesn't try to rotate odd-size
220 * tiles or stipples. afbUnnatural<tile/stipple>FS works directly off
221 * the unrotate tile/stipple in the GC
222 */
223 ErrorF("X internal error: trying to rotate odd-sized pixmap.\n");
224 }
225
226}
227
228/* Rotates pixmap pPix by h lines. Assumes that h is always less than
229 pPix->height
230 works on any width.
231 */
232void
233afbYRotatePixmap(pPix, rh)
234 register PixmapPtr pPix;
235 int rh;
236{
237 int nbyDown; /* bytes to move down to row 0; also offset of
238 row rh */
239 int nbyUp; /* bytes to move up to line rh; also
240 offset of first line moved down to 0 */
241 char *pbase;
242 char *ptmp;
243 int height;
244 int d;
245
246 if (pPix == NullPixmap)
247 return;
248 height = (int) pPix->drawable.height;
249 rh %= height;
250 if (rh < 0)
251 rh += height;
252
253 nbyDown = rh * pPix->devKind;
254 nbyUp = (pPix->devKind * height) - nbyDown;
255
256 if(!(ptmp = (char *)xalloc(nbyUp)))
257 return;
258
259 for (d = 0; d < pPix->drawable.depth; d++) {
260 pbase = (char *)pPix->devPrivate.ptr + pPix->devKind * height * d; /* @@@ NEXT PLANE @@@ */
261
262 memmove(ptmp, pbase, nbyUp); /* save the low rows */
263 memmove(pbase, pbase+nbyUp, nbyDown); /* slide the top rows down */
264 memmove(pbase+nbyDown, ptmp, nbyUp); /* move lower rows up to row rh */
265 }
266 xfree(ptmp);
267}
268
269void
270afbCopyRotatePixmap(psrcPix, ppdstPix, xrot, yrot)
271 register PixmapPtr psrcPix, *ppdstPix;
272 int xrot, yrot;
273{
274 register PixmapPtr pdstPix;
275
276 if ((pdstPix = *ppdstPix) &&
277 (pdstPix->devKind == psrcPix->devKind) &&
278 (pdstPix->drawable.height == psrcPix->drawable.height) &&
279 (pdstPix->drawable.depth == psrcPix->drawable.depth)) {
280 memmove((char *)pdstPix->devPrivate.ptr,
281 (char *)psrcPix->devPrivate.ptr,
282 psrcPix->drawable.height * psrcPix->devKind *
283 psrcPix->drawable.depth);
284 pdstPix->drawable.width = psrcPix->drawable.width;
285 pdstPix->drawable.serialNumber = NEXT_SERIAL_NUMBER;
286 } else {
287 if (pdstPix)
288 /* FIX XBUG 6168 */
289 (*pdstPix->drawable.pScreen->DestroyPixmap)(pdstPix);
290 *ppdstPix = pdstPix = afbCopyPixmap(psrcPix);
291 if (!pdstPix)
292 return;
293 }
294 afbPadPixmap(pdstPix);
295 if (xrot)
296 afbXRotatePixmap(pdstPix, xrot);
297 if (yrot)
298 afbYRotatePixmap(pdstPix, yrot);
299}
diff --git a/afb/afbply1rct.c b/afb/afbply1rct.c
deleted file mode 100644
index e9d4d5e09..000000000
--- a/afb/afbply1rct.c
+++ /dev/null
@@ -1,300 +0,0 @@
1/*
2 *
3Copyright (c) 1990 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25 *
26 * Author: Keith Packard, MIT X Consortium
27 */
28
29#ifdef HAVE_DIX_CONFIG_H
30#include <dix-config.h>
31#endif
32
33#include <stdlib.h>
34
35#include <X11/X.h>
36
37#include "gcstruct.h"
38#include "windowstr.h"
39#include "pixmapstr.h"
40#include "regionstr.h"
41#include "scrnintstr.h"
42#include "mistruct.h"
43
44#include "afb.h"
45#include "maskbits.h"
46
47#if defined(mips) || defined(sparc)
48#define GetHighWord(x) (((int)(x)) >> 16)
49#else
50#define GetHighWord(x) (((int)(x)) / 65536)
51#endif
52
53#if IMAGE_BYTE_ORDER == MSBFirst
54#define intToCoord(i,x,y) (((x) = GetHighWord(i)), ((y) = (int)((short) (i))))
55#define coordToInt(x,y) (((x) << 16) | (y))
56#define intToX(i) (GetHighWord(i))
57#define intToY(i) ((int)((short) i))
58#else
59#define intToCoord(i,x,y) (((x) = (int)((short) (i))), ((y) = GetHighWord(i)))
60#define coordToInt(x,y) (((y) << 16) | (x))
61#define intToX(i) ((int)((short) (i)))
62#define intToY(i) (GetHighWord(i))
63#endif
64
65void
66afbFillPolygonSolid (pDrawable, pGC, shape, mode, count, ptsIn)
67 DrawablePtr pDrawable;
68 GCPtr pGC;
69 int shape;
70 int mode;
71 int count;
72 DDXPointPtr ptsIn;
73{
74 afbPrivGCPtr devPriv;
75 int nlwidth;
76 PixelType *addrl, *addr;
77 int maxy;
78 int origin;
79 register int vertex1, vertex2;
80 int c;
81 BoxPtr extents;
82 int clip;
83 int y;
84 int *vertex1p = NULL, *vertex2p;
85 int *endp;
86 int x1 = 0, x2 = 0;
87 int dx1 = 0, dx2 = 0;
88 int dy1 = 0, dy2 = 0;
89 int e1 = 0, e2 = 0;
90 int step1 = 0, step2 = 0;
91 int sign1 = 0, sign2 = 0;
92 int h;
93 int l, r;
94 PixelType mask, bits = ~((PixelType)0);
95 int nmiddle;
96 register unsigned char *rrops;
97 register int n;
98 register int d;
99 int sizeDst;
100 int depthDst;
101 register PixelType *pdst;
102
103 devPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
104 afbGCPrivateKey);
105 if (mode == CoordModePrevious || shape != Convex ||
106 REGION_NUM_RECTS(pGC->pCompositeClip) != 1) {
107 miFillPolygon (pDrawable, pGC, shape, mode, count, ptsIn);
108 return;
109 }
110 origin = *((int *) &pDrawable->x);
111 origin -= (origin & 0x8000) << 1;
112 extents = &pGC->pCompositeClip->extents;
113 vertex1 = *((int *) &extents->x1) - origin;
114 vertex2 = *((int *) &extents->x2) - origin - 0x00010001;
115 clip = 0;
116 y = 32767;
117 maxy = 0;
118 vertex2p = (int *) ptsIn;
119 endp = vertex2p + count;
120 while (count--) {
121 c = *vertex2p;
122 clip |= (c - vertex1) | (vertex2 - c);
123 c = intToY(c);
124 if (c < y) {
125 y = c;
126 vertex1p = vertex2p;
127 }
128 vertex2p++;
129 if (c > maxy)
130 maxy = c;
131 }
132 if (y == maxy)
133 return;
134
135 if (clip & 0x80008000) {
136 miFillPolygon (pDrawable, pGC, shape, mode, vertex2p - (int *) ptsIn, ptsIn);
137 return;
138 }
139
140 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
141 addrl);
142 rrops = devPriv->rrops;
143 addrl = afbScanlineDelta(addrl, y + pDrawable->y, nlwidth);
144 origin = intToX(origin);
145 vertex2p = vertex1p;
146 vertex2 = vertex1 = *vertex2p++;
147 if (vertex2p == endp)
148 vertex2p = (int *) ptsIn;
149#define Setup(c,x,vertex,dx,dy,e,sign,step) {\
150 x = intToX(vertex); \
151 if ((dy = intToY(c) - y)) { \
152 dx = intToX(c) - x; \
153 step = 0; \
154 if (dx >= 0) { \
155 e = 0; \
156 sign = 1; \
157 if (dx >= dy) {\
158 step = dx / dy; \
159 dx = dx % dy; \
160 } \
161 } else { \
162 e = 1 - dy; \
163 sign = -1; \
164 dx = -dx; \
165 if (dx >= dy) { \
166 step = - (dx / dy); \
167 dx = dx % dy; \
168 } \
169 } \
170 } \
171 x += origin; \
172 vertex = c; \
173}
174
175#define Step(x,dx,dy,e,sign,step) {\
176 x += step; \
177 if ((e += dx) > 0) { \
178 x += sign; \
179 e -= dy; \
180 } \
181}
182 for (;;) {
183 if (y == intToY(vertex1)) {
184 do {
185 if (vertex1p == (int *) ptsIn)
186 vertex1p = endp;
187 c = *--vertex1p;
188 Setup (c,x1,vertex1,dx1,dy1,e1,sign1,step1)
189 } while (y >= intToY(vertex1));
190 h = dy1;
191 } else {
192 Step(x1,dx1,dy1,e1,sign1,step1)
193 h = intToY(vertex1) - y;
194 }
195 if (y == intToY(vertex2)) {
196 do {
197 c = *vertex2p++;
198 if (vertex2p == endp)
199 vertex2p = (int *) ptsIn;
200 Setup (c,x2,vertex2,dx2,dy2,e2,sign2,step2)
201 } while (y >= intToY(vertex2));
202 if (dy2 < h)
203 h = dy2;
204 } else {
205 Step(x2,dx2,dy2,e2,sign2,step2)
206 if ((c = (intToY(vertex2) - y)) < h)
207 h = c;
208 }
209 /* fill spans for this segment */
210 y += h;
211 for (;;) {
212 l = x1;
213 r = x2;
214 nmiddle = x2 - x1;
215 if (nmiddle < 0) {
216 nmiddle = -nmiddle;
217 l = x2;
218 r = x1;
219 }
220 c = l & PIM;
221 l -= c;
222 l = l >> PWSH;
223 addr = addrl + l;
224 if (c + nmiddle < PPW) {
225 mask = SCRRIGHT (bits,c) ^ SCRRIGHT (bits,c+nmiddle);
226 for (pdst = addr, d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
227 switch (rrops[d]) {
228 case RROP_BLACK:
229 *pdst &= ~mask;
230 break;
231 case RROP_WHITE:
232 *pdst |= mask;
233 break;
234 case RROP_INVERT:
235 *pdst ^= mask;
236 break;
237 case RROP_NOP:
238 break;
239 }
240 }
241 } else {
242 if (c) {
243 mask = SCRRIGHT(bits, c);
244 for (pdst = addr, d = 0; d < depthDst; d++, pdst += sizeDst) { /* @@@ NEXT PLANE @@@ */
245 switch (rrops[d]) {
246 case RROP_BLACK:
247 *pdst &= ~mask;
248 break;
249 case RROP_WHITE:
250 *pdst |= mask;
251 break;
252 case RROP_INVERT:
253 *pdst ^= mask;
254 break;
255 case RROP_NOP:
256 break;
257 }
258 }
259 nmiddle += c - PPW;
260 addr++;
261 }
262 nmiddle >>= PWSH;
263 mask = ~SCRRIGHT(bits, r & PIM);
264
265 for (d = 0; d < depthDst; d++, addr += sizeDst) { /* @@@ NEXT PLANE @@@ */
266 n = nmiddle;
267 pdst = addr;
268
269 switch (rrops[d]) {
270 case RROP_BLACK:
271 Duff (n, *pdst++ = 0;)
272 if (mask)
273 *pdst &= ~mask;
274 break;
275 case RROP_WHITE:
276 Duff (n, *pdst++ = ~0;);
277 if (mask)
278 *pdst |= mask;
279 break;
280 case RROP_INVERT:
281 Duff (n, *pdst++ ^= ~0;);
282 if (mask)
283 *pdst ^= mask;
284 break;
285 case RROP_NOP:
286 break;
287 }
288 }
289 }
290 if (!--h)
291 break;
292 afbScanlineInc(addrl, nlwidth);
293 Step(x1,dx1,dy1,e1,sign1,step1)
294 Step(x2,dx2,dy2,e2,sign2,step2)
295 }
296 if (y == maxy)
297 break;
298 afbScanlineInc(addrl, nlwidth);
299 }
300}
diff --git a/afb/afbplygblt.c b/afb/afbplygblt.c
deleted file mode 100644
index d1de102d7..000000000
--- a/afb/afbplygblt.c
+++ /dev/null
@@ -1,463 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xmd.h>
56#include <X11/Xproto.h>
57#include "afb.h"
58#include <X11/fonts/fontstruct.h>
59#include "dixfontstr.h"
60#include "gcstruct.h"
61#include "windowstr.h"
62#include "scrnintstr.h"
63#include "pixmapstr.h"
64#include "regionstr.h"
65#include "maskbits.h"
66
67/*
68 this works for fonts with glyphs <= 32 bits wide.
69
70 the clipping calculations are done for worst-case fonts.
71we make no assumptions about the heights, widths, or bearings
72of the glyphs. if we knew that the glyphs are all the same height,
73we could clip the tops and bottoms per clipping box, rather
74than per character per clipping box. if we knew that the glyphs'
75left and right bearings were wlle-behaved, we could clip a single
76character at the start, output until the last unclipped
77character, and then clip the last one. this is all straightforward
78to determine based on max-bounds and min-bounds from the font.
79 there is some inefficiency introduced in the per-character
80clipping to make what's going on clearer.
81
82 (it is possible, for example, for a font to be defined in which the
83next-to-last character in a font would be clipped out, but the last
84one wouldn't. the code below deals with this.)
85
86*/
87
88void
89afbPolyGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
90 DrawablePtr pDrawable;
91 GC *pGC;
92 int x, y;
93 unsigned int nglyph;
94 CharInfoPtr *ppci; /* array of character info */
95 pointer pglyphBase; /* start of array of glyphs */
96{
97 ExtentInfoRec info; /* used by QueryGlyphExtents() */
98 BoxRec bbox; /* string's bounding box */
99
100 CharInfoPtr pci;
101 int xorg, yorg; /* origin of drawable in bitmap */
102 int widthDst; /* width of dst in longwords */
103
104 /* these keep track of the character origin */
105 PixelType *pdstBase;
106 /* points to longword with character origin */
107 int xchar; /* xorigin of char (mod 32) */
108
109 /* these are used for placing the glyph */
110 register int xoff; /* x offset of left edge of glyph (mod 32) */
111 register PixelType *pdst; /* pointer to current longword in dst */
112
113 register int d;
114 int depthDst;
115 int sizeDst;
116 int hSave;
117 int w; /* width of glyph in bits */
118 int h; /* height of glyph */
119 int widthGlyph; /* width of glyph, in bytes */
120 unsigned char *rrops;
121 register unsigned char *pglyph;
122 /* pointer to current row of glyph */
123 unsigned char *pglyphSave;
124
125 /* used for putting down glyph */
126 register PixelType tmpSrc;
127 /* for getting bits from glyph */
128 register PixelType startmask;
129 register PixelType endmask;
130
131 register int nFirst; /* bits of glyph in current longword */
132 PixelType *pdstSave;
133
134 xorg = pDrawable->x;
135 yorg = pDrawable->y;
136 afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
137 pdstBase);
138
139 QueryGlyphExtents(pGC->font, ppci, (unsigned long)nglyph, &info);
140
141 x += xorg;
142 y += yorg;
143
144 bbox.x1 = x + info.overallLeft;
145 bbox.x2 = x + info.overallRight;
146 bbox.y1 = y - info.overallAscent;
147 bbox.y2 = y + info.overallDescent;
148
149 rrops = ((afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
150 afbGCPrivateKey))->rrops;
151 switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
152 case rgnOUT:
153 break;
154 case rgnIN:
155 pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
156 xchar = x & PIM;
157
158 while(nglyph--) {
159 pci = *ppci;
160 pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
161 w = pci->metrics.rightSideBearing - pci->metrics.leftSideBearing;
162 hSave = pci->metrics.ascent + pci->metrics.descent;
163 widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
164 /* start at top scanline of glyph */
165 pdstSave = afbScanlineDelta(pdstBase, -pci->metrics.ascent,
166 widthDst);
167
168 /* find correct word in scanline and x offset within it
169 for left edge of glyph
170 */
171 xoff = xchar + pci->metrics.leftSideBearing;
172 if (xoff > PLST) {
173 pdstSave++;
174 xoff &= PIM;
175 } else if (xoff < 0) {
176 xoff += PPW;
177 pdstSave--;
178 }
179
180 for (d = 0; d < depthDst; d++) {
181 h = hSave;
182 pdst = pdstSave;
183 pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
184 pglyph = pglyphSave;
185
186 if ((xoff + w) <= PPW) {
187 /* glyph all in one longword */
188 maskpartialbits(xoff, w, startmask);
189 switch (rrops[d]) {
190 case RROP_WHITE:
191 while (h--) {
192 getleftbits(pglyph, w, tmpSrc);
193 *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
194 pglyph += widthGlyph;
195 afbScanlineInc(pdst, widthDst);
196 }
197 break;
198 case RROP_BLACK:
199 while (h--) {
200 getleftbits(pglyph, w, tmpSrc);
201 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
202 pglyph += widthGlyph;
203 afbScanlineInc(pdst, widthDst);
204 }
205 break;
206 case RROP_INVERT:
207 while (h--) {
208 getleftbits(pglyph, w, tmpSrc);
209 *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
210 pglyph += widthGlyph;
211 afbScanlineInc(pdst, widthDst);
212 }
213 break;
214 }
215 } else {
216 /* glyph crosses longword boundary */
217 maskPPWbits(xoff, w, startmask, endmask);
218 nFirst = PPW - xoff;
219 switch (rrops[d]) {
220 case RROP_WHITE:
221 while (h--) {
222 getleftbits(pglyph, w, tmpSrc);
223 *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
224 *(pdst+1) |= (SCRLEFT(tmpSrc, nFirst) & endmask);
225 pglyph += widthGlyph;
226 afbScanlineInc(pdst, widthDst);
227 }
228 break;
229 case RROP_BLACK:
230 while (h--) {
231 getleftbits(pglyph, w, tmpSrc);
232 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
233 *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
234 pglyph += widthGlyph;
235 afbScanlineInc(pdst, widthDst);
236 }
237 break;
238 case RROP_INVERT:
239 while (h--) {
240 getleftbits(pglyph, w, tmpSrc);
241 *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
242 *(pdst+1) ^= (SCRLEFT(tmpSrc, nFirst) & endmask);
243 pglyph += widthGlyph;
244 afbScanlineInc(pdst, widthDst);
245 }
246 break;
247 }
248 } /* glyph crosses longwords boundary */
249 } /* depth loop */
250 /* update character origin */
251 x += pci->metrics.characterWidth;
252 xchar += pci->metrics.characterWidth;
253 if (xchar > PLST) {
254 xchar -= PPW;
255 pdstBase++;
256 } else if (xchar < 0) {
257 xchar += PPW;
258 pdstBase--;
259 }
260 ppci++;
261 } /* while nglyph-- */
262 break;
263 case rgnPART:
264 {
265 afbTEXTPOS *ppos;
266 int nbox;
267 BoxPtr pbox;
268 RegionPtr cclip;
269 int xpos; /* x position of char origin */
270 int i;
271 BoxRec clip;
272 int leftEdge, rightEdge;
273 int topEdge, bottomEdge;
274 int glyphRow; /* first row of glyph not wholly
275 clipped out */
276 int glyphCol; /* leftmost visible column of glyph */
277#if GETLEFTBITS_ALIGNMENT > 1
278 int getWidth; /* bits to get from glyph */
279#endif
280
281 if(!(ppos = (afbTEXTPOS *)xalloc(nglyph * sizeof(afbTEXTPOS))))
282 return;
283
284 pdstBase = afbScanlineNoBankSwitch(pdstBase, x, y, widthDst);
285 xpos = x;
286 xchar = xpos & PIM;
287
288 for (i = 0; i < nglyph; i++) {
289 pci = ppci[i];
290
291 ppos[i].xpos = xpos;
292 ppos[i].xchar = xchar;
293 ppos[i].leftEdge = xpos + pci->metrics.leftSideBearing;
294 ppos[i].rightEdge = xpos + pci->metrics.rightSideBearing;
295 ppos[i].topEdge = y - pci->metrics.ascent;
296 ppos[i].bottomEdge = y + pci->metrics.descent;
297 ppos[i].pdstBase = pdstBase;
298 ppos[i].widthGlyph = GLYPHWIDTHBYTESPADDED(pci);
299
300 xpos += pci->metrics.characterWidth;
301 xchar += pci->metrics.characterWidth;
302 if (xchar > PLST) {
303 xchar &= PIM;
304 pdstBase++;
305 } else if (xchar < 0) {
306 xchar += PPW;
307 pdstBase--;
308 }
309 }
310
311 cclip = pGC->pCompositeClip;
312 pbox = REGION_RECTS(cclip);
313 nbox = REGION_NUM_RECTS(cclip);
314
315 /* HACK ALERT
316 since we continue out of the loop below so often, it
317 is easier to increment pbox at the top than at the end.
318 don't try this at home.
319 */
320 pbox--;
321 while(nbox--) {
322 pbox++;
323 clip.x1 = max(bbox.x1, pbox->x1);
324 clip.y1 = max(bbox.y1, pbox->y1);
325 clip.x2 = min(bbox.x2, pbox->x2);
326 clip.y2 = min(bbox.y2, pbox->y2);
327 if ((clip.x2<=clip.x1) || (clip.y2<=clip.y1))
328 continue;
329
330 for(i=0; i<nglyph; i++) {
331 pci = ppci[i];
332 xchar = ppos[i].xchar;
333
334 /* clip the left and right edges */
335 if (ppos[i].leftEdge < clip.x1)
336 leftEdge = clip.x1;
337 else
338 leftEdge = ppos[i].leftEdge;
339
340 if (ppos[i].rightEdge > clip.x2)
341 rightEdge = clip.x2;
342 else
343 rightEdge = ppos[i].rightEdge;
344
345 w = rightEdge - leftEdge;
346 if (w <= 0)
347 continue;
348
349 /* clip the top and bottom edges */
350 if (ppos[i].topEdge < clip.y1)
351 topEdge = clip.y1;
352 else
353 topEdge = ppos[i].topEdge;
354
355 if (ppos[i].bottomEdge > clip.y2)
356 bottomEdge = clip.y2;
357 else
358 bottomEdge = ppos[i].bottomEdge;
359
360 hSave = bottomEdge - topEdge;
361 if (hSave <= 0)
362 continue;
363
364 glyphRow = (topEdge - y) + pci->metrics.ascent;
365 widthGlyph = ppos[i].widthGlyph;
366 pglyphSave = FONTGLYPHBITS(pglyphBase, pci);
367 pglyphSave += (glyphRow * widthGlyph);
368
369 glyphCol = (leftEdge - ppos[i].xpos) -
370 (pci->metrics.leftSideBearing);
371#if GETLEFTBITS_ALIGNMENT > 1
372 getWidth = w + glyphCol;
373#endif
374
375 pdstSave = afbScanlineDelta(ppos[i].pdstBase, -(y-topEdge),
376 widthDst);
377 xoff = xchar + (leftEdge - ppos[i].xpos);
378 if (xoff > PLST) {
379 xoff &= PIM;
380 pdstSave++;
381 } else if (xoff < 0) {
382 xoff += PPW;
383 pdstSave--;
384 }
385
386 for (d = 0; d < depthDst; d++) {
387 h = hSave;
388 pdst = pdstSave;
389 pdstSave += sizeDst; /* @@@ NEXT PLANE @@@ */
390 pglyph = pglyphSave;
391
392 if ((xoff + w) <= PPW) {
393 maskpartialbits(xoff, w, startmask);
394 switch (rrops[d]) {
395 case RROP_WHITE:
396 while (h--) {
397 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
398 *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
399 pglyph += widthGlyph;
400 afbScanlineInc(pdst, widthDst);
401 }
402 break;
403 case RROP_BLACK:
404 while (h--) {
405 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
406 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
407 pglyph += widthGlyph;
408 afbScanlineInc(pdst, widthDst);
409 }
410 break;
411 case RROP_INVERT:
412 while (h--) {
413 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
414 *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
415 pglyph += widthGlyph;
416 afbScanlineInc(pdst, widthDst);
417 }
418 break;
419 }
420 } else {
421 maskPPWbits(xoff, w, startmask, endmask);
422 nFirst = PPW - xoff;
423 switch (rrops[d]) {
424 case RROP_WHITE:
425 while (h--) {
426 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
427 *pdst |= (SCRRIGHT(tmpSrc, xoff) & startmask);
428 *(pdst+1) |= (SCRLEFT(tmpSrc, nFirst) & endmask);
429 pglyph += widthGlyph;
430 afbScanlineInc(pdst, widthDst);
431 }
432 break;
433 case RROP_BLACK:
434 while (h--) {
435 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
436 *pdst &= ~(SCRRIGHT(tmpSrc, xoff) & startmask);
437 *(pdst+1) &= ~(SCRLEFT(tmpSrc, nFirst) & endmask);
438 pglyph += widthGlyph;
439 afbScanlineInc(pdst, widthDst);
440 }
441 break;
442 case RROP_INVERT:
443 while (h--) {
444 getshiftedleftbits(pglyph, glyphCol, getWidth, tmpSrc);
445 *pdst ^= (SCRRIGHT(tmpSrc, xoff) & startmask);
446 *(pdst+1) ^= (SCRLEFT(tmpSrc, nFirst) & endmask);
447 pglyph += widthGlyph;
448 afbScanlineInc(pdst, widthDst);
449 }
450 break;
451 }
452 }
453 } /* depth */
454 } /* for each glyph */
455 } /* while nbox-- */
456 xfree(ppos);
457 break;
458 }
459
460 default:
461 break;
462 }
463}
diff --git a/afb/afbpntarea.c b/afb/afbpntarea.c
deleted file mode 100644
index cc43f5237..000000000
--- a/afb/afbpntarea.c
+++ /dev/null
@@ -1,655 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55
56#include "windowstr.h"
57#include "regionstr.h"
58#include "pixmapstr.h"
59#include "scrnintstr.h"
60
61#include "afb.h"
62#include "maskbits.h"
63
64/*
65 the solid fillers are called for rectangles and window backgrounds.
66 the boxes are already translated.
67 maybe this should always take a pixmap instead of a drawable?
68
69 NOTE:
70 iy = ++iy < tileHeight ? iy : 0
71is equivalent to iy%= tileheight, and saves a division.
72*/
73
74/*ARGSUSED*/
75void
76afbSolidFillArea (pDraw, nbox, pbox, rrops)
77 DrawablePtr pDraw;
78 int nbox;
79 BoxPtr pbox;
80 register unsigned char *rrops;
81{
82 int nlwidth; /* width in longwords of the drawable */
83 int w; /* width of current box */
84 register int h; /* height of current box */
85 register PixelType *p; /* pointer to bits we're writing */
86 register int nlw; /* loop version of nlwMiddle */
87 register PixelType startmask;
88 register PixelType endmask;
89 /* masks for reggedy bits at either end of line */
90 register int nlwExtra;
91 /* to get from right of box to left of next span */
92 int nlwMiddle; /* number of longwords between sides of boxes */
93 PixelType *pbits; /* pointer to start of drawable */
94 PixelType *saveP;
95 int saveH;
96 int depthDst;
97 int sizeDst;
98 register int d;
99
100 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
101 pbits);
102
103 while (nbox--) {
104 w = pbox->x2 - pbox->x1;
105 saveH = pbox->y2 - pbox->y1;
106
107 saveP = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
108
109 if ( ((pbox->x1 & PIM) + w) < PPW) {
110 for (d = 0; d < depthDst; d++) {
111 h = saveH;
112 p = saveP;
113 saveP += sizeDst; /* @@@ NEXT PLANE @@@ */
114 maskpartialbits(pbox->x1, w, startmask);
115 nlwExtra = nlwidth;
116
117 switch (rrops[d]) {
118 case RROP_BLACK:
119 Duff(h, *p &= ~startmask; afbScanlineInc(p, nlwExtra));
120 break;
121 case RROP_WHITE:
122 Duff(h, *p |= startmask; afbScanlineInc(p, nlwExtra));
123 break;
124 case RROP_INVERT:
125 Duff(h, *p ^= startmask; afbScanlineInc(p, nlwExtra));
126 break;
127 case RROP_NOP:
128 break;
129 } /* switch */
130 } /* for (d = ..) */
131 } else {
132 maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
133
134 for (d = 0; d < depthDst; d++) {
135 h = saveH;
136 p = saveP;
137 saveP += sizeDst; /* @@@ NEXT PLANE @@@ */
138 nlwExtra = nlwidth - nlwMiddle;
139
140 if (startmask && endmask) {
141 nlwExtra -= 1;
142 switch (rrops[d]) {
143 case RROP_BLACK:
144 while (h--) {
145 nlw = nlwMiddle;
146 *p &= ~startmask;
147 p++;
148 Duff(nlw, *p++ = 0);
149 *p &= ~endmask;
150 afbScanlineInc(p, nlwExtra);
151 }
152 break;
153 case RROP_WHITE:
154 while (h--) {
155 nlw = nlwMiddle;
156 *p |= startmask;
157 p++;
158 Duff(nlw, *p++ = ~0);
159 *p |= endmask;
160 afbScanlineInc(p, nlwExtra);
161 }
162 break;
163 case RROP_INVERT:
164 while (h--) {
165 nlw = nlwMiddle;
166 *p ^= startmask;
167 p++;
168 Duff(nlw, *p++ ^= ~0);
169 *p ^= endmask;
170 afbScanlineInc(p, nlwExtra);
171 }
172 break;
173 case RROP_NOP:
174 break;
175 }
176 } else if (startmask && !endmask) {
177 nlwExtra -= 1;
178 switch (rrops[d]) {
179 case RROP_BLACK:
180 while (h--) {
181 nlw = nlwMiddle;
182 *p &= ~startmask;
183 p++;
184 Duff(nlw, *p++ = 0);
185 afbScanlineInc(p, nlwExtra);
186 }
187 break;
188 case RROP_WHITE:
189 while (h--) {
190 nlw = nlwMiddle;
191 *p |= startmask;
192 p++;
193 Duff(nlw, *p++ = ~0);
194 afbScanlineInc(p, nlwExtra);
195 }
196 break;
197 case RROP_INVERT:
198 while (h--) {
199 nlw = nlwMiddle;
200 *p ^= startmask;
201 p++;
202 Duff(nlw, *p++ ^= ~0);
203 afbScanlineInc(p, nlwExtra);
204 }
205 break;
206 case RROP_NOP:
207 break;
208 }
209 } else if (!startmask && endmask) {
210 switch (rrops[d]) {
211 case RROP_BLACK:
212 while (h--) {
213 nlw = nlwMiddle;
214 Duff(nlw, *p++ = 0);
215 *p &= ~endmask;
216 afbScanlineInc(p, nlwExtra);
217 }
218 break;
219 case RROP_WHITE:
220 while (h--) {
221 nlw = nlwMiddle;
222 Duff(nlw, *p++ = ~0);
223 *p |= endmask;
224 afbScanlineInc(p, nlwExtra);
225 }
226 break;
227 case RROP_INVERT:
228 while (h--) {
229 nlw = nlwMiddle;
230 Duff(nlw, *p++ ^= ~0);
231 *p ^= endmask;
232 afbScanlineInc(p, nlwExtra);
233 }
234 case RROP_NOP:
235 break;
236 }
237 } else { /* no ragged bits at either end */
238 switch (rrops[d]) {
239 case RROP_BLACK:
240 while (h--) {
241 nlw = nlwMiddle;
242 Duff(nlw, *p++ = 0);
243 afbScanlineInc(p, nlwExtra);
244 }
245 break;
246 case RROP_WHITE:
247 while (h--) {
248 nlw = nlwMiddle;
249 Duff(nlw, *p++ = ~0);
250 afbScanlineInc(p, nlwExtra);
251 }
252 break;
253 case RROP_INVERT:
254 while (h--) {
255 nlw = nlwMiddle;
256 Duff(nlw, *p++ ^= ~0);
257 afbScanlineInc(p, nlwExtra);
258 }
259 break;
260 case RROP_NOP:
261 break;
262 } /* switch */
263 }
264 } /* for (d = 0 ... ) */
265 }
266 pbox++;
267 }
268}
269
270/* stipple a list of boxes -
271
272you can use the reduced rasterop for stipples. if rrop is
273black, AND the destination with (not stipple pattern). if rrop is
274white OR the destination with the stipple pattern. if rrop is invert,
275XOR the destination with the stipple pattern.
276*/
277
278/*ARGSUSED*/
279void
280afbStippleAreaPPW (pDraw, nbox, pbox, pstipple, rrops)
281 DrawablePtr pDraw;
282 int nbox;
283 BoxPtr pbox;
284 PixmapPtr pstipple;
285 unsigned char *rrops;
286{
287 register PixelType *psrc;
288 /* pointer to bits in tile, if needed */
289 int tileHeight; /* height of the tile */
290 register PixelType srcpix;
291
292 int nlwidth; /* width in longwords of the drawable */
293 int w; /* width of current box */
294 register int nlw; /* loop version of nlwMiddle */
295 register PixelType *p; /* pointer to bits we're writing */
296 register int h; /* height of current box */
297 PixelType startmask;
298 PixelType endmask; /* masks for reggedy bits at either end of line */
299 int nlwMiddle; /* number of longwords between sides of boxes */
300 int nlwExtra; /* to get from right of box to left of next span */
301 int sizeDst;
302 int depthDst;
303 int d;
304 int saveIy;
305 register int iy; /* index of current scanline in tile */
306 PixelType *pbits; /* pointer to start of drawable */
307 PixelType *pBase;
308
309 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
310 pBase);
311
312 tileHeight = pstipple->drawable.height;
313 psrc = (PixelType *)(pstipple->devPrivate.ptr);
314
315 while (nbox--) {
316 w = pbox->x2 - pbox->x1;
317 saveIy = pbox->y1 % tileHeight;
318 pbits = pBase;
319
320 if ( ((pbox->x1 & PIM) + w) < PPW) {
321 maskpartialbits(pbox->x1, w, startmask);
322 nlwExtra = nlwidth;
323 for (d = 0; d < depthDst; d++) {
324 p = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
325 pbits += sizeDst; /* @@@ NEXT PLANE @@@ */
326 iy = saveIy;
327 h = pbox->y2 - pbox->y1;
328
329 switch (rrops[d]) {
330 case RROP_BLACK:
331 while (h--) {
332 srcpix = psrc[iy];
333 iy = ++iy < tileHeight ? iy : 0;
334 *p &= ~(srcpix & startmask);
335 afbScanlineInc(p, nlwExtra);
336 }
337 break;
338 case RROP_WHITE:
339 while (h--) {
340 srcpix = psrc[iy];
341 iy = ++iy < tileHeight ? iy : 0;
342 *p |= (srcpix & startmask);
343 afbScanlineInc(p, nlwExtra);
344 }
345 break;
346 case RROP_INVERT:
347 while (h--) {
348 srcpix = psrc[iy];
349 iy = ++iy < tileHeight ? iy : 0;
350 *p ^= (srcpix & startmask);
351 afbScanlineInc(p, nlwExtra);
352 }
353 break;
354 case RROP_NOP:
355 break;
356 } /* switch */
357 } /* for (d = ...) */
358
359 } else {
360 maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
361
362 for (d = 0; d < depthDst; d++) {
363 nlwExtra = nlwidth - nlwMiddle;
364 p = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
365 pbits += sizeDst; /* @@@ NEXT PLANE @@@ */
366 iy = saveIy;
367 h = pbox->y2 - pbox->y1;
368
369 if (startmask && endmask) {
370 nlwExtra -= 1;
371 switch (rrops[d]) {
372 case RROP_BLACK:
373 while (h--) {
374 srcpix = psrc[iy];
375 iy = ++iy < tileHeight ? iy : 0;
376 nlw = nlwMiddle;
377 *p &= ~(srcpix & startmask);
378 p++;
379 Duff (nlw, *p++ &= ~srcpix);
380 *p &= ~(srcpix & endmask);
381 afbScanlineInc(p, nlwExtra);
382 }
383 break;
384 case RROP_WHITE:
385 while (h--) {
386 srcpix = psrc[iy];
387 iy = ++iy < tileHeight ? iy : 0;
388 nlw = nlwMiddle;
389 *p |= (srcpix & startmask);
390 p++;
391 Duff (nlw, *p++ |= srcpix);
392 *p |= (srcpix & endmask);
393 afbScanlineInc(p, nlwExtra);
394 }
395 break;
396 case RROP_INVERT:
397 while (h--) {
398 srcpix = psrc[iy];
399 iy = ++iy < tileHeight ? iy : 0;
400 nlw = nlwMiddle;
401 *p ^= (srcpix & startmask);
402 p++;
403 Duff (nlw, *p++ ^= srcpix);
404 *p ^= (srcpix & endmask);
405 afbScanlineInc(p, nlwExtra);
406 }
407 break;
408 case RROP_NOP:
409 break;
410 } /* switch */
411 } else if (startmask && !endmask) {
412 nlwExtra -= 1;
413 switch (rrops[d]) {
414 case RROP_BLACK:
415 while (h--) {
416 srcpix = psrc[iy];
417 iy = ++iy < tileHeight ? iy : 0;
418 nlw = nlwMiddle;
419 *p &= ~(srcpix & startmask);
420 p++;
421 Duff(nlw, *p++ &= ~srcpix);
422 afbScanlineInc(p, nlwExtra);
423 }
424 break;
425 case RROP_WHITE:
426 while (h--) {
427 srcpix = psrc[iy];
428 iy = ++iy < tileHeight ? iy : 0;
429 nlw = nlwMiddle;
430 *p |= (srcpix & startmask);
431 p++;
432 Duff(nlw, *p++ |= srcpix);
433 afbScanlineInc(p, nlwExtra);
434 }
435 break;
436 case RROP_INVERT:
437 while (h--) {
438 srcpix = psrc[iy];
439 iy = ++iy < tileHeight ? iy : 0;
440 nlw = nlwMiddle;
441 *p ^= (srcpix & startmask);
442 p++;
443 Duff(nlw, *p++ ^= srcpix);
444 afbScanlineInc(p, nlwExtra);
445 }
446 break;
447 case RROP_NOP:
448 break;
449 } /* switch */
450 } else if (!startmask && endmask) {
451 switch (rrops[d]) {
452 case RROP_BLACK:
453 while (h--) {
454 srcpix = psrc[iy];
455 iy = ++iy < tileHeight ? iy : 0;
456 nlw = nlwMiddle;
457 Duff(nlw, *p++ &= ~srcpix);
458 *p &= ~(srcpix & endmask);
459 afbScanlineInc(p, nlwExtra);
460 }
461 break;
462 case RROP_WHITE:
463 while (h--) {
464 srcpix = psrc[iy];
465 iy = ++iy < tileHeight ? iy : 0;
466 nlw = nlwMiddle;
467 Duff(nlw, *p++ |= srcpix);
468 *p |= (srcpix & endmask);
469 afbScanlineInc(p, nlwExtra);
470 }
471 break;
472 case RROP_INVERT:
473 while (h--) {
474 srcpix = psrc[iy];
475 iy = ++iy < tileHeight ? iy : 0;
476 nlw = nlwMiddle;
477 Duff(nlw, *p++ ^= srcpix);
478 *p ^= (srcpix & endmask);
479 afbScanlineInc(p, nlwExtra);
480 }
481 break;
482 case RROP_NOP:
483 break;
484 } /* switch */
485 } else { /* no ragged bits at either end */
486 switch (rrops[d]) {
487 case RROP_BLACK:
488 while (h--) {
489 srcpix = psrc[iy];
490 iy = ++iy < tileHeight ? iy : 0;
491 nlw = nlwMiddle;
492 Duff(nlw, *p++ &= ~srcpix);
493 afbScanlineInc(p, nlwExtra);
494 }
495 break;
496 case RROP_WHITE:
497 while (h--) {
498 srcpix = psrc[iy];
499 iy = ++iy < tileHeight ? iy : 0;
500 nlw = nlwMiddle;
501 Duff(nlw, *p++ |= srcpix);
502 afbScanlineInc(p, nlwExtra);
503 }
504 break;
505 case RROP_INVERT:
506 while (h--) {
507 srcpix = psrc[iy];
508 iy = ++iy < tileHeight ? iy : 0;
509 nlw = nlwMiddle;
510 Duff(nlw, *p++ ^= srcpix);
511 afbScanlineInc(p, nlwExtra);
512 }
513 break;
514 } /* switch */
515 }
516 } /* for (d = ...) */
517 }
518 pbox++;
519 }
520}
521
522void
523afbStippleArea (pDraw, nbox, pbox, pTile, xOff, yOff, rrops)
524 DrawablePtr pDraw;
525 int nbox;
526 BoxPtr pbox;
527 PixmapPtr pTile;
528 int xOff;
529 int yOff;
530 unsigned char *rrops;
531{
532 register PixelType *psrc; /* pointer to bits in tile, if needed */
533 int nlwidth; /* width in longwords of the drawable */
534 register int h; /* height of current box */
535 register PixelType *pdst; /* pointer to bits we're writing */
536 int sizeDst;
537 int depthDst;
538 int tileLine;
539 int iline;
540 int w, width, x, xSrc, ySrc, srcStartOver, nend;
541 int tlwidth, rem, tileWidth, tileHeight, endinc;
542 int saveW;
543 register int rop;
544 PixelType *psrcT;
545 int d;
546 int nstart;
547 PixelType startmask;
548 PixelType endmask; /* masks for reggedy bits at either end of line */
549 int nlMiddle; /* number of longwords between sides of boxes */
550 int iy;
551 PixelType *pBase; /* pointer to start of drawable */
552 PixelType *saveP;
553 PixelType *pStartDst;
554 PixelType *pStartTile;
555 int saveH;
556
557 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
558 pBase);
559
560 tileHeight = pTile->drawable.height;
561 tileWidth = pTile->drawable.width;
562 tlwidth = pTile->devKind / sizeof (PixelType);
563
564 xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
565 ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
566
567 while (nbox--) {
568 saveW = pbox->x2 - pbox->x1;
569 iline = (pbox->y1 - ySrc) % tileHeight;
570 psrcT = (PixelType *) pTile->devPrivate.ptr;
571 tileLine = iline * tlwidth;
572 saveH = pbox->y2 - pbox->y1;
573 saveP = afbScanline(pBase, pbox->x1, pbox->y1, nlwidth);
574
575 for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
576 h = saveH;
577 pStartDst = saveP;
578 pStartTile = psrcT + tileLine;
579 iy = iline;
580
581 while (h--) {
582 x = pbox->x1;
583 width = saveW;
584 pdst = pStartDst;
585 rop = rrops[d];
586
587 while(width > 0) {
588 psrc = pStartTile;
589 w = min(tileWidth, width);
590 if((rem = (x - xSrc) % tileWidth) != 0) {
591 /* if we're in the middle of the tile, get
592 as many bits as will finish the span, or
593 as many as will get to the left edge of the tile,
594 or a longword worth, starting at the appropriate
595 offset in the tile.
596 */
597 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
598 endinc = rem / BITMAP_SCANLINE_PAD;
599 getandputrrop((psrc + endinc), (rem & PIM), (x & PIM),
600 w, pdst, rop)
601 if((x & PIM) + w >= PPW)
602 pdst++;
603 } else if(((x & PIM) + w) < PPW) {
604 /* doing < PPW bits is easy, and worth special-casing */
605 putbitsrrop(*psrc, x & PIM, w, pdst, rop);
606 } else {
607 /* start at the left edge of the tile,
608 and put down as much as we can
609 */
610 maskbits(x, w, startmask, endmask, nlMiddle);
611
612 if (startmask)
613 nstart = PPW - (x & PIM);
614 else
615 nstart = 0;
616 if (endmask)
617 nend = (x + w) & PIM;
618 else
619 nend = 0;
620
621 srcStartOver = nstart > PLST;
622
623 if(startmask) {
624 putbitsrrop(*psrc, (x & PIM), nstart, pdst, rop);
625 pdst++;
626 if(srcStartOver)
627 psrc++;
628 }
629
630 while(nlMiddle--) {
631 getandputrrop0(psrc, nstart, PPW, pdst, rop);
632 pdst++;
633 psrc++;
634 }
635
636 if(endmask) {
637 getandputrrop0(psrc, nstart, nend, pdst, rop);
638 }
639 }
640 x += w;
641 width -= w;
642 } /* while (width > 0) */
643
644 pStartDst += nlwidth;
645 if (++iy >= tileHeight) {
646 iy = 0;
647 pStartTile = psrcT;
648 } else
649 pStartTile += tlwidth;
650
651 } /* while (h) */
652 } /* for (d = ... ) */
653 pbox++;
654 } /* for each box */
655}
diff --git a/afb/afbpolypnt.c b/afb/afbpolypnt.c
deleted file mode 100644
index b8ea3ed3e..000000000
--- a/afb/afbpolypnt.c
+++ /dev/null
@@ -1,146 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xprotostr.h>
56#include "pixmapstr.h"
57#include "gcstruct.h"
58#include "windowstr.h"
59#include "regionstr.h"
60#include "scrnintstr.h"
61
62#include "afb.h"
63#include "maskbits.h"
64
65void
66afbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
67 register DrawablePtr pDrawable;
68 GCPtr pGC;
69 int mode; /* Origin or Previous */
70 int npt;
71 xPoint *pptInit;
72{
73
74 register BoxPtr pbox;
75 register int nbox;
76 register int d;
77
78 register PixelType *addrl;
79 PixelType *pBase;
80 PixelType *pBaseSave;
81 int nlwidth;
82 int sizeDst;
83 int depthDst;
84
85 int nptTmp;
86 register xPoint *ppt;
87
88 register int x;
89 register int y;
90 register unsigned char *rrops;
91 afbPrivGC *pGCPriv;
92
93 pGCPriv = (afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
94 afbGCPrivateKey);
95 afbGetPixelWidthSizeDepthAndPointer(pDrawable, nlwidth, sizeDst, depthDst,
96 pBaseSave);
97
98 rrops = pGCPriv->rrops;
99 if ((mode == CoordModePrevious) && (npt > 1))
100 for (ppt = pptInit + 1, nptTmp = npt - 1; --nptTmp >= 0; ppt++) {
101 ppt->x += (ppt-1)->x;
102 ppt->y += (ppt-1)->y;
103 }
104
105 nbox = REGION_NUM_RECTS(pGC->pCompositeClip);
106 pbox = REGION_RECTS(pGC->pCompositeClip);
107 for (; --nbox >= 0; pbox++)
108 for (d = 0, pBase = pBaseSave; d < depthDst; d++, pBase += sizeDst) { /* @@@ NEXT PLANE @@@ */
109 addrl = pBase;
110
111 switch (rrops[d]) {
112 case RROP_BLACK:
113 for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
114 x = ppt->x + pDrawable->x;
115 y = ppt->y + pDrawable->y;
116 if ((x >= pbox->x1) && (x < pbox->x2) &&
117 (y >= pbox->y1) && (y < pbox->y2))
118 *afbScanline(addrl, x, y, nlwidth) &= mfbGetrmask(x & PIM);
119 }
120 break;
121
122 case RROP_WHITE:
123 for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
124 x = ppt->x + pDrawable->x;
125 y = ppt->y + pDrawable->y;
126 if ((x >= pbox->x1) && (x < pbox->x2) &&
127 (y >= pbox->y1) && (y < pbox->y2))
128 *afbScanline(addrl, x, y, nlwidth) |= mfbGetmask(x & PIM);
129 }
130 break;
131
132 case RROP_INVERT:
133 for (ppt = pptInit, nptTmp = npt; --nptTmp >= 0; ppt++) {
134 x = ppt->x + pDrawable->x;
135 y = ppt->y + pDrawable->y;
136 if ((x >= pbox->x1) && (x < pbox->x2) &&
137 (y >= pbox->y1) && (y < pbox->y2))
138 *afbScanline(addrl, x, y, nlwidth) ^= mfbGetmask(x & PIM);
139 }
140 break;
141
142 case RROP_NOP:
143 break;
144 } /* switch */
145 } /* for (d = ...) */
146}
diff --git a/afb/afbpushpxl.c b/afb/afbpushpxl.c
deleted file mode 100644
index 3dd548737..000000000
--- a/afb/afbpushpxl.c
+++ /dev/null
@@ -1,169 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <string.h>
54
55#include <X11/X.h>
56#include "gcstruct.h"
57#include "scrnintstr.h"
58#include "pixmapstr.h"
59#include "regionstr.h"
60#include "maskbits.h"
61#include "afb.h"
62
63#define NPT 128
64
65/* afbPushPixels -- squeegees the forground color of pGC through pBitMap
66 * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may
67 * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit
68 * is set in the bitmap, the fill style is put onto the drawable using
69 * the GC's logical function. The drawable is not changed where the bitmap
70 * has a zero bit or outside the area covered by the stencil.
71 */
72void
73afbPushPixels(GCPtr pGC, PixmapPtr pBitMap, DrawablePtr pDrawable, int dx, int dy, int xOrg, int yOrg)
74{
75 int h, dxDivPPW, ibEnd;
76 PixelType *pwLineStart;
77 register PixelType *pw, *pwEnd;
78 register PixelType mask;
79 register int ib;
80 register PixelType w;
81 register int ipt; /* index into above arrays */
82 Bool fInBox;
83 DDXPointRec pt[NPT];
84 int width[NPT];
85
86 /* Now scan convert the pixmap and use the result to call fillspans in
87 * in the drawable with the original GC */
88 ipt = 0;
89 dxDivPPW = dx/PPW;
90 for (h = 0; h < dy; h++) {
91
92 pw = (PixelType *)
93 (((char *)(pBitMap->devPrivate.ptr))+(h * pBitMap->devKind));
94 pwLineStart = pw;
95 /* Process all words which are fully in the pixmap */
96
97 fInBox = FALSE;
98 pwEnd = pwLineStart + dxDivPPW;
99 while(pw < pwEnd) {
100 w = *pw;
101 mask = mfbGetendtab(1);
102 for(ib = 0; ib < PPW; ib++) {
103 if(w & mask) {
104 if(!fInBox) {
105 pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
106 pt[ipt].y = h + yOrg;
107 /* start new box */
108 fInBox = TRUE;
109 }
110 } else {
111 if(fInBox) {
112 width[ipt] = ((pw - pwLineStart) << PWSH) +
113 ib + xOrg - pt[ipt].x;
114 if (++ipt >= NPT) {
115 (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
116 width, TRUE);
117 ipt = 0;
118 }
119 /* end box */
120 fInBox = FALSE;
121 }
122 }
123 mask = SCRRIGHT(mask, 1);
124 }
125 pw++;
126 }
127 ibEnd = dx & PIM;
128 if(ibEnd) {
129 /* Process final partial word on line */
130 w = *pw;
131 mask = mfbGetendtab(1);
132 for(ib = 0; ib < ibEnd; ib++) {
133 if(w & mask) {
134 if(!fInBox) {
135 /* start new box */
136 pt[ipt].x = ((pw - pwLineStart) << PWSH) + ib + xOrg;
137 pt[ipt].y = h + yOrg;
138 fInBox = TRUE;
139 }
140 } else {
141 if(fInBox) {
142 /* end box */
143 width[ipt] = ((pw - pwLineStart) << PWSH) +
144 ib + xOrg - pt[ipt].x;
145 if (++ipt >= NPT) {
146 (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt,
147 width, TRUE);
148 ipt = 0;
149 }
150 fInBox = FALSE;
151 }
152 }
153 mask = SCRRIGHT(mask, 1);
154 }
155 }
156 /* If scanline ended with last bit set, end the box */
157 if(fInBox) {
158 width[ipt] = dx + xOrg - pt[ipt].x;
159 if (++ipt >= NPT) {
160 (*pGC->ops->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE);
161 ipt = 0;
162 }
163 }
164 }
165 /* Flush any remaining spans */
166 if (ipt) {
167 (*pGC->ops->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE);
168 }
169}
diff --git a/afb/afbscrinit.c b/afb/afbscrinit.c
deleted file mode 100644
index cbabb894e..000000000
--- a/afb/afbscrinit.c
+++ /dev/null
@@ -1,218 +0,0 @@
1/***********************************************************
2
3Copyright (c) 1987 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26
27Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
28
29 All Rights Reserved
30
31Permission to use, copy, modify, and distribute this software and its
32documentation for any purpose and without fee is hereby granted,
33provided that the above copyright notice appear in all copies and that
34both that copyright notice and this permission notice appear in
35supporting documentation, and that the name of Digital not be
36used in advertising or publicity pertaining to distribution of the
37software without specific, written prior permission.
38
39DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
40ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
41DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
42ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
43WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
44ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
45SOFTWARE.
46
47******************************************************************/
48
49#ifdef HAVE_DIX_CONFIG_H
50#include <dix-config.h>
51#endif
52
53#include <stdlib.h>
54
55#include <X11/X.h>
56#include <X11/Xproto.h> /* for xColorItem */
57#include <X11/Xmd.h>
58#include "scrnintstr.h"
59#include "pixmapstr.h"
60#include "windowstr.h"
61#include "resource.h"
62#include "colormap.h"
63#include "afb.h"
64#include "mistruct.h"
65#include "dix.h"
66#include "mi.h"
67#include "mibstore.h"
68#include "migc.h"
69#include "servermd.h"
70
71#ifdef PIXMAP_PER_WINDOW
72DevPrivateKey frameWindowPrivateKey = &frameWindowPrivateKey;
73#endif
74DevPrivateKey afbGCPrivateKey = &afbGCPrivateKey;
75DevPrivateKey afbScreenPrivateKey = &afbScreenPrivateKey;
76
77static Bool
78afbCloseScreen(int index, ScreenPtr pScreen)
79{
80 int d;
81 DepthPtr depths = pScreen->allowedDepths;
82
83 for (d = 0; d < pScreen->numDepths; d++)
84 xfree(depths[d].vids);
85 xfree(depths);
86 xfree(pScreen->visuals);
87 xfree(dixLookupPrivate(&pScreen->devPrivates, afbScreenPrivateKey));
88 return(TRUE);
89}
90
91static Bool
92afbCreateScreenResources(ScreenPtr pScreen)
93{
94 Bool retval;
95
96 pointer oldDevPrivate = pScreen->devPrivate;
97
98 pScreen->devPrivate = dixLookupPrivate(&pScreen->devPrivates,
99 afbScreenPrivateKey);
100 retval = miCreateScreenResources(pScreen);
101
102 /* Modify screen's pixmap devKind value stored off devPrivate to
103 * be the width of a single plane in longs rather than the width
104 * of a chunky screen in longs as incorrectly setup by the mi routine.
105 */
106 ((PixmapPtr)pScreen->devPrivate)->devKind = BitmapBytePad(pScreen->width);
107 dixSetPrivate(&pScreen->devPrivates, afbScreenPrivateKey,
108 pScreen->devPrivate);
109 pScreen->devPrivate = oldDevPrivate;
110 return(retval);
111}
112
113static PixmapPtr
114afbGetWindowPixmap(WindowPtr pWin)
115{
116#ifdef PIXMAP_PER_WINDOW
117 return (PixmapPtr)dixLookupPrivate(&pWin->devPrivates,
118 frameWindowPrivateKey);
119#else
120 ScreenPtr pScreen = pWin->drawable.pScreen;
121
122 return (* pScreen->GetScreenPixmap)(pScreen);
123#endif
124}
125
126static void
127afbSetWindowPixmap(WindowPtr pWin, PixmapPtr pPix)
128{
129#ifdef PIXMAP_PER_WINDOW
130 dixSetPrivate(&pWin->devPrivates, frameWindowPrivateKey, pPix);
131#else
132 (* pWin->drawable.pScreen->SetScreenPixmap)(pPix);
133#endif
134}
135
136static Bool
137afbAllocatePrivates(ScreenPtr pScreen, DevPrivateKey *pGCKey)
138{
139 if (pGCKey)
140 *pGCKey = afbGCPrivateKey;
141
142 pScreen->GetWindowPixmap = afbGetWindowPixmap;
143 pScreen->SetWindowPixmap = afbSetWindowPixmap;
144 return dixRequestPrivate(afbGCPrivateKey, sizeof(afbPrivGC));
145}
146
147/* dts * (inch/dot) * (25.4 mm / inch) = mm */
148Bool
149afbScreenInit(register ScreenPtr pScreen, pointer pbits, int xsize, int ysize, int dpix, int dpiy, int width)
150
151 /* pointer to screen bitmap */
152 /* in pixels */
153 /* dots per inch */
154 /* pixel width of frame buffer */
155{
156 VisualPtr visuals;
157 DepthPtr depths;
158 int nvisuals;
159 int ndepths;
160 int rootdepth;
161 VisualID defaultVisual;
162 pointer oldDevPrivate;
163
164 rootdepth = 0;
165 if (!afbInitVisuals(&visuals, &depths, &nvisuals, &ndepths, &rootdepth,
166 &defaultVisual, 256, 8)) {
167 ErrorF("afbInitVisuals: FALSE\n");
168 return FALSE;
169 }
170 if (!afbAllocatePrivates(pScreen, NULL)) {
171 ErrorF("afbAllocatePrivates: FALSE\n");
172 return FALSE;
173 }
174
175 pScreen->defColormap = (Colormap)FakeClientID(0);
176 /* whitePixel, blackPixel */
177 pScreen->blackPixel = 0;
178 pScreen->whitePixel = 0;
179 pScreen->QueryBestSize = afbQueryBestSize;
180 /* SaveScreen */
181 pScreen->GetImage = afbGetImage;
182 pScreen->GetSpans = afbGetSpans;
183 pScreen->CreateWindow = afbCreateWindow;
184 pScreen->DestroyWindow = afbDestroyWindow;
185 pScreen->PositionWindow = afbPositionWindow;
186 pScreen->ChangeWindowAttributes = afbChangeWindowAttributes;
187 pScreen->RealizeWindow = afbMapWindow;
188 pScreen->UnrealizeWindow = afbUnmapWindow;
189 pScreen->CopyWindow = afbCopyWindow;
190 pScreen->CreatePixmap = afbCreatePixmap;
191 pScreen->DestroyPixmap = afbDestroyPixmap;
192 pScreen->RealizeFont = afbRealizeFont;
193 pScreen->UnrealizeFont = afbUnrealizeFont;
194 pScreen->CreateGC = afbCreateGC;
195 pScreen->CreateColormap = afbInitializeColormap;
196 pScreen->DestroyColormap = (DestroyColormapProcPtr)NoopDDA;
197 pScreen->InstallColormap = afbInstallColormap;
198 pScreen->UninstallColormap = afbUninstallColormap;
199 pScreen->ListInstalledColormaps = afbListInstalledColormaps;
200 pScreen->StoreColors = (StoreColorsProcPtr)NoopDDA;
201 pScreen->ResolveColor = afbResolveColor;
202 pScreen->BitmapToRegion = afbPixmapToRegion;
203 oldDevPrivate = pScreen->devPrivate;
204 if (!miScreenInit(pScreen, pbits, xsize, ysize, dpix, dpiy, width, rootdepth,
205 ndepths, depths, defaultVisual, nvisuals, visuals)) {
206 ErrorF("miScreenInit: FALSE\n");
207 return FALSE;
208 }
209
210 pScreen->CloseScreen = afbCloseScreen;
211 pScreen->CreateScreenResources = afbCreateScreenResources;
212
213 dixSetPrivate(&pScreen->devPrivates, afbScreenPrivateKey,
214 pScreen->devPrivate);
215 pScreen->devPrivate = oldDevPrivate;
216
217 return TRUE;
218}
diff --git a/afb/afbsetsp.c b/afb/afbsetsp.c
deleted file mode 100644
index cb36dba99..000000000
--- a/afb/afbsetsp.c
+++ /dev/null
@@ -1,257 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xmd.h>
56
57#include "misc.h"
58#include "regionstr.h"
59#include "gcstruct.h"
60#include "windowstr.h"
61#include "pixmapstr.h"
62#include "scrnintstr.h"
63
64#include "afb.h"
65#include "maskbits.h"
66
67#include "servermd.h"
68
69
70/* afbSetScanline -- copies the bits from psrc to the drawable starting at
71 * (xStart, y) and continuing to (xEnd, y). xOrigin tells us where psrc
72 * starts on the scanline. (I.e., if this scanline passes through multiple
73 * boxes, we may not want to start grabbing bits at psrc but at some offset
74 * further on.)
75 */
76static void
77afbSetScanline(int y, int xOrigin, int xStart, int xEnd, PixelType *psrc,
78 int alu, PixelType *pdstBase, int widthDst, int sizeDst,
79 int depthDst, int sizeSrc)
80{
81 int w; /* width of scanline in bits */
82 register PixelType *pdst; /* where to put the bits */
83 register PixelType tmpSrc; /* scratch buffer to collect bits in */
84 int dstBit; /* offset in bits from beginning of
85 * word */
86 register int nstart; /* number of bits from first partial */
87 register int nend; /* " " last partial word */
88 int offSrc;
89 PixelType startmask, endmask;
90 PixelType *savePsrc = psrc + ((xStart - xOrigin) >> PWSH);
91 int nlMiddle, nl;
92 int d;
93
94 for (d = 0; d < depthDst; d++) {
95 pdst = afbScanline(pdstBase, xStart, y, widthDst) + sizeDst * d; /* @@@ NEXT PLANE @@@ */
96 psrc = savePsrc + sizeSrc * d; /* @@@ NEXT PLANE @@@ */
97 offSrc = (xStart - xOrigin) & PIM;
98 w = xEnd - xStart;
99 dstBit = xStart & PIM;
100
101 if (dstBit + w <= PPW) {
102 getandputrop(psrc, offSrc, dstBit, w, pdst, alu)
103 } else {
104 maskbits(xStart, w, startmask, endmask, nlMiddle);
105 if (startmask)
106 nstart = PPW - dstBit;
107 else
108 nstart = 0;
109 if (endmask)
110 nend = xEnd & PIM;
111 else
112 nend = 0;
113 if (startmask) {
114 getandputrop(psrc, offSrc, dstBit, nstart, pdst, alu)
115 pdst++;
116 offSrc += nstart;
117 if (offSrc > PLST) {
118 psrc++;
119 offSrc -= PPW;
120 }
121 }
122 nl = nlMiddle;
123 while (nl--) {
124 getbits(psrc, offSrc, PPW, tmpSrc);
125 DoRop(*pdst, alu, tmpSrc, *pdst);
126 pdst++;
127 psrc++;
128 }
129 if (endmask) {
130 getandputrop0(psrc, offSrc, nend, pdst, alu);
131 }
132 }
133 }
134}
135
136
137
138/* SetSpans -- for each span copy pwidth[i] bits from psrc to pDrawable at
139 * ppt[i] using the raster op from the GC. If fSorted is TRUE, the scanlines
140 * are in increasing Y order.
141 * Source bit lines are server scanline padded so that they always begin
142 * on a word boundary.
143 */
144void
145afbSetSpans(pDrawable, pGC, pcharsrc, ppt, pwidth, nspans, fSorted)
146 DrawablePtr pDrawable;
147 GCPtr pGC;
148 char *pcharsrc;
149 register DDXPointPtr ppt;
150 int *pwidth;
151 int nspans;
152 int fSorted;
153{
154 PixelType *psrc = (PixelType *)pcharsrc;
155 PixelType *pdstBase; /* start of dst bitmap */
156 int widthDst; /* width of bitmap in words */
157 int sizeDst;
158 int depthDst;
159 int sizeSrc = 0;
160 register BoxPtr pbox, pboxLast, pboxTest;
161 register DDXPointPtr pptLast;
162 int alu;
163 RegionPtr prgnDst;
164 int xStart, xEnd;
165 int yMax;
166
167 alu = pGC->alu;
168 prgnDst = pGC->pCompositeClip;
169
170 pptLast = ppt + nspans;
171
172 yMax = pDrawable->y + (int) pDrawable->height;
173 afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
174 pdstBase);
175
176 pbox = REGION_RECTS(prgnDst);
177 pboxLast = pbox + REGION_NUM_RECTS(prgnDst);
178
179 if(fSorted) {
180 /* scan lines sorted in ascending order. Because they are sorted, we
181 * don't have to check each scanline against each clip box. We can be
182 * sure that this scanline only has to be clipped to boxes at or after the
183 * beginning of this y-band
184 */
185 pboxTest = pbox;
186 while(ppt < pptLast) {
187 pbox = pboxTest;
188 if(ppt->y >= yMax)
189 break;
190 while(pbox < pboxLast) {
191 if(pbox->y1 > ppt->y) {
192 /* scanline is before clip box */
193 break;
194 } else if(pbox->y2 <= ppt->y) {
195 /* clip box is before scanline */
196 pboxTest = ++pbox;
197 continue;
198 } else if(pbox->x1 > ppt->x + *pwidth) {
199 /* clip box is to right of scanline */
200 break;
201 } else if(pbox->x2 <= ppt->x) {
202 /* scanline is to right of clip box */
203 pbox++;
204 continue;
205 }
206
207 /* at least some of the scanline is in the current clip box */
208 xStart = max(pbox->x1, ppt->x);
209 xEnd = min(ppt->x + *pwidth, pbox->x2);
210 sizeSrc = PixmapWidthInPadUnits(*pwidth, 1);
211 afbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu, pdstBase,
212 widthDst, sizeDst, depthDst, sizeSrc);
213 if(ppt->x + *pwidth <= pbox->x2) {
214 /* End of the line, as it were */
215 break;
216 } else
217 pbox++;
218 }
219 /* We've tried this line against every box; it must be outside them
220 * all. move on to the next point */
221 ppt++;
222 psrc += sizeSrc * depthDst;
223 pwidth++;
224 }
225 } else {
226 /* scan lines not sorted. We must clip each line against all the boxes */
227 while(ppt < pptLast) {
228 if(ppt->y >= 0 && ppt->y < yMax) {
229 for(pbox = REGION_RECTS(prgnDst); pbox< pboxLast; pbox++) {
230 if(pbox->y1 > ppt->y) {
231 /* rest of clip region is above this scanline,
232 * skip it */
233 break;
234 }
235 if(pbox->y2 <= ppt->y) {
236 /* clip box is below scanline */
237 pbox++;
238 break;
239 }
240 if(pbox->x1 <= ppt->x + *pwidth &&
241 pbox->x2 > ppt->x) {
242 xStart = max(pbox->x1, ppt->x);
243 xEnd = min(pbox->x2, ppt->x + *pwidth);
244 sizeSrc = PixmapWidthInPadUnits(*pwidth, 1);
245 afbSetScanline(ppt->y, ppt->x, xStart, xEnd, psrc, alu,
246 pdstBase, widthDst, sizeDst, depthDst,
247 sizeSrc);
248 }
249
250 }
251 }
252 psrc += sizeSrc * depthDst;
253 ppt++;
254 pwidth++;
255 }
256 }
257}
diff --git a/afb/afbtegblt.c b/afb/afbtegblt.c
deleted file mode 100644
index c89b23a5d..000000000
--- a/afb/afbtegblt.c
+++ /dev/null
@@ -1,586 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55#include <X11/Xmd.h>
56#include <X11/Xproto.h>
57#include "afb.h"
58#include <X11/fonts/fontstruct.h>
59#include "dixfontstr.h"
60#include "gcstruct.h"
61#include "windowstr.h"
62#include "scrnintstr.h"
63#include "pixmapstr.h"
64#include "regionstr.h"
65#include "maskbits.h"
66
67/*
68 this works for fonts with glyphs <= PPW bits wide.
69
70 This should be called only with a terminal-emulator font;
71this means that the FIXED_METRICS flag is set, and that
72glyphbounds == charbounds.
73
74 in theory, this goes faster; even if it doesn't, it reduces the
75flicker caused by writing a string over itself with image text (since
76the background gets repainted per character instead of per string.)
77this seems to be important for some converted X10 applications.
78
79 Image text looks at the bits in the glyph and the fg and bg in the
80GC. it paints a rectangle, as defined in the protocol dcoument,
81and the paints the characters.
82
83*/
84
85#if defined(NO_3_60_CG4) && defined(FASTPUTBITS) && defined(FASTGETBITS)
86#define FASTCHARS
87#endif
88
89/*
90 * this macro "knows" that only characters <= 8 bits wide will
91 * fit this case (which is why it is independent of GLYPHPADBYTES)
92 */
93
94#if (BITMAP_BIT_ORDER == MSBFirst) && (GLYPHPADBYTES != 4)
95#if GLYPHPADBYTES == 1
96#define ShiftAmnt 24
97#else
98#define ShiftAmnt 16
99#endif
100
101/*
102 * Note: for BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER, SCRRIGHT() evaluates its
103 * first argument more than once. Thus the imbedded char++ have to be moved.
104 * (DHD)
105 */
106#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
107#if PPW == 32
108#define GetBits4 c = (*char1++ << ShiftAmnt) | \
109 SCRRIGHT (*char2++ << ShiftAmnt, xoff2) | \
110 SCRRIGHT (*char3++ << ShiftAmnt, xoff3) | \
111 SCRRIGHT (*char4++ << ShiftAmnt, xoff4);
112#else /* PPW */
113#define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
114 (SCRRIGHT (*char2++ << ShiftAmnt, xoff2) << 32 ) | \
115 (SCRRIGHT (*char3++ << ShiftAmnt, xoff3) << 32 ) | \
116 (SCRRIGHT (*char4++ << ShiftAmnt, xoff4) << 32 ) | \
117 (*char5++ << ShiftAmnt) | \
118 SCRRIGHT (*char6++ << ShiftAmnt, xoff6) | \
119 SCRRIGHT (*char7++ << ShiftAmnt, xoff7) | \
120 SCRRIGHT (*char8++ << ShiftAmnt, xoff8);
121#endif /* PPW */
122#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
123#if PPW == 32
124#define GetBits4 c = (*char1++ << ShiftAmnt) | \
125 SCRRIGHT (*char2 << ShiftAmnt, xoff2) | \
126 SCRRIGHT (*char3 << ShiftAmnt, xoff3) | \
127 SCRRIGHT (*char4 << ShiftAmnt, xoff4); \
128 char2++; char3++; char4++;
129#else /* PPW == 64 */
130#define GetBits4 c = ((unsigned long)(*char1++ << ShiftAmnt) << 32 ) | \
131 (SCRRIGHT (*char2 << ShiftAmnt, xoff2) << 32 ) | \
132 (SCRRIGHT (*char3 << ShiftAmnt, xoff3) << 32 ) | \
133 (SCRRIGHT (*char4 << ShiftAmnt, xoff4) << 32 ) | \
134 (*char5++ << ShiftAmnt) | \
135 SCRRIGHT (*char6 << ShiftAmnt, xoff6) | \
136 SCRRIGHT (*char7 << ShiftAmnt, xoff7) | \
137 SCRRIGHT (*char8 << ShiftAmnt, xoff8); \
138 char2++; char3++; char4++; char6++; char7++; char8++;
139#endif /* PPW */
140#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
141
142#else /* (BITMAP_BIT_ORDER != MSBFirst) || (GLYPHPADBYTES == 4) */
143
144#if BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER
145#if PPW == 32
146#define GetBits4 c = *char1++ | \
147 SCRRIGHT (*char2++, xoff2) | \
148 SCRRIGHT (*char3++, xoff3) | \
149 SCRRIGHT (*char4++, xoff4);
150#else /* PPW == 64 */
151#define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
152 (SCRRIGHT (*char2++, xoff2) << 64 ) | \
153 (SCRRIGHT (*char3++, xoff3) << 64 ) | \
154 (SCRRIGHT (*char4++, xoff4) << 64 ) | \
155 SCRRIGHT (*char5++, xoff5) | \
156 SCRRIGHT (*char6++, xoff6) | \
157 SCRRIGHT (*char7++, xoff7) | \
158 SCRRIGHT (*char8++, xoff8));
159#endif /* PPW */
160#else /* BITMAP_BIT_ORDER != IMAGE_BYTE_ORDER */
161#if PPW == 32
162#define GetBits4 c = *char1++ | \
163 SCRRIGHT (*char2, xoff2) | \
164 SCRRIGHT (*char3, xoff3) | \
165 SCRRIGHT (*char4, xoff4); \
166 char2++; char3++; char4++;
167#else /* PPW == 64 */
168#define GetBits4 c = (unsigned long)(((*char1++) << 64 ) | \
169 (SCRRIGHT (*char2, xoff2) << 64 ) | \
170 (SCRRIGHT (*char3, xoff3) << 64 ) | \
171 (SCRRIGHT (*char4, xoff4) << 64 ) | \
172 SCRRIGHT (*char5, xoff5) | \
173 SCRRIGHT (*char6, xoff6) | \
174 SCRRIGHT (*char7, xoff7) | \
175 SCRRIGHT (*char8, xoff8)); \
176 char2++; char3++; char4++; \
177 char5++; char6++; char7++; char8++;
178#endif /* PPW */
179#endif /* BITMAP_BIT_ORDER == IMAGE_BYTE_ORDER */
180
181#endif /* BITMAP_BIT_ORDER && GLYPHPADBYTES */
182
183
184#if GLYPHPADBYTES == 1
185typedef unsigned char *glyphPointer;
186#define USE_LEFTBITS
187#endif
188
189#if GLYPHPADBYTES == 2
190typedef unsigned short *glyphPointer;
191#define USE_LEFTBITS
192#endif
193
194#if GLYPHPADBYTES == 4
195typedef unsigned int *glyphPointer;
196#endif
197
198#ifdef USE_LEFTBITS
199#define GetBits1 getleftbits (char1, widthGlyph, c); \
200 c &= glyphMask; \
201 char1 = (glyphPointer) (((char *) char1) + glyphBytes);
202#else
203#define GetBits1 c = *char1++;
204#endif
205
206void
207afbTEGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase)
208 DrawablePtr pDrawable;
209 GC *pGC;
210 int x, y;
211 unsigned int nglyph;
212 CharInfoPtr *ppci; /* array of character info */
213 pointer pglyphBase; /* start of array of glyphs */
214{
215 FontPtr pfont = pGC->font;
216 int widthDst;
217 PixelType *pdstBase; /* pointer to longword with top row
218 of current glyph */
219
220 int h; /* height of glyph and char */
221 register int xpos; /* current x */
222 int ypos; /* current y */
223 int widthGlyph;
224
225 int hTmp; /* counter for height */
226 register PixelType startmask, endmask;
227 int nfirst; /* used if glyphs spans a longword boundary */
228 BoxRec bbox; /* for clipping */
229 int widthGlyphs;
230 int sizeDst;
231 int depthDst;
232 PixelType *saveDst;
233 register PixelType *dst;
234 register PixelType c;
235 register int d;
236 register int xoff1, xoff2, xoff3, xoff4;
237 register glyphPointer char1, char2, char3, char4;
238 glyphPointer schar1, schar2, schar3, schar4;
239#if PPW == 64
240 register int xoff5, xoff6, xoff7, xoff8;
241 register glyphPointer char5, char6, char7, char8;
242 glyphPointer schar5, schar6, schar7, schar8;
243#endif /* PPW */
244
245 unsigned char *rrops;
246#ifdef USE_LEFTBITS
247 register PixelType glyphMask;
248 register PixelType tmpSrc;
249 register int glyphBytes;
250#endif
251
252 afbGetPixelWidthSizeDepthAndPointer(pDrawable, widthDst, sizeDst, depthDst,
253 pdstBase);
254
255 xpos = x + pDrawable->x;
256 ypos = y + pDrawable->y;
257
258 widthGlyph = FONTMAXBOUNDS(pfont,characterWidth);
259 h = FONTASCENT(pfont) + FONTDESCENT(pfont);
260
261 xpos += FONTMAXBOUNDS(pfont,leftSideBearing);
262 ypos -= FONTASCENT(pfont);
263
264 rrops = ((afbPrivGCPtr)dixLookupPrivate(&pGC->devPrivates,
265 afbGCPrivateKey))->rropOS;
266 bbox.x1 = xpos;
267 bbox.x2 = xpos + (widthGlyph * nglyph);
268 bbox.y1 = ypos;
269 bbox.y2 = ypos + h;
270
271 switch (RECT_IN_REGION(pGC->pScreen, pGC->pCompositeClip, &bbox)) {
272 case rgnPART:
273 /* this is the WRONG thing to do, but it works.
274 calling the non-terminal text is easy, but slow, given
275 what we know about the font.
276
277 the right thing to do is something like:
278 for each clip rectangle
279 compute at which row the glyph starts to be in it,
280 and at which row the glyph ceases to be in it
281 compute which is the first glyph inside the left
282 edge, and the last one inside the right edge
283 draw a fractional first glyph, using only
284 the rows we know are in
285 draw all the whole glyphs, using the appropriate rows
286 draw any pieces of the last glyph, using the right rows
287
288 this way, the code would take advantage of knowing that
289 all glyphs are the same height and don't overlap.
290
291 one day...
292 */
293 afbImageGlyphBlt (pDrawable, pGC, x, y, nglyph, ppci, pglyphBase);
294 case rgnOUT:
295 return;
296 }
297 pdstBase = afbScanlineDeltaNoBankSwitch(pdstBase, ypos, widthDst);
298 widthGlyphs = widthGlyph * PGSZB;
299
300#ifdef USE_LEFTBITS
301 glyphMask = mfbGetendtab(widthGlyph);
302 glyphBytes = GLYPHWIDTHBYTESPADDED(*ppci);
303#endif
304
305 if (nglyph >= PGSZB && widthGlyphs <= PPW) {
306 while (nglyph >= PGSZB) {
307 nglyph -= PGSZB;
308 xoff1 = xpos & PIM;
309 xoff2 = widthGlyph;
310 xoff3 = xoff2 + widthGlyph;
311 xoff4 = xoff3 + widthGlyph;
312#if PPW == 64
313 xoff5 = xoff4 + widthGlyph;
314 xoff6 = xoff5 + widthGlyph;
315 xoff7 = xoff6 + widthGlyph;
316 xoff8 = xoff7 + widthGlyph;
317#endif /* PPW */
318 schar1 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
319 schar2 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
320 schar3 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
321 schar4 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
322#if PPW == 64
323 schar5 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
324 schar6 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
325 schar7 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
326 schar8 = (glyphPointer)FONTGLYPHBITS(pglyphBase,(*ppci++));
327#endif /* PPW */
328
329 hTmp = h;
330 saveDst = afbScanlineOffset(pdstBase, (xpos >> PWSH)); /* switch now */
331
332#ifndef FASTCHARS
333 if (xoff1 + widthGlyphs <= PPW) {
334 maskpartialbits (xoff1, widthGlyphs, startmask);
335#endif
336 for (d = 0; d < depthDst; d++) {
337 hTmp = h;
338 dst = saveDst;
339 saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
340
341 switch (rrops[d]) {
342 case RROP_BLACK:
343 while (hTmp--) {
344#ifdef FASTCHARS
345 FASTPUTBITS(0, xoff1, widthGlyphs, dst);
346#else
347 *(dst) &= ~startmask;
348#endif
349 afbScanlineInc(dst, widthDst);
350 }
351 break;
352 case RROP_WHITE:
353 while (hTmp--) {
354#ifdef FASTCHARS
355 FASTPUTBITS(~0, xoff1, widthGlyphs, dst);
356#else
357 *(dst) |= startmask;
358#endif
359 afbScanlineInc(dst, widthDst);
360 }
361 break;
362 case RROP_INVERT:
363 char1 = schar1;
364 char2 = schar2;
365 char3 = schar3;
366 char4 = schar4;
367 /* XXX */
368 while (hTmp--) {
369 GetBits4
370#ifdef FASTCHARS
371# if BITMAP_BIT_ORDER == MSBFirst
372 c >>= PPW - widthGlyphs;
373# endif
374 FASTPUTBITS(~c, xoff1, widthGlyphs, dst);
375#else
376 *(dst) = ((*dst) & ~startmask) | (~SCRRIGHT(c, xoff1) & startmask);
377#endif
378 afbScanlineInc(dst, widthDst);
379 }
380 break;
381 case RROP_COPY:
382 char1 = schar1;
383 char2 = schar2;
384 char3 = schar3;
385 char4 = schar4;
386
387 while (hTmp--) {
388 GetBits4
389#ifdef FASTCHARS
390# if BITMAP_BIT_ORDER == MSBFirst
391 c >>= PPW - widthGlyphs;
392#endif
393 FASTPUTBITS(c, xoff1, widthGlyphs, dst);
394#else
395 *(dst) = ((*dst) & ~startmask) | (SCRRIGHT(c, xoff1) & startmask);
396#endif
397 afbScanlineInc(dst, widthDst);
398 }
399 break;
400 case RROP_NOP:
401 break;
402 } /* switch (rrops[d]) */
403 } /* for (d = ... ) */
404#ifndef FASTCHARS
405 } else {
406 maskPPWbits (xoff1, widthGlyphs, startmask, endmask);
407 nfirst = PPW - xoff1;
408 for (d = 0; d < depthDst; d++) {
409 hTmp = h;
410 dst = saveDst;
411 saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
412
413 switch (rrops[d]) {
414 case RROP_BLACK:
415 while (hTmp--) {
416 dst[0] &= ~startmask;
417 dst[1] &= ~endmask;
418 afbScanlineInc(dst, widthDst);
419 }
420 break;
421 case RROP_WHITE:
422 while (hTmp--) {
423 dst[0] |= startmask;
424 dst[1] |= endmask;
425 afbScanlineInc(dst, widthDst);
426 }
427 break;
428 case RROP_INVERT:
429 char1 = schar1;
430 char2 = schar2;
431 char3 = schar3;
432 char4 = schar4;
433
434 while (hTmp--) {
435 GetBits4
436 dst[0] = (dst[0] & ~startmask) | (~SCRRIGHT(c,xoff1) & startmask);
437 dst[1] = (dst[1] & ~endmask) | (~SCRLEFT(c,nfirst) & endmask);
438 afbScanlineInc(dst, widthDst);
439 }
440 break;
441 case RROP_COPY:
442 char1 = schar1;
443 char2 = schar2;
444 char3 = schar3;
445 char4 = schar4;
446
447 while (hTmp--) {
448 GetBits4
449 dst[0] = (dst[0] & ~startmask) | (SCRRIGHT(c,xoff1) & startmask);
450 dst[1] = (dst[1] & ~endmask) | (SCRLEFT(c,nfirst) & endmask);
451 afbScanlineInc(dst, widthDst);
452 }
453 break;
454
455 case RROP_NOP:
456 break;
457 } /* switch */
458 } /* for (d = ... ) */
459 }
460#endif
461 xpos += widthGlyphs;
462 }
463 }
464
465 while(nglyph--) {
466 xoff1 = xpos & PIM;
467 schar1 = (glyphPointer) FONTGLYPHBITS(pglyphBase,(*ppci++));
468 hTmp = h;
469 saveDst = afbScanlineOffset(pdstBase, (xpos >> PWSH));
470
471 if (xoff1 + widthGlyph <= PPW) {
472 maskpartialbits (xoff1, widthGlyph, startmask);
473
474 for (d = 0; d < depthDst; d++) {
475 hTmp = h;
476 dst = saveDst;
477 saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
478 char1 = schar1;
479
480 switch (rrops[d]) {
481 case RROP_BLACK:
482 while (hTmp--) {
483 (*dst) &= ~startmask;
484 afbScanlineInc(dst, widthDst);
485 }
486 break;
487 case RROP_WHITE:
488 while (hTmp--) {
489 (*dst) |= startmask;
490 afbScanlineInc(dst, widthDst);
491 }
492 break;
493 case RROP_INVERT:
494 while (hTmp--) {
495#ifdef FASTCHARS
496#ifdef USE_LEFTBITS
497 FASTGETBITS (char1,0,widthGlyph,c);
498 char1 = (glyphPointer) (((char *) char1) + glyphBytes);
499#else
500 c = *char1++;
501#if BITMAP_BIT_ORDER == MSBFirst
502 c >>= PPW - widthGlyph;
503#endif
504#endif
505 FASTPUTBITS (~c,xoff1,widthGlyph,dst);
506#else
507 GetBits1
508 (*dst) = ((*dst) & ~startmask) | (~SCRRIGHT(c, xoff1) & startmask);
509#endif
510 afbScanlineInc(dst, widthDst);
511 }
512 break;
513 case RROP_COPY:
514 while (hTmp--) {
515#ifdef FASTCHARS
516#ifdef USE_LEFTBITS
517 FASTGETBITS (char1,0,widthGlyph,c);
518 char1 = (glyphPointer) (((char *) char1) + glyphBytes);
519#else
520 c = *char1++;
521#if BITMAP_BIT_ORDER == MSBFirst
522 c >>= PPW - widthGlyph;
523#endif
524#endif
525 FASTPUTBITS (c,xoff1,widthGlyph,dst);
526#else
527 GetBits1
528 (*dst) = ((*dst) & ~startmask) | (SCRRIGHT(c, xoff1) & startmask);
529#endif
530 afbScanlineInc(dst, widthDst);
531 }
532 break;
533 case RROP_NOP:
534 break;
535 } /* switch */
536 } /* for (d = ...) */
537 } else {
538 maskPPWbits (xoff1, widthGlyph, startmask, endmask);
539 nfirst = PPW - xoff1;
540
541 for (d = 0; d < depthDst; d++) {
542 hTmp = h;
543 dst = saveDst;
544 saveDst += sizeDst; /* @@@ NEXT PLANE @@@ */
545 char1 = schar1;
546
547 switch (rrops[d]) {
548 case RROP_BLACK:
549 while (hTmp--) {
550 dst[0] &= ~startmask;
551 dst[1] &= ~endmask;
552 afbScanlineInc(dst, widthDst);
553 }
554 break;
555 case RROP_WHITE:
556 while (hTmp--) {
557 dst[0] |= startmask;
558 dst[1] |= endmask;
559 afbScanlineInc(dst, widthDst);
560 }
561 break;
562 case RROP_INVERT:
563 while (hTmp--) {
564 GetBits1
565 dst[0] = (dst[0] & ~startmask) | (~SCRRIGHT(c,xoff1) & startmask);
566 dst[1] = (dst[1] & ~endmask) | (~SCRLEFT(c,nfirst) & endmask);
567 afbScanlineInc(dst, widthDst);
568 }
569 break;
570 case RROP_COPY:
571 while (hTmp--) {
572 GetBits1
573 dst[0] = (dst[0] & ~startmask) | (SCRRIGHT(c,xoff1) & startmask);
574 dst[1] = (dst[1] & ~endmask) | (SCRLEFT(c,nfirst) & endmask);
575 afbScanlineInc(dst, widthDst);
576 }
577 break;
578 case RROP_NOP:
579 break;
580 } /* switch */
581 } /* for (d = ...) */
582 }
583
584 xpos += widthGlyph;
585 }
586}
diff --git a/afb/afbtile.c b/afb/afbtile.c
deleted file mode 100644
index 8fcb9cde7..000000000
--- a/afb/afbtile.c
+++ /dev/null
@@ -1,857 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <X11/X.h>
55
56#include "windowstr.h"
57#include "regionstr.h"
58#include "pixmapstr.h"
59#include "scrnintstr.h"
60
61#include "afb.h"
62
63#include "maskbits.h"
64
65#include "mergerop.h"
66/*
67
68 the boxes are already translated.
69
70 NOTE:
71 iy = ++iy < tileHeight ? iy : 0
72is equivalent to iy%= tileheight, and saves a division.
73*/
74
75/*
76 tile area with a PPW bit wide pixmap
77*/
78void
79MROP_NAME(afbTileAreaPPW)(pDraw, nbox, pbox, alu, ptile, planemask)
80 DrawablePtr pDraw;
81 int nbox;
82 BoxPtr pbox;
83 int alu;
84 PixmapPtr ptile;
85 unsigned long planemask;
86{
87 register PixelType *psrc;
88 /* pointer to bits in tile, if needed */
89 int tileHeight; /* height of the tile */
90 register PixelType srcpix;
91 int nlwidth; /* width in longwords of the drawable */
92 int w; /* width of current box */
93 MROP_DECLARE_REG ()
94 register int h; /* height of current box */
95 register int nlw; /* loop version of nlwMiddle */
96 register PixelType *p; /* pointer to bits we're writing */
97 int sizeDst;
98 int depthDst;
99 register int d;
100 PixelType startmask;
101 PixelType endmask; /* masks for reggedy bits at either end of line */
102 int nlwMiddle; /* number of longwords between sides of boxes */
103 int nlwExtra; /* to get from right of box to left of next span */
104 register int iy; /* index of current scanline in tile */
105 PixelType *pbits; /* pointer to start of drawable */
106 PixelType *saveP;
107 PixelType *pSaveSrc;
108 int saveH;
109 int saveIY;
110
111 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
112 pbits);
113
114 MROP_INITIALIZE(alu,~0)
115
116 tileHeight = ptile->drawable.height;
117 pSaveSrc = (PixelType *)(ptile->devPrivate.ptr);
118
119 while (nbox--) {
120 w = pbox->x2 - pbox->x1;
121 saveH = pbox->y2 - pbox->y1;
122 saveIY = pbox->y1 % tileHeight;
123 saveP = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
124 psrc = pSaveSrc;
125
126 if (((pbox->x1 & PIM) + w) < PPW) {
127 maskpartialbits(pbox->x1, w, startmask);
128 nlwExtra = nlwidth;
129 for (d = 0; d < depthDst; d++, saveP += sizeDst, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
130 if (!(planemask & (1 << d)))
131 continue;
132
133 p = saveP;
134 h = saveH;
135 iy = saveIY;
136
137 while (h--) {
138 srcpix = psrc[iy];
139 iy++;
140 if (iy == tileHeight)
141 iy = 0;
142 *p = MROP_MASK(srcpix,*p,startmask);
143 afbScanlineInc(p, nlwExtra);
144 }
145 }
146 } else {
147 maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
148
149 for (d = 0; d < depthDst; d++, saveP += sizeDst, psrc += tileHeight) { /* @@@ NEXT PLANE @@@ */
150 if (!(planemask & (1 << d)))
151 continue;
152
153 p = saveP;
154 h = saveH;
155 iy = saveIY;
156 nlwExtra = nlwidth - nlwMiddle;
157
158 if (startmask && endmask) {
159 nlwExtra -= 1;
160 while (h--) {
161 srcpix = psrc[iy];
162 iy++;
163 if (iy == tileHeight)
164 iy = 0;
165 nlw = nlwMiddle;
166 *p = MROP_MASK (srcpix,*p,startmask);
167 p++;
168 while (nlw--) {
169 *p = MROP_SOLID(srcpix,*p);
170 p++;
171 }
172
173 *p = MROP_MASK(srcpix,*p,endmask);
174 afbScanlineInc(p, nlwExtra);
175 }
176 } else if (startmask && !endmask) {
177 nlwExtra -= 1;
178 while (h--) {
179 srcpix = psrc[iy];
180 iy++;
181 if (iy == tileHeight)
182 iy = 0;
183 nlw = nlwMiddle;
184 *p = MROP_MASK(srcpix,*p,startmask);
185 p++;
186 while (nlw--) {
187 *p = MROP_SOLID(srcpix,*p);
188 p++;
189 }
190 afbScanlineInc(p, nlwExtra);
191 }
192 } else if (!startmask && endmask) {
193 while (h--) {
194 srcpix = psrc[iy];
195 iy++;
196 if (iy == tileHeight)
197 iy = 0;
198 nlw = nlwMiddle;
199 while (nlw--) {
200 *p = MROP_SOLID(srcpix,*p);
201 p++;
202 }
203
204 *p = MROP_MASK(srcpix,*p,endmask);
205 afbScanlineInc(p, nlwExtra);
206 }
207 } else { /* no ragged bits at either end */
208 while (h--) {
209 srcpix = psrc[iy];
210 iy++;
211 if (iy == tileHeight)
212 iy = 0;
213 nlw = nlwMiddle;
214 while (nlw--) {
215 *p = MROP_SOLID (srcpix,*p);
216 p++;
217 }
218 afbScanlineInc(p, nlwExtra);
219 }
220 }
221 } /* for (d = ...) */
222 }
223 pbox++;
224 }
225}
226
227void
228MROP_NAME(afbTileArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff, planemask)
229 DrawablePtr pDraw;
230 int nbox;
231 BoxPtr pbox;
232 int alu;
233 PixmapPtr pTile;
234 int xOff;
235 int yOff;
236 unsigned long planemask;
237{
238 register PixelType *psrc;
239 /* pointer to bits in tile, if needed */
240 int nlwidth; /* width in longwords of the drawable */
241 MROP_DECLARE_REG ()
242 register int h; /* height of current box */
243 register PixelType *pdst; /* pointer to bits we're writing */
244 register PixelType tmpsrc;
245#if (MROP) != Mcopy
246 register PixelType tmpdst;
247#endif
248 int sizeDst;
249 int depthDst;
250 int sizeTile;
251 int tileLine;
252 int iline;
253 int w, width, x, xSrc, ySrc, srcStartOver, nend;
254 int tlwidth, rem, tileWidth, tileHeight, endinc;
255 int saveW;
256 PixelType *psrcT;
257 int d;
258 int nstart;
259 PixelType startmask;
260 PixelType endmask; /* masks for reggedy bits at either end of line */
261 int nlMiddle; /* number of longwords between sides of boxes */
262 int iy;
263 PixelType *pBase; /* pointer to start of drawable */
264 PixelType *saveP;
265 PixelType *pStartDst;
266 PixelType *pStartTile;
267 int saveH;
268
269 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
270 pBase);
271
272 MROP_INITIALIZE(alu,~0)
273
274 tileHeight = pTile->drawable.height;
275 tileWidth = pTile->drawable.width;
276 tlwidth = pTile->devKind / sizeof (PixelType);
277 sizeTile = tlwidth * tileHeight;
278
279 xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
280 ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
281
282 while (nbox--) {
283 saveW = pbox->x2 - pbox->x1;
284 iline = (pbox->y1 - ySrc) % tileHeight;
285 psrcT = (PixelType *) pTile->devPrivate.ptr;
286 tileLine = iline * tlwidth;
287 saveH = pbox->y2 - pbox->y1;
288 saveP = afbScanline(pBase, pbox->x1, pbox->y1, nlwidth);
289
290 for (d = 0; d < depthDst; d++, psrcT += sizeTile, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
291 if (!(planemask & (1 << d)))
292 continue;
293
294 h = saveH;
295 pStartDst = saveP;
296 pStartTile = psrcT + tileLine;
297 iy = iline;
298
299 while (h--) {
300 x = pbox->x1;
301 width = saveW;
302 pdst = pStartDst;
303 while(width > 0) {
304 psrc = pStartTile;
305 w = min(tileWidth, width);
306 if((rem = (x - xSrc) % tileWidth) != 0) {
307 /* if we're in the middle of the tile, get
308 as many bits as will finish the span, or
309 as many as will get to the left edge of the tile,
310 or a longword worth, starting at the appropriate
311 offset in the tile.
312 */
313 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
314 endinc = rem / BITMAP_SCANLINE_PAD;
315
316 getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
317#if (MROP) != Mcopy
318 getbits (pdst, (x & PIM), w, tmpdst);
319 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
320#endif
321 putbits (tmpsrc, (x & PIM), w, pdst);
322
323 if((x & PIM) + w >= PPW)
324 pdst++;
325 } else if(((x & PIM) + w) < PPW) {
326 /* doing < PPW bits is easy, and worth special-casing */
327 tmpsrc = *psrc;
328#if (MROP) != Mcopy
329 getbits (pdst, (x & PIM), w, tmpdst);
330 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
331#endif
332 putbits (tmpsrc, (x & PIM), w, pdst);
333 } else {
334 /* start at the left edge of the tile,
335 and put down as much as we can
336 */
337 maskbits(x, w, startmask, endmask, nlMiddle);
338
339 if (startmask)
340 nstart = PPW - (x & PIM);
341 else
342 nstart = 0;
343 if (endmask)
344 nend = (x + w) & PIM;
345 else
346 nend = 0;
347
348 srcStartOver = nstart > PLST;
349
350 if(startmask) {
351 tmpsrc = *psrc;
352#if (MROP) != Mcopy
353 getbits (pdst, (x & PIM), nstart, tmpdst);
354 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
355#endif
356 putbits (tmpsrc, (x & PIM), nstart, pdst);
357 pdst++;
358 if(srcStartOver)
359 psrc++;
360 }
361
362 while(nlMiddle--) {
363 getbits (psrc, nstart, PPW, tmpsrc);
364#if (MROP) != Mcopy
365 tmpdst = *pdst;
366 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
367#endif
368 *pdst++ = tmpsrc;
369 /*putbits (tmpsrc, 0, PPW, pdst);
370 pdst++;*/
371 psrc++;
372 }
373
374 if(endmask) {
375 getbits (psrc, nstart, nend, tmpsrc);
376#if (MROP) != Mcopy
377 tmpdst = *pdst;
378 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
379#endif
380 putbits (tmpsrc, 0, nend, pdst);
381 }
382 }
383 x += w;
384 width -= w;
385 } /* while (width > 0) */
386
387 pStartDst += nlwidth;
388 if (++iy >= tileHeight) {
389 iy = 0;
390 pStartTile = psrcT;
391 } else
392 pStartTile += tlwidth;
393
394 } /* while (h) */
395 } /* for (d = ... ) */
396 pbox++;
397 } /* for each box */
398}
399
400void
401MROP_NAME(afbOpaqueStippleAreaPPW)(pDraw, nbox, pbox, alu, ptile,
402 rropsOS, planemask)
403 DrawablePtr pDraw;
404 int nbox;
405 BoxPtr pbox;
406 int alu;
407 PixmapPtr ptile;
408 register unsigned char *rropsOS;
409 unsigned long planemask;
410{
411 register PixelType *psrc;
412 /* pointer to bits in tile, if needed */
413 int tileHeight; /* height of the tile */
414 register PixelType srcpix = 0;
415 int nlwidth; /* width in longwords of the drawable */
416 int w; /* width of current box */
417 MROP_DECLARE_REG ()
418 register int h; /* height of current box */
419 register int nlw; /* loop version of nlwMiddle */
420 register PixelType *p; /* pointer to bits we're writing */
421 int sizeDst;
422 int depthDst;
423 register int d;
424 PixelType startmask;
425 PixelType endmask; /* masks for reggedy bits at either end of line */
426 int nlwMiddle; /* number of longwords between sides of boxes */
427 int nlwExtra; /* to get from right of box to left of next span */
428 register int iy; /* index of current scanline in tile */
429 PixelType *pbits; /* pointer to start of drawable */
430 PixelType *saveP;
431 int saveH;
432 int saveIY;
433
434 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
435 pbits);
436
437 MROP_INITIALIZE(alu,~0)
438
439 tileHeight = ptile->drawable.height;
440 psrc = (PixelType *)(ptile->devPrivate.ptr);
441
442 while (nbox--) {
443 w = pbox->x2 - pbox->x1;
444 saveH = pbox->y2 - pbox->y1;
445 saveIY = pbox->y1 % tileHeight;
446 saveP = afbScanline(pbits, pbox->x1, pbox->y1, nlwidth);
447
448 if ( ((pbox->x1 & PIM) + w) < PPW) {
449 maskpartialbits(pbox->x1, w, startmask);
450 nlwExtra = nlwidth;
451 for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
452 if (!(planemask & (1 << d)))
453 continue;
454
455 p = saveP;
456 h = saveH;
457 iy = saveIY;
458
459 while (h--) {
460 switch (rropsOS[d]) {
461 case RROP_BLACK:
462 srcpix = 0;
463 break;
464 case RROP_WHITE:
465 srcpix = ~0;
466 break;
467 case RROP_COPY:
468 srcpix = psrc[iy];
469 break;
470 case RROP_INVERT:
471 srcpix = ~psrc[iy];
472 break;
473 }
474 iy++;
475 if (iy == tileHeight)
476 iy = 0;
477 *p = MROP_MASK(srcpix,*p,startmask);
478 afbScanlineInc(p, nlwExtra);
479 }
480 }
481 } else {
482 maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
483
484 for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
485 if (!(planemask & (1 << d)))
486 continue;
487
488 p = saveP;
489 h = saveH;
490 iy = saveIY;
491 nlwExtra = nlwidth - nlwMiddle;
492
493 if (startmask && endmask) {
494 nlwExtra -= 1;
495 while (h--) {
496 switch (rropsOS[d]) {
497 case RROP_BLACK:
498 srcpix = 0;
499 break;
500 case RROP_WHITE:
501 srcpix = ~0;
502 break;
503 case RROP_COPY:
504 srcpix = psrc[iy];
505 break;
506 case RROP_INVERT:
507 srcpix = ~psrc[iy];
508 break;
509 }
510 iy++;
511 if (iy == tileHeight)
512 iy = 0;
513 nlw = nlwMiddle;
514 *p = MROP_MASK (srcpix,*p,startmask);
515 p++;
516 while (nlw--) {
517 *p = MROP_SOLID(srcpix,*p);
518 p++;
519 }
520
521 *p = MROP_MASK(srcpix,*p,endmask);
522 afbScanlineInc(p, nlwExtra);
523 }
524 } else if (startmask && !endmask) {
525 nlwExtra -= 1;
526 while (h--) {
527 switch (rropsOS[d]) {
528 case RROP_BLACK:
529 srcpix = 0;
530 break;
531 case RROP_WHITE:
532 srcpix = ~0;
533 break;
534 case RROP_COPY:
535 srcpix = psrc[iy];
536 break;
537 case RROP_INVERT:
538 srcpix = ~psrc[iy];
539 break;
540 }
541 iy++;
542 if (iy == tileHeight)
543 iy = 0;
544 nlw = nlwMiddle;
545 *p = MROP_MASK(srcpix,*p,startmask);
546 p++;
547 while (nlw--) {
548 *p = MROP_SOLID(srcpix,*p);
549 p++;
550 }
551 afbScanlineInc(p, nlwExtra);
552 }
553 } else if (!startmask && endmask) {
554 while (h--) {
555 switch (rropsOS[d]) {
556 case RROP_BLACK:
557 srcpix = 0;
558 break;
559 case RROP_WHITE:
560 srcpix = ~0;
561 break;
562 case RROP_COPY:
563 srcpix = psrc[iy];
564 break;
565 case RROP_INVERT:
566 srcpix = ~psrc[iy];
567 break;
568 }
569 iy++;
570 if (iy == tileHeight)
571 iy = 0;
572 nlw = nlwMiddle;
573 while (nlw--) {
574 *p = MROP_SOLID(srcpix,*p);
575 p++;
576 }
577
578 *p = MROP_MASK(srcpix,*p,endmask);
579 afbScanlineInc(p, nlwExtra);
580 }
581 } else { /* no ragged bits at either end */
582 while (h--) {
583 switch (rropsOS[d]) {
584 case RROP_BLACK:
585 srcpix = 0;
586 break;
587 case RROP_WHITE:
588 srcpix = ~0;
589 break;
590 case RROP_COPY:
591 srcpix = psrc[iy];
592 break;
593 case RROP_INVERT:
594 srcpix = ~psrc[iy];
595 break;
596 }
597 iy++;
598 if (iy == tileHeight)
599 iy = 0;
600 nlw = nlwMiddle;
601 while (nlw--) {
602 *p = MROP_SOLID (srcpix,*p);
603 p++;
604 }
605 afbScanlineInc(p, nlwExtra);
606 }
607 }
608 } /* for (d = ...) */
609 }
610 pbox++;
611 }
612}
613
614void
615MROP_NAME(afbOpaqueStippleArea)(pDraw, nbox, pbox, alu, pTile, xOff, yOff,
616 rropsOS, planemask)
617 DrawablePtr pDraw;
618 int nbox;
619 BoxPtr pbox;
620 int alu;
621 PixmapPtr pTile;
622 int xOff;
623 int yOff;
624 register unsigned char *rropsOS;
625 unsigned long planemask;
626{
627 register PixelType *psrc;
628 /* pointer to bits in tile, if needed */
629 int nlwidth; /* width in longwords of the drawable */
630 MROP_DECLARE_REG ()
631 register int h; /* height of current box */
632 register PixelType *pdst; /* pointer to bits we're writing */
633 register PixelType tmpsrc = 0;
634#if (MROP) != Mcopy
635 register PixelType tmpdst;
636#endif
637 int sizeDst;
638 int depthDst;
639 int tileLine;
640 int iline;
641 int w, width, x, xSrc, ySrc, srcStartOver, nend;
642 int tlwidth, rem, tileWidth, tileHeight, endinc;
643 int saveW;
644 PixelType *psrcT;
645 int d;
646 int nstart;
647 PixelType startmask;
648 PixelType endmask; /* masks for reggedy bits at either end of line */
649 int nlMiddle; /* number of longwords between sides of boxes */
650 int iy;
651 PixelType *pBase; /* pointer to start of drawable */
652 PixelType *saveP;
653 PixelType *pStartDst;
654 PixelType *pStartTile;
655 int saveH;
656
657 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
658 pBase);
659
660 MROP_INITIALIZE(alu,~0)
661
662 tileHeight = pTile->drawable.height;
663 tileWidth = pTile->drawable.width;
664 tlwidth = pTile->devKind / sizeof (PixelType);
665
666 xSrc = pDraw->x + ((xOff % tileWidth) - tileWidth);
667 ySrc = pDraw->y + ((yOff % tileHeight) - tileHeight);
668
669 while (nbox--) {
670 saveW = pbox->x2 - pbox->x1;
671 iline = (pbox->y1 - ySrc) % tileHeight;
672 psrcT = (PixelType *) pTile->devPrivate.ptr;
673 tileLine = iline * tlwidth;
674 saveH = pbox->y2 - pbox->y1;
675 saveP = afbScanline(pBase, pbox->x1, pbox->y1, nlwidth);
676
677 for (d = 0; d < depthDst; d++, saveP += sizeDst) { /* @@@ NEXT PLANE @@@ */
678 if (!(planemask & (1 << d)))
679 continue;
680
681 h = saveH;
682 pStartDst = saveP;
683 pStartTile = psrcT + tileLine;
684 iy = iline;
685
686 while (h--) {
687 x = pbox->x1;
688 width = saveW;
689 pdst = pStartDst;
690 while(width > 0) {
691 psrc = pStartTile;
692 w = min(tileWidth, width);
693 if((rem = (x - xSrc) % tileWidth) != 0) {
694 /* if we're in the middle of the tile, get
695 as many bits as will finish the span, or
696 as many as will get to the left edge of the tile,
697 or a longword worth, starting at the appropriate
698 offset in the tile.
699 */
700 w = min(min(tileWidth - rem, width), BITMAP_SCANLINE_PAD);
701 endinc = rem / BITMAP_SCANLINE_PAD;
702
703 switch (rropsOS[d]) {
704 case RROP_BLACK:
705 tmpsrc = 0;
706 break;
707 case RROP_WHITE:
708 tmpsrc = ~0;
709 break;
710
711 case RROP_COPY:
712 getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
713 break;
714
715 case RROP_INVERT:
716 getbits ((psrc+endinc), (rem&PIM), w, tmpsrc);
717 tmpsrc = ~tmpsrc;
718 break;
719 }
720#if (MROP) != Mcopy
721 getbits (pdst, (x & PIM), w, tmpdst);
722 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
723#endif
724 putbits (tmpsrc, (x & PIM), w, pdst);
725
726 if((x & PIM) + w >= PPW)
727 pdst++;
728 } else if(((x & PIM) + w) < PPW) {
729 /* doing < PPW bits is easy, and worth special-casing */
730 switch (rropsOS[d]) {
731 case RROP_BLACK:
732 tmpsrc = 0;
733 break;
734 case RROP_WHITE:
735 tmpsrc = ~0;
736 break;
737 case RROP_COPY:
738 tmpsrc = *psrc;
739 break;
740 case RROP_INVERT:
741 tmpsrc = ~*psrc;
742 break;
743 }
744#if (MROP) != Mcopy
745 getbits (pdst, (x & PIM), w, tmpdst);
746 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
747#endif
748 putbits (tmpsrc, (x & PIM), w, pdst);
749 } else {
750 /* start at the left edge of the tile,
751 and put down as much as we can
752 */
753 maskbits(x, w, startmask, endmask, nlMiddle);
754
755 if (startmask)
756 nstart = PPW - (x & PIM);
757 else
758 nstart = 0;
759 if (endmask)
760 nend = (x + w) & PIM;
761 else
762 nend = 0;
763
764 srcStartOver = nstart > PLST;
765
766 if(startmask) {
767 switch (rropsOS[d]) {
768 case RROP_BLACK:
769 tmpsrc = 0;
770 break;
771 case RROP_WHITE:
772 tmpsrc = ~0;
773 break;
774 case RROP_COPY:
775 tmpsrc = *psrc;
776 break;
777 case RROP_INVERT:
778 tmpsrc = ~*psrc;
779 break;
780 }
781#if (MROP) != Mcopy
782 getbits (pdst, (x & PIM), nstart, tmpdst);
783 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
784#endif
785 putbits (tmpsrc, (x & PIM), nstart, pdst);
786 pdst++;
787 if(srcStartOver)
788 psrc++;
789 }
790
791 while(nlMiddle--) {
792 switch (rropsOS[d]) {
793 case RROP_BLACK:
794 tmpsrc = 0;
795 break;
796 case RROP_WHITE:
797 tmpsrc = ~0;
798 break;
799 case RROP_COPY:
800 getbits (psrc, nstart, PPW, tmpsrc);
801 break;
802 case RROP_INVERT:
803 getbits (psrc, nstart, PPW, tmpsrc);
804 tmpsrc = ~tmpsrc;
805 break;
806 }
807#if (MROP) != Mcopy
808 tmpdst = *pdst;
809 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
810#endif
811 *pdst++ = tmpsrc;
812 /*putbits (tmpsrc, 0, PPW, pdst);
813 pdst++; */
814 psrc++;
815 }
816
817 if(endmask) {
818 switch (rropsOS[d]) {
819 case RROP_BLACK:
820 tmpsrc = 0;
821 break;
822 case RROP_WHITE:
823 tmpsrc = ~0;
824 break;
825
826 case RROP_COPY:
827 getbits (psrc, nstart, nend, tmpsrc);
828 break;
829
830 case RROP_INVERT:
831 getbits (psrc, nstart, nend, tmpsrc);
832 tmpsrc = ~tmpsrc;
833 break;
834 }
835#if (MROP) != Mcopy
836 tmpdst = *pdst;
837 tmpsrc = DoMergeRop (tmpsrc, tmpdst);
838#endif
839 putbits (tmpsrc, 0, nend, pdst);
840 }
841 }
842 x += w;
843 width -= w;
844 } /* while (width > 0) */
845
846 pStartDst += nlwidth;
847 if (++iy >= tileHeight) {
848 iy = 0;
849 pStartTile = psrcT;
850 } else
851 pStartTile += tlwidth;
852
853 } /* while (h) */
854 } /* for (d = ... ) */
855 pbox++;
856 } /* for each box */
857}
diff --git a/afb/afbwindow.c b/afb/afbwindow.c
deleted file mode 100644
index c0dee980d..000000000
--- a/afb/afbwindow.c
+++ /dev/null
@@ -1,164 +0,0 @@
1/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2/***********************************************************
3
4Copyright (c) 1987 X Consortium
5
6Permission is hereby granted, free of charge, to any person obtaining a copy
7of this software and associated documentation files (the "Software"), to deal
8in the Software without restriction, including without limitation the rights
9to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10copies of the Software, and to permit persons to whom the Software is
11furnished to do so, subject to the following conditions:
12
13The above copyright notice and this permission notice shall be included in
14all copies or substantial portions of the Software.
15
16THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22
23Except as contained in this notice, the name of the X Consortium shall not be
24used in advertising or otherwise to promote the sale, use or other dealings
25in this Software without prior written authorization from the X Consortium.
26
27
28Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
29
30 All Rights Reserved
31
32Permission to use, copy, modify, and distribute this software and its
33documentation for any purpose and without fee is hereby granted,
34provided that the above copyright notice appear in all copies and that
35both that copyright notice and this permission notice appear in
36supporting documentation, and that the name of Digital not be
37used in advertising or publicity pertaining to distribution of the
38software without specific, written prior permission.
39
40DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
46SOFTWARE.
47
48******************************************************************/
49
50#ifdef HAVE_DIX_CONFIG_H
51#include <dix-config.h>
52#endif
53
54#include <stdlib.h>
55
56#include <X11/X.h>
57#include "scrnintstr.h"
58#include "windowstr.h"
59#include "privates.h"
60#include "afb.h"
61#include "mistruct.h"
62#include "regionstr.h"
63#include "maskbits.h"
64
65Bool
66afbCreateWindow(WindowPtr pWin)
67{
68 return (TRUE);
69}
70
71/* This always returns true, because Xfree can't fail. It might be possible
72 * on some devices for Destroy to fail */
73Bool
74afbDestroyWindow(WindowPtr pWin)
75{
76 return (TRUE);
77}
78
79/*ARGSUSED*/
80Bool
81afbMapWindow(pWindow)
82 WindowPtr pWindow;
83{
84 return (TRUE);
85}
86
87/*ARGSUSED*/
88Bool
89afbPositionWindow(WindowPtr pWin, int x, int y)
90{
91 /* This is the "wrong" fix to the right problem, but it doesn't really
92 * cost very much. When the window is moved, we need to invalidate any
93 * RotatedPixmap that exists in any GC currently validated against this
94 * window.
95 */
96 pWin->drawable.serialNumber = NEXT_SERIAL_NUMBER;
97
98 /* Again, we have no failure modes indicated by any of the routines
99 * we've called, so we have to assume it worked */
100 return (TRUE);
101}
102
103/*ARGSUSED*/
104Bool
105afbUnmapWindow(pWindow)
106 WindowPtr pWindow;
107{
108 return (TRUE);
109}
110
111/* UNCLEAN!
112 this code calls the bitblt helper code directly.
113
114 afbCopyWindow copies only the parts of the destination that are
115visible in the source.
116*/
117
118
119void
120afbCopyWindow(pWin, ptOldOrg, prgnSrc)
121 WindowPtr pWin;
122 DDXPointRec ptOldOrg;
123 RegionPtr prgnSrc;
124{
125 DDXPointPtr pptSrc;
126 register DDXPointPtr ppt;
127 RegionPtr prgnDst;
128 register BoxPtr pbox;
129 register int dx, dy;
130 register int i, nbox;
131 WindowPtr pwinRoot;
132
133 pwinRoot = WindowTable[pWin->drawable.pScreen->myNum];
134
135 prgnDst = REGION_CREATE(pWin->drawable.pScreen, NULL, 1);
136
137 dx = ptOldOrg.x - pWin->drawable.x;
138 dy = ptOldOrg.y - pWin->drawable.y;
139 REGION_TRANSLATE(pWin->drawable.pScreen, prgnSrc, -dx, -dy);
140 REGION_INTERSECT(pWin->drawable.pScreen, prgnDst, &pWin->borderClip,
141 prgnSrc);
142
143 pbox = REGION_RECTS(prgnDst);
144 nbox = REGION_NUM_RECTS(prgnDst);
145 if(!(pptSrc = (DDXPointPtr )xalloc(nbox * sizeof(DDXPointRec))))
146 return;
147 ppt = pptSrc;
148
149 for (i=nbox; --i >= 0; ppt++, pbox++) {
150 ppt->x = pbox->x1 + dx;
151 ppt->y = pbox->y1 + dy;
152 }
153
154 afbDoBitblt((DrawablePtr)pwinRoot, (DrawablePtr)pwinRoot, GXcopy, prgnDst,
155 pptSrc, ~0);
156 xfree(pptSrc);
157 REGION_DESTROY(pWin->drawable.pScreen, prgnDst);
158}
159
160Bool
161afbChangeWindowAttributes(WindowPtr pWin, unsigned long mask)
162{
163 return (TRUE);
164}
diff --git a/afb/afbzerarc.c b/afb/afbzerarc.c
deleted file mode 100644
index e53488e02..000000000
--- a/afb/afbzerarc.c
+++ /dev/null
@@ -1,201 +0,0 @@
1/************************************************************
2
3Copyright (c) 1989 X Consortium
4
5Permission is hereby granted, free of charge, to any person obtaining a copy
6of this software and associated documentation files (the "Software"), to deal
7in the Software without restriction, including without limitation the rights
8to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9copies of the Software, and to permit persons to whom the Software is
10furnished to do so, subject to the following conditions:
11
12The above copyright notice and this permission notice shall be included in
13all copies or substantial portions of the Software.
14
15THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
19AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
20CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22Except as contained in this notice, the name of the X Consortium shall not be
23used in advertising or otherwise to promote the sale, use or other dealings
24in this Software without prior written authorization from the X Consortium.
25
26********************************************************/
27
28
29/* Derived from:
30 * "Algorithm for drawing ellipses or hyperbolae with a digital plotter"
31 * by M. L. V. Pitteway
32 * The Computer Journal, November 1967, Volume 10, Number 3, pp. 282-289
33 */
34
35#ifdef HAVE_DIX_CONFIG_H
36#include <dix-config.h>
37#endif
38
39#include <X11/X.h>
40#include <X11/Xprotostr.h>
41#include "regionstr.h"
42#include "gcstruct.h"
43#include "pixmapstr.h"
44#include "scrnintstr.h"
45#include "afb.h"
46#include "maskbits.h"
47#include "mizerarc.h"
48#include "mi.h"
49
50/*
51 * Note: LEFTMOST must be the bit leftmost in the actual screen
52 * representation. This depends also on the IMAGE_BYTE_ORDER.
53 * LONG2CHARS() takes care of the re-ordering as required. (DHD)
54 */
55#if (BITMAP_BIT_ORDER == MSBFirst)
56#define LEFTMOST ((PixelType) LONG2CHARS((1 << PLST)))
57#else
58#define LEFTMOST ((PixelType) LONG2CHARS(1))
59#endif
60
61#define Pixelate(base,yoff,xoff) \
62{ \
63 paddr = afbScanlineOffset(base, (yoff) + ((xoff)>>PWSH)); \
64 pmask = SCRRIGHT(LEFTMOST, (xoff) & PIM); \
65 for (de = 0; de < depthDst; de++, paddr += sizeDst) /* @@@ NEXT PLANE @@@ */ \
66 switch (rrops[de]) { \
67 case RROP_BLACK: \
68 *paddr &= ~pmask; \
69 break; \
70 case RROP_WHITE: \
71 *paddr |= pmask; \
72 break; \
73 case RROP_INVERT: \
74 *paddr ^= pmask; \
75 break; \
76 case RROP_NOP: \
77 break; \
78 } \
79}
80
81#define DoPix(bit,base,yoff,xoff) if (mask & bit) Pixelate(base,yoff,xoff);
82
83static void
84afbZeroArcSS(DrawablePtr pDraw, GCPtr pGC, xArc *arc)
85{
86 miZeroArcRec info;
87 Bool do360;
88 register int de;
89 register int x, y, a, b, d, mask;
90 register int k1, k3, dx, dy;
91 PixelType *addrl;
92 PixelType *yorgl, *yorgol;
93 int nlwidth, yoffset, dyoffset;
94 int sizeDst, depthDst;
95 PixelType pmask;
96 register PixelType *paddr;
97 register unsigned char *rrops;
98
99 rrops = ((afbPrivGC *)dixLookupPrivate(&pGC->devPrivates,
100 afbGCPrivateKey))->rrops;
101 afbGetPixelWidthSizeDepthAndPointer(pDraw, nlwidth, sizeDst, depthDst,
102 addrl);
103 do360 = miZeroArcSetup(arc, &info, TRUE);
104 yorgl = addrl + ((info.yorg + pDraw->y) * nlwidth);
105 yorgol = addrl + ((info.yorgo + pDraw->y) * nlwidth);
106 info.xorg += pDraw->x;
107 info.xorgo += pDraw->x;
108 MIARCSETUP();
109 yoffset = y ? nlwidth : 0;
110 dyoffset = 0;
111 mask = info.initialMask;
112 if (!(arc->width & 1)) {
113 DoPix(2, yorgl, 0, info.xorgo);
114 DoPix(8, yorgol, 0, info.xorgo);
115 }
116 if (!info.end.x || !info.end.y) {
117 mask = info.end.mask;
118 info.end = info.altend;
119 }
120 if (do360 && (arc->width == arc->height) && !(arc->width & 1)) {
121 int xoffset = nlwidth;
122 PixelType *yorghl = afbScanlineDeltaNoBankSwitch(yorgl, info.h, nlwidth);
123 int xorghp = info.xorg + info.h;
124 int xorghn = info.xorg - info.h;
125
126 while (1) {
127 Pixelate(yorgl, yoffset, info.xorg + x);
128 Pixelate(yorgl, yoffset, info.xorg - x);
129 Pixelate(yorgol, -yoffset, info.xorg - x);
130 Pixelate(yorgol, -yoffset, info.xorg + x);
131 if (a < 0)
132 break;
133 Pixelate(yorghl, -xoffset, xorghp - y);
134 Pixelate(yorghl, -xoffset, xorghn + y);
135 Pixelate(yorghl, xoffset, xorghn + y);
136 Pixelate(yorghl, xoffset, xorghp - y);
137 xoffset += nlwidth;
138 MIARCCIRCLESTEP(yoffset += nlwidth;);
139 }
140 x = info.w;
141 yoffset = info.h * nlwidth;
142 } else if (do360) {
143 while (y < info.h || x < info.w) {
144 MIARCOCTANTSHIFT(dyoffset = nlwidth;);
145 Pixelate(yorgl, yoffset, info.xorg + x);
146 Pixelate(yorgl, yoffset, info.xorgo - x);
147 Pixelate(yorgol, -yoffset, info.xorgo - x);
148 Pixelate(yorgol, -yoffset, info.xorg + x);
149 MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
150 }
151 } else {
152 while (y < info.h || x < info.w) {
153 MIARCOCTANTSHIFT(dyoffset = nlwidth;);
154 if ((x == info.start.x) || (y == info.start.y)) {
155 mask = info.start.mask;
156 info.start = info.altstart;
157 }
158 DoPix(1, yorgl, yoffset, info.xorg + x);
159 DoPix(2, yorgl, yoffset, info.xorgo - x);
160 DoPix(4, yorgol, -yoffset, info.xorgo - x);
161 DoPix(8, yorgol, -yoffset, info.xorg + x);
162 if ((x == info.end.x) || (y == info.end.y)) {
163 mask = info.end.mask;
164 info.end = info.altend;
165 }
166 MIARCSTEP(yoffset += dyoffset;, yoffset += nlwidth;);
167 }
168 }
169 if ((x == info.start.x) || (y == info.start.y))
170 mask = info.start.mask;
171 DoPix(1, yorgl, yoffset, info.xorg + x);
172 DoPix(4, yorgol, -yoffset, info.xorgo - x);
173 if (arc->height & 1) {
174 DoPix(2, yorgl, yoffset, info.xorgo - x);
175 DoPix(8, yorgol, -yoffset, info.xorg + x);
176 }
177}
178
179void
180afbZeroPolyArcSS(DrawablePtr pDraw, GCPtr pGC, int narcs, xArc *parcs)
181{
182 register xArc *arc;
183 register int i;
184 BoxRec box;
185 RegionPtr cclip;
186
187 cclip = pGC->pCompositeClip;
188 for (arc = parcs, i = narcs; --i >= 0; arc++) {
189 if (miCanZeroArc(arc)) {
190 box.x1 = arc->x + pDraw->x;
191 box.y1 = arc->y + pDraw->y;
192 box.x2 = box.x1 + (int)arc->width + 1;
193 box.y2 = box.y1 + (int)arc->height + 1;
194 if (RECT_IN_REGION(pDraw->pScreen, cclip, &box) == rgnIN)
195 afbZeroArcSS(pDraw, pGC, arc);
196 else
197 miZeroPolyArc(pDraw, pGC, 1, arc);
198 } else
199 miPolyArc(pDraw, pGC, 1, arc);
200 }
201}
diff --git a/configure.ac b/configure.ac
index 7c749f52e..8a1b73f20 100644
--- a/configure.ac
+++ b/configure.ac
@@ -573,7 +573,6 @@ AC_ARG_ENABLE(xglx, AS_HELP_STRING([--enable-xglx], [Build Xglx xgl mo
573AC_ARG_ENABLE(xegl, AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no]) 573AC_ARG_ENABLE(xegl, AS_HELP_STRING([--enable-xegl], [Build Xegl xgl module (default: no)]), [XEGL=$enableval], [XEGL=no])
574dnl legacy fb support 574dnl legacy fb support
575AC_ARG_ENABLE(mfb, AS_HELP_STRING([--enable-mfb], [Build legacy mono framebuffer support (default: disable)]), [MFB=$enableval], [MFB=no]) 575AC_ARG_ENABLE(mfb, AS_HELP_STRING([--enable-mfb], [Build legacy mono framebuffer support (default: disable)]), [MFB=$enableval], [MFB=no])
576AC_ARG_ENABLE(afb, AS_HELP_STRING([--enable-afb], [Build legacy advanced framebuffer support (default: disable)]), [AFB=$enableval], [AFB=no])
577dnl kdrive and its subsystems 576dnl kdrive and its subsystems
578AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no]) 577AC_ARG_ENABLE(kdrive, AS_HELP_STRING([--enable-kdrive], [Build kdrive servers (default: no)]), [KDRIVE=$enableval], [KDRIVE=no])
579AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto]) 578AC_ARG_ENABLE(xephyr, AS_HELP_STRING([--enable-xephyr], [Build the kdrive Xephyr server (default: auto)]), [XEPHYR=$enableval], [XEPHYR=auto])
@@ -1581,10 +1580,8 @@ AM_CONDITIONAL([XF86VIDMODE], [test "x$XF86VIDMODE" = xyes])
1581 1580
1582dnl legacy fb support 1581dnl legacy fb support
1583test "x$MFB" = xauto && MFB="$XORG" 1582test "x$MFB" = xauto && MFB="$XORG"
1584test "x$AFB" = xauto && AFB="$XORG"
1585AM_CONDITIONAL(MFB, [test "x$MFB" = xyes]) 1583AM_CONDITIONAL(MFB, [test "x$MFB" = xyes])
1586AM_CONDITIONAL(AFB, [test "x$AFB" = xyes]) 1584if test "x$MFB" = xyes; then
1587if test "x$MFB" = xyes -o "x$AFB" = xyes; then
1588 if test "x$XORG" != xyes; then 1585 if test "x$XORG" != xyes; then
1589 AC_MSG_ERROR([legacy fb support requires the Xorg server]) 1586 AC_MSG_ERROR([legacy fb support requires the Xorg server])
1590 fi 1587 fi
@@ -1992,7 +1989,6 @@ AC_OUTPUT([
1992Makefile 1989Makefile
1993glx/Makefile 1990glx/Makefile
1994include/Makefile 1991include/Makefile
1995afb/Makefile
1996composite/Makefile 1992composite/Makefile
1997damageext/Makefile 1993damageext/Makefile
1998dbe/Makefile 1994dbe/Makefile
diff --git a/hw/xfree86/dixmods/Makefile.am b/hw/xfree86/dixmods/Makefile.am
index 904507971..bb79c9c61 100644
--- a/hw/xfree86/dixmods/Makefile.am
+++ b/hw/xfree86/dixmods/Makefile.am
@@ -14,10 +14,6 @@ if DBE
14DBEMOD = libdbe.la 14DBEMOD = libdbe.la
15endif 15endif
16 16
17if AFB
18AFBMOD = libafb.la
19endif
20
21if MFB 17if MFB
22MFBMOD = libmfb.la 18MFBMOD = libmfb.la
23endif 19endif
@@ -26,8 +22,7 @@ if RECORD
26RECORDMOD = librecord.la 22RECORDMOD = librecord.la
27endif 23endif
28 24
29module_LTLIBRARIES = $(AFBMOD) \ 25module_LTLIBRARIES = libfb.la \
30 libfb.la \
31 libwfb.la \ 26 libwfb.la \
32 $(MFBMOD) \ 27 $(MFBMOD) \
33 libshadow.la 28 libshadow.la
@@ -48,10 +43,6 @@ INCLUDES = @XORG_INCS@ \
48 -I$(top_srcdir)/miext/shadow \ 43 -I$(top_srcdir)/miext/shadow \
49 -I$(top_srcdir)/glx 44 -I$(top_srcdir)/glx
50 45
51libafb_la_LDFLAGS = -avoid-version
52libafb_la_LIBADD = $(top_builddir)/afb/libafb.la
53libafb_la_SOURCES = afbmodule.c
54
55libdbe_la_LDFLAGS = -avoid-version 46libdbe_la_LDFLAGS = -avoid-version
56libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la 47libdbe_la_LIBADD = $(top_builddir)/dbe/libdbe.la
57libdbe_la_SOURCES = dbemodule.c 48libdbe_la_SOURCES = dbemodule.c
diff --git a/hw/xfree86/dixmods/afbmodule.c b/hw/xfree86/dixmods/afbmodule.c
deleted file mode 100644
index b0aea6ddc..000000000
--- a/hw/xfree86/dixmods/afbmodule.c
+++ /dev/null
@@ -1,57 +0,0 @@
1/*
2 * Copyright (C) 1998 The XFree86 Project, Inc. All Rights Reserved.
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy
5 * of this software and associated documentation files (the "Software"), to
6 * deal in the Software without restriction, including without limitation the
7 * rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
8 * sell copies of the Software, and to permit persons to whom the Software is
9 * furnished to do so, subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in
12 * all copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
16 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
17 * XFREE86 PROJECT BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 *
21 * Except as contained in this notice, the name of the XFree86 Project shall
22 * not be used in advertising or otherwise to promote the sale, use or other
23 * dealings in this Software without prior written authorization from the
24 * XFree86 Project.
25 */
26
27#ifdef HAVE_XORG_CONFIG_H
28#include <xorg-config.h>
29#endif
30
31#include "xf86Module.h"
32
33static MODULESETUPPROTO(afbSetup);
34
35static XF86ModuleVersionInfo VersRec =
36{
37 "afb",
38 MODULEVENDORSTRING,
39 MODINFOSTRING1,
40 MODINFOSTRING2,
41 XORG_VERSION_CURRENT,
42 1, 0, 0,
43 ABI_CLASS_ANSIC, /* Only need the ansic layer */
44 ABI_ANSIC_VERSION,
45 MOD_CLASS_NONE,
46 {0,0,0,0} /* signature, to be patched into the file by a tool */
47};
48
49_X_EXPORT XF86ModuleData afbModuleData = { &VersRec, afbSetup, NULL };
50
51static pointer
52afbSetup(pointer module, pointer opts, int *errmaj, int *errmin)
53{
54 /* This modules requires mfb, so load it */
55 return LoadSubModule(module, "mfb", NULL, NULL, NULL, NULL,
56 errmaj, errmin);
57}