1 /* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 */
2 /***********************************************************
4 Copyright (c) 1987 X Consortium
6 Permission is hereby granted, free of charge, to any person obtaining a copy
7 of this software and associated documentation files (the "Software"), to deal
8 in the Software without restriction, including without limitation the rights
9 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 copies of the Software, and to permit persons to whom the Software is
11 furnished to do so, subject to the following conditions:
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19 X CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
20 AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
21 CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 Except as contained in this notice, the name of the X Consortium shall not be
24 used in advertising or otherwise to promote the sale, use or other dealings
25 in this Software without prior written authorization from the X Consortium.
28 Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
32 Permission to use, copy, modify, and distribute this software and its
33 documentation for any purpose and without fee is hereby granted,
34 provided that the above copyright notice appear in all copies and that
35 both that copyright notice and this permission notice appear in
36 supporting documentation, and that the name of Digital not be
37 used in advertising or publicity pertaining to distribution of the
38 software without specific, written prior permission.
40 DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
41 ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
42 DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
43 ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
44 WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
45 ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
48 ******************************************************************/
49 /* Monochrome Frame Buffer definitions
50 written by drewry, september 1986
57 #include "regionstr.h"
61 extern int afbInverseAlu
[];
62 extern int afbScreenPrivateIndex
;
63 /* warning: PixelType definition duplicated in maskbits.h */
65 #define PixelType CARD32
66 #endif /* PixelType */
68 #define AFB_MAX_DEPTH 8
72 extern void afbDoBitblt(
76 RegionPtr
/*prgnDst*/,
77 DDXPointPtr
/*pptSrc*/,
78 unsigned long /*planemask*/
81 extern RegionPtr
afbCopyArea(
82 DrawablePtr
/*pSrcDrawable*/,
83 DrawablePtr
/*pDstDrawable*/,
95 extern void afbDoBitbltCopy(
99 RegionPtr
/*prgnDst*/,
100 DDXPointPtr
/*pptSrc*/,
101 unsigned long /*planemask*/
105 extern void afbDoBitbltCopyInverted(
106 DrawablePtr
/*pSrc*/,
107 DrawablePtr
/*pDst*/,
109 RegionPtr
/*prgnDst*/,
110 DDXPointPtr
/*pptSrc*/,
111 unsigned long /*planemask*/
115 extern void afbDoBitbltGeneral(
116 DrawablePtr
/*pSrc*/,
117 DrawablePtr
/*pDst*/,
119 RegionPtr
/*prgnDst*/,
120 DDXPointPtr
/*pptSrc*/,
121 unsigned long /*planemask*/
125 extern void afbDoBitbltOr(
126 DrawablePtr
/*pSrc*/,
127 DrawablePtr
/*pDst*/,
129 RegionPtr
/*prgnDst*/,
130 DDXPointPtr
/*pptSrc*/,
131 unsigned long /*planemask*/
135 extern void afbDoBitbltXor(
136 DrawablePtr
/*pSrc*/,
137 DrawablePtr
/*pDst*/,
139 RegionPtr
/*prgnDst*/,
140 DDXPointPtr
/*pptSrc*/,
141 unsigned long /*planemask*/
145 extern void afbBresS(
146 PixelType
* /*addrl*/,
159 unsigned char * /*rrops*/
163 extern void afbBresD(
164 int * /*pdashIndex*/,
165 unsigned char * /*pDash*/,
166 int /*numInDashList*/,
167 int * /*pdashOffset*/,
168 int /*isDoubleDash*/,
169 PixelType
* /*addrl*/,
182 unsigned char * /*rrops*/,
183 unsigned char * /*bgrrops*/
187 extern void afbSaveAreas(
188 PixmapPtr
/*pPixmap*/,
189 RegionPtr
/*prgnSave*/,
195 extern void afbRestoreAreas(
196 PixmapPtr
/*pPixmap*/,
197 RegionPtr
/*prgnRestore*/,
204 extern RegionPtr
afbPixmapToRegion(
210 extern int afbListInstalledColormaps(
211 ScreenPtr
/*pScreen*/,
215 extern void afbInstallColormap(
219 extern void afbUninstallColormap(
223 extern void afbResolveColor(
224 unsigned short * /*pred*/,
225 unsigned short * /*pgreen*/,
226 unsigned short * /*pblue*/,
227 VisualPtr
/*pVisual*/
230 extern Bool
afbInitializeColormap(
234 extern Bool
afbInitVisuals(
235 VisualPtr
* /*visualp*/,
236 DepthPtr
* /*depthp*/,
239 int * /*rootDepthp*/,
240 VisualID
* /*defaultVisp*/,
241 unsigned long /*sizes*/,
247 extern void afbPolyFillArcSolid(
248 DrawablePtr
/*pDraw*/,
255 extern void afbPolyFillRect(
256 DrawablePtr
/*pDrawable*/,
259 xRectangle
* /*prectInit*/
263 extern void afbFillPolygonSolid(
264 DrawablePtr
/*pDrawable*/,
269 DDXPointPtr
/*ptsIn*/
274 extern void afbSolidFS(
275 DrawablePtr
/*pDrawable*/,
278 DDXPointPtr
/*pptInit*/,
279 int * /*pwidthInit*/,
283 extern void afbStippleFS(
284 DrawablePtr
/*pDrawable*/,
287 DDXPointPtr
/*pptInit*/,
288 int * /*pwidthInit*/,
292 extern void afbTileFS(
293 DrawablePtr
/*pDrawable*/,
296 DDXPointPtr
/*pptInit*/,
297 int * /*pwidthInit*/,
301 extern void afbUnnaturalTileFS(
302 DrawablePtr
/*pDrawable*/,
305 DDXPointPtr
/*pptInit*/,
306 int * /*pwidthInit*/,
310 extern void afbUnnaturalStippleFS(
311 DrawablePtr
/*pDrawable*/,
314 DDXPointPtr
/*pptInit*/,
315 int * /*pwidthInit*/,
319 extern void afbOpaqueStippleFS(
320 DrawablePtr
/*pDrawable*/,
323 DDXPointPtr
/*pptInit*/,
324 int * /*pwidthInit*/,
328 extern void afbUnnaturalOpaqueStippleFS(
329 DrawablePtr
/*pDrawable*/,
332 DDXPointPtr
/*pptInit*/,
333 int * /*pwidthInit*/,
339 extern Bool
afbRealizeFont(
344 extern Bool
afbUnrealizeFont(
350 extern Bool
afbCreateGC(
354 extern void afbReduceRop(
357 unsigned long /*planemask*/,
359 unsigned char * /*rrops*/
364 extern void afbGetSpans(
365 DrawablePtr
/*pDrawable*/,
374 extern void afbHorzS(
375 PixelType
* /*addrl*/,
382 unsigned char * /*rrops*/
385 extern void afbVertS(
386 PixelType
* /*addrl*/,
393 unsigned char * /*rrops*/
397 extern void afbImageGlyphBlt (
398 DrawablePtr
/*pDrawable*/,
402 unsigned int /*nglyph*/,
403 CharInfoPtr
* /*ppci*/,
404 pointer
/*pglyphBase*/
410 extern void afbPutImage(
423 extern void afbGetImage(
424 DrawablePtr
/*pDrawable*/,
429 unsigned int /*format*/,
430 unsigned long /*planeMask*/,
435 extern void afbLineSS(
436 DrawablePtr
/*pDrawable*/,
440 DDXPointPtr
/*pptInit*/
443 extern void afbLineSD(
444 DrawablePtr
/*pDrawable*/,
448 DDXPointPtr
/*pptInit*/
453 extern void afbQueryBestSize(
455 unsigned short * /*pwidth*/,
456 unsigned short * /*pheight*/,
457 ScreenPtr
/*pScreen*/
461 extern void afbSolidFillArea(
462 DrawablePtr
/*pDraw*/,
465 unsigned char * /*rrops*/
468 extern void afbStippleAreaPPW(
469 DrawablePtr
/*pDraw*/,
472 PixmapPtr
/*pstipple*/,
473 unsigned char * /*rrops*/
475 extern void afbStippleArea(
476 DrawablePtr
/*pDraw*/,
479 PixmapPtr
/*pstipple*/,
482 unsigned char * /*rrops*/
486 extern void afbPolyGlyphBlt(
487 DrawablePtr
/*pDrawable*/,
491 unsigned int /*nglyph*/,
492 CharInfoPtr
* /*ppci*/,
493 pointer
/*pglyphBase*/
498 extern PixmapPtr
afbCreatePixmap(
499 ScreenPtr
/*pScreen*/,
505 extern Bool
afbDestroyPixmap(
506 PixmapPtr
/*pPixmap*/
509 extern void afbXRotatePixmap(
514 extern void afbYRotatePixmap(
519 extern void afbCopyRotatePixmap(
520 PixmapPtr
/*psrcPix*/,
521 PixmapPtr
* /*ppdstPix*/,
525 extern void afbPaintWindow(
527 RegionPtr
/*pRegion*/,
532 extern void afbPolyPoint(
533 DrawablePtr
/*pDrawable*/,
541 extern void afbPushPixels(
543 PixmapPtr
/*pBitMap*/,
544 DrawablePtr
/*pDrawable*/,
553 extern Bool
afbScreenInit(
554 ScreenPtr
/*pScreen*/,
565 extern void afbSegmentSS(
566 DrawablePtr
/*pDrawable*/,
572 extern void afbSegmentSD(
573 DrawablePtr
/*pDrawable*/,
580 extern void afbSetSpans(
581 DrawablePtr
/*pDrawable*/,
591 extern void afbTEGlyphBlt(
592 DrawablePtr
/*pDrawable*/,
596 unsigned int /*nglyph*/,
597 CharInfoPtr
* /*ppci*/,
598 pointer
/*pglyphBase*/
602 extern void afbTileAreaPPWCopy(
603 DrawablePtr
/*pDraw*/,
608 unsigned long /*planemask*/
612 extern void afbTileAreaPPWGeneral(
613 DrawablePtr
/*pDraw*/,
618 unsigned long /*planemask*/
621 extern void afbTileAreaCopy(
622 DrawablePtr
/*pDraw*/,
629 unsigned long /*planemask*/
633 extern void afbTileAreaGeneral(
634 DrawablePtr
/*pDraw*/,
641 unsigned long /*planemask*/
644 extern void afbOpaqueStippleAreaPPWCopy(
645 DrawablePtr
/*pDraw*/,
650 unsigned char */
*rropsOS*/
,
651 unsigned long /*planemask*/
655 extern void afbOpaqueStippleAreaPPWGeneral(
656 DrawablePtr
/*pDraw*/,
661 unsigned char */
*rropsOS*/
,
662 unsigned long /*planemask*/
665 extern void afbOpaqueStippleAreaCopy(
666 DrawablePtr
/*pDraw*/,
673 unsigned char */
*rropsOS*/
,
674 unsigned long /*planemask*/
678 extern void afbOpaqueStippleAreaGeneral(
679 DrawablePtr
/*pDraw*/,
686 unsigned char */
*rropsOS*/
,
687 unsigned long /*planemask*/
692 extern Bool
afbCreateWindow(
696 extern Bool
afbDestroyWindow(
700 extern Bool
afbMapWindow(
701 WindowPtr
/*pWindow*/
704 extern Bool
afbPositionWindow(
710 extern Bool
afbUnmapWindow(
711 WindowPtr
/*pWindow*/
714 extern void afbCopyWindow(
716 DDXPointRec
/*ptOldOrg*/,
717 RegionPtr
/*prgnSrc*/
720 extern Bool
afbChangeWindowAttributes(
722 unsigned long /*mask*/
726 extern void afbZeroPolyArcSS(
727 DrawablePtr
/*pDraw*/,
734 private field of pixmap
735 pixmap.devPrivate = (PixelType *)pointer_to_bits
736 pixmap.devKind = width_of_pixmap_in_bytes
738 private field of screen
739 a pixmap, for which we allocate storage. devPrivate is a pointer to
740 the bits in the hardware framebuffer. note that devKind can be poked to
741 make the code work for framebuffers that are wider than their
742 displayable screen (e.g. the early vsII, which displayed 960 pixels
743 across, but was 1024 in the hardware.)
749 unsigned char rrops
[AFB_MAX_DEPTH
]; /* reduction of rasterop to 1 of 3 */
750 unsigned char rropOS
[AFB_MAX_DEPTH
]; /* rop for opaque stipple */
752 typedef afbPrivGC
*afbPrivGCPtr
;
754 extern int afbGCPrivateIndex
; /* index into GC private array */
755 extern int afbWindowPrivateIndex
; /* index into Window private array */
756 #ifdef PIXMAP_PER_WINDOW
757 extern int frameWindowPrivateIndex
; /* index into Window private array */
760 #define afbGetGCPrivate(pGC) \
761 ((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
763 /* private field of window */
765 unsigned char fastBorder
; /* non-zero if border tile is 32 bits wide */
766 unsigned char fastBackground
;
767 unsigned short unused
; /* pad for alignment with Sun compiler */
768 DDXPointRec oldRotate
;
769 PixmapPtr pRotatedBackground
;
770 PixmapPtr pRotatedBorder
;
773 /* Common macros for extracting drawing information */
775 #define afbGetTypedWidth(pDrawable,wtype)( \
776 (((pDrawable)->type == DRAWABLE_WINDOW) ? \
777 (int)(((PixmapPtr)((pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr))->devKind) : \
778 (int)(((PixmapPtr)pDrawable)->devKind)) / sizeof (wtype))
780 #define afbGetByteWidth(pDrawable) afbGetTypedWidth(pDrawable, unsigned char)
782 #define afbGetPixelWidth(pDrawable) afbGetTypedWidth(pDrawable, PixelType)
784 #define afbGetTypedWidthAndPointer(pDrawable, width, pointer, wtype, ptype) {\
786 if ((pDrawable)->type == DRAWABLE_WINDOW) \
787 _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
789 _pPix = (PixmapPtr)(pDrawable); \
790 (pointer) = (ptype *) _pPix->devPrivate.ptr; \
791 (width) = ((int) _pPix->devKind) / sizeof (wtype); \
794 #define afbGetPixelWidthSizeDepthAndPointer(pDrawable, width, size, dep, pointer) {\
796 if ((pDrawable)->type == DRAWABLE_WINDOW) \
797 _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
799 _pPix = (PixmapPtr)(pDrawable); \
800 (pointer) = (PixelType *)_pPix->devPrivate.ptr; \
801 (width) = ((int)_pPix->devKind) / sizeof (PixelType); \
802 (size) = (width) * _pPix->drawable.height; \
803 (dep) = _pPix->drawable.depth; (void)(dep); \
806 #define afbGetByteWidthAndPointer(pDrawable, width, pointer) \
807 afbGetTypedWidthAndPointer(pDrawable, width, pointer, unsigned char, unsigned char)
809 #define afbGetPixelWidthAndPointer(pDrawable, width, pointer) \
810 afbGetTypedWidthAndPointer(pDrawable, width, pointer, PixelType, PixelType)
812 #define afbGetWindowTypedWidthAndPointer(pWin, width, pointer, wtype, ptype) {\
813 PixmapPtr _pPix = (PixmapPtr)(pWin)->drawable.pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
814 (pointer) = (ptype *) _pPix->devPrivate.ptr; \
815 (width) = ((int) _pPix->devKind) / sizeof (wtype); \
818 #define afbGetWindowPixelWidthAndPointer(pWin, width, pointer) \
819 afbGetWindowTypedWidthAndPointer(pWin, width, pointer, PixelType, PixelType)
821 #define afbGetWindowByteWidthAndPointer(pWin, width, pointer) \
822 afbGetWindowTypedWidthAndPointer(pWin, width, pointer, char, char)
824 /* afb uses the following macros to calculate addresses in drawables.
825 * To support banked framebuffers, the macros come in four flavors.
826 * All four collapse into the same definition on unbanked devices.
828 * afbScanlineFoo - calculate address and do bank switching
829 * afbScanlineFooNoBankSwitch - calculate address, don't bank switch
830 * afbScanlineFooSrc - calculate address, switch source bank
831 * afbScanlineFooDst - calculate address, switch destination bank
834 /* The NoBankSwitch versions are the same for banked and unbanked cases */
836 #define afbScanlineIncNoBankSwitch(_ptr, _off) _ptr += (_off)
837 #define afbScanlineOffsetNoBankSwitch(_ptr, _off) ((_ptr) + (_off))
838 #define afbScanlineDeltaNoBankSwitch(_ptr, _y, _w) \
839 afbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w))
840 #define afbScanlineNoBankSwitch(_ptr, _x, _y, _w) \
841 afbScanlineOffsetNoBankSwitch(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
845 #include "afblinebank.h" /* get macro definitions from this file */
847 #else /* !MFB_LINE_BANK - unbanked case */
849 #define afbScanlineInc(_ptr, _off) afbScanlineIncNoBankSwitch(_ptr, _off)
850 #define afbScanlineIncSrc(_ptr, _off) afbScanlineInc(_ptr, _off)
851 #define afbScanlineIncDst(_ptr, _off) afbScanlineInc(_ptr, _off)
853 #define afbScanlineOffset(_ptr, _off) afbScanlineOffsetNoBankSwitch(_ptr, _off)
854 #define afbScanlineOffsetSrc(_ptr, _off) afbScanlineOffset(_ptr, _off)
855 #define afbScanlineOffsetDst(_ptr, _off) afbScanlineOffset(_ptr, _off)
857 #define afbScanlineSrc(_ptr, _x, _y, _w) afbScanline(_ptr, _x, _y, _w)
858 #define afbScanlineDst(_ptr, _x, _y, _w) afbScanline(_ptr, _x, _y, _w)
860 #define afbScanlineDeltaSrc(_ptr, _y, _w) afbScanlineDelta(_ptr, _y, _w)
861 #define afbScanlineDeltaDst(_ptr, _y, _w) afbScanlineDelta(_ptr, _y, _w)
863 #endif /* MFB_LINE_BANK */
865 #define afbScanlineDelta(_ptr, _y, _w) \
866 afbScanlineOffset(_ptr, (_y) * (_w))
868 #define afbScanline(_ptr, _x, _y, _w) \
869 afbScanlineOffset(_ptr, (_y) * (_w) + ((_x) >> MFB_PWSH))
871 /* precomputed information about each glyph for GlyphBlt code.
872 this saves recalculating the per glyph information for each box.
875 typedef struct _afbpos
{
876 int xpos
; /* xposition of glyph's origin */
877 int xchar
; /* x position mod 32 */
882 PixelType
*pdstBase
; /* longword with character origin */
883 int widthGlyph
; /* width in bytes of this glyph */
886 /* reduced raster ops for afb */
887 #define RROP_BLACK GXclear
888 #define RROP_WHITE GXset
889 #define RROP_NOP GXnoop
890 #define RROP_INVERT GXinvert
891 #define RROP_COPY GXcopy
893 /* macros for afbbitblt.c, afbfillsp.c
894 these let the code do one switch on the rop per call, rather
895 than a switch on the rop per item (span or rectangle.)
898 #define fnCLEAR(src, dst) (0)
899 #define fnAND(src, dst) (src & dst)
900 #define fnANDREVERSE(src, dst) (src & ~dst)
901 #define fnCOPY(src, dst) (src)
902 #define fnANDINVERTED(src, dst) (~src & dst)
903 #define fnNOOP(src, dst) (dst)
904 #define fnXOR(src, dst) (src ^ dst)
905 #define fnOR(src, dst) (src | dst)
906 #define fnNOR(src, dst) (~(src | dst))
907 #define fnEQUIV(src, dst) (~src ^ dst)
908 #define fnINVERT(src, dst) (~dst)
909 #define fnORREVERSE(src, dst) (src | ~dst)
910 #define fnCOPYINVERTED(src, dst) (~src)
911 #define fnORINVERTED(src, dst) (~src | dst)
912 #define fnNAND(src, dst) (~(src & dst))
914 #define fnSET(src, dst) (~0)
916 /* Using a "switch" statement is much faster in most cases
917 * since the compiler can do a look-up table or multi-way branch
918 * instruction, depending on the architecture. The result on
919 * A Sun 3/50 is at least 2.5 times faster, assuming a uniform
920 * distribution of RasterOp operation types.
922 * However, doing some profiling on a running system reveals
923 * GXcopy is the operation over 99.5% of the time and
924 * GXxor is the next most frequent (about .4%), so we make special
925 * checks for those first.
927 * Note that this requires a change to the "calling sequence"
928 * since we can't engineer a "switch" statement to have an lvalue.
931 #define DoRop(result, alu, src, dst) \
934 result = fnCOPY (src, dst); \
935 else if (alu == GXxor) \
936 result = fnXOR (src, dst); \
940 result = fnCLEAR (src, dst); \
943 result = fnAND (src, dst); \
946 result = fnANDREVERSE (src, dst); \
948 case GXandInverted: \
949 result = fnANDINVERTED (src, dst); \
953 result = fnNOOP (src, dst); \
956 result = fnOR (src, dst); \
959 result = fnNOR (src, dst); \
962 result = fnEQUIV (src, dst); \
965 result = fnINVERT (src, dst); \
968 result = fnORREVERSE (src, dst); \
970 case GXcopyInverted: \
971 result = fnCOPYINVERTED (src, dst); \
974 result = fnORINVERTED (src, dst); \
977 result = fnNAND (src, dst); \
980 result = fnSET (src, dst); \
986 /* C expression fragments for various operations. These get passed in
987 * as -D's on the compile command line. See afb/Imakefile. This
990 * This seems like a good place to point out that afb's use of the
991 * words black and white is an unfortunate misnomer. In afb code, black
992 * means zero, and white means one.
994 #define MFB_OPEQ_WHITE |=
995 #define MFB_OPEQ_BLACK &=~
996 #define MFB_OPEQ_INVERT ^=
997 #define MFB_EQWHOLEWORD_WHITE =~0
998 #define MFB_EQWHOLEWORD_BLACK =0
999 #define MFB_EQWHOLEWORD_INVERT ^=~0
1000 #define MFB_OP_WHITE /* nothing */
1001 #define MFB_OP_BLACK ~