Initial commit
[xorg_rtime.git] / xorg-server-1.4 / afb / afb.h
blob5aa2b0c92d187b267bd0b04e79657be89e898d34
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.
30 All Rights Reserved
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
46 SOFTWARE.
48 ******************************************************************/
49 /* Monochrome Frame Buffer definitions
50 written by drewry, september 1986
53 #include "pixmap.h"
54 #include "region.h"
55 #include "gc.h"
56 #include "colormap.h"
57 #include "regionstr.h"
58 #include "mibstore.h"
59 #include "mfb.h"
61 extern int afbInverseAlu[];
62 extern int afbScreenPrivateIndex;
63 /* warning: PixelType definition duplicated in maskbits.h */
64 #ifndef PixelType
65 #define PixelType CARD32
66 #endif /* PixelType */
68 #define AFB_MAX_DEPTH 8
70 /* afbbitblt.c */
72 extern void afbDoBitblt(
73 DrawablePtr /*pSrc*/,
74 DrawablePtr /*pDst*/,
75 int /*alu*/,
76 RegionPtr /*prgnDst*/,
77 DDXPointPtr /*pptSrc*/,
78 unsigned long /*planemask*/
81 extern 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*/
93 /* afbbltC.c */
95 extern void afbDoBitbltCopy(
96 DrawablePtr /*pSrc*/,
97 DrawablePtr /*pDst*/,
98 int /*alu*/,
99 RegionPtr /*prgnDst*/,
100 DDXPointPtr /*pptSrc*/,
101 unsigned long /*planemask*/
103 /* afbbltCI.c */
105 extern void afbDoBitbltCopyInverted(
106 DrawablePtr /*pSrc*/,
107 DrawablePtr /*pDst*/,
108 int /*alu*/,
109 RegionPtr /*prgnDst*/,
110 DDXPointPtr /*pptSrc*/,
111 unsigned long /*planemask*/
113 /* afbbltG.c */
115 extern void afbDoBitbltGeneral(
116 DrawablePtr /*pSrc*/,
117 DrawablePtr /*pDst*/,
118 int /*alu*/,
119 RegionPtr /*prgnDst*/,
120 DDXPointPtr /*pptSrc*/,
121 unsigned long /*planemask*/
123 /* afbbltO.c */
125 extern void afbDoBitbltOr(
126 DrawablePtr /*pSrc*/,
127 DrawablePtr /*pDst*/,
128 int /*alu*/,
129 RegionPtr /*prgnDst*/,
130 DDXPointPtr /*pptSrc*/,
131 unsigned long /*planemask*/
133 /* afbbltX.c */
135 extern void afbDoBitbltXor(
136 DrawablePtr /*pSrc*/,
137 DrawablePtr /*pDst*/,
138 int /*alu*/,
139 RegionPtr /*prgnDst*/,
140 DDXPointPtr /*pptSrc*/,
141 unsigned long /*planemask*/
143 /* afbbres.c */
145 extern 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*/
161 /* afbbresd.c */
163 extern 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*/
185 /* afbbstore.c */
187 extern void afbSaveAreas(
188 PixmapPtr /*pPixmap*/,
189 RegionPtr /*prgnSave*/,
190 int /*xorg*/,
191 int /*yorg*/,
192 WindowPtr /*pWin*/
195 extern void afbRestoreAreas(
196 PixmapPtr /*pPixmap*/,
197 RegionPtr /*prgnRestore*/,
198 int /*xorg*/,
199 int /*yorg*/,
200 WindowPtr /*pWin*/
202 /* afbclip.c */
204 extern RegionPtr afbPixmapToRegion(
205 PixmapPtr /*pPix*/
208 /* afbcmap.c */
210 extern int afbListInstalledColormaps(
211 ScreenPtr /*pScreen*/,
212 Colormap * /*pmaps*/
215 extern void afbInstallColormap(
216 ColormapPtr /*pmap*/
219 extern void afbUninstallColormap(
220 ColormapPtr /*pmap*/
223 extern void afbResolveColor(
224 unsigned short * /*pred*/,
225 unsigned short * /*pgreen*/,
226 unsigned short * /*pblue*/,
227 VisualPtr /*pVisual*/
230 extern Bool afbInitializeColormap(
231 ColormapPtr /*pmap*/
234 extern Bool afbInitVisuals(
235 VisualPtr * /*visualp*/,
236 DepthPtr * /*depthp*/,
237 int * /*nvisualp*/,
238 int * /*ndepthp*/,
239 int * /*rootDepthp*/,
240 VisualID * /*defaultVisp*/,
241 unsigned long /*sizes*/,
242 int /*bitsPerRGB*/
245 /* afbfillarc.c */
247 extern void afbPolyFillArcSolid(
248 DrawablePtr /*pDraw*/,
249 GCPtr /*pGC*/,
250 int /*narcs*/,
251 xArc * /*parcs*/
253 /* afbfillrct.c */
255 extern void afbPolyFillRect(
256 DrawablePtr /*pDrawable*/,
257 GCPtr /*pGC*/,
258 int /*nrectFill*/,
259 xRectangle * /*prectInit*/
262 /* afbply1rct.c */
263 extern void afbFillPolygonSolid(
264 DrawablePtr /*pDrawable*/,
265 GCPtr /*pGC*/,
266 int /*mode*/,
267 int /*shape*/,
268 int /*count*/,
269 DDXPointPtr /*ptsIn*/
272 /* afbfillsp.c */
274 extern void afbSolidFS(
275 DrawablePtr /*pDrawable*/,
276 GCPtr /*pGC*/,
277 int /*nInit*/,
278 DDXPointPtr /*pptInit*/,
279 int * /*pwidthInit*/,
280 int /*fSorted*/
283 extern void afbStippleFS(
284 DrawablePtr /*pDrawable*/,
285 GCPtr/*pGC*/,
286 int /*nInit*/,
287 DDXPointPtr /*pptInit*/,
288 int * /*pwidthInit*/,
289 int /*fSorted*/
292 extern void afbTileFS(
293 DrawablePtr /*pDrawable*/,
294 GCPtr/*pGC*/,
295 int /*nInit*/,
296 DDXPointPtr /*pptInit*/,
297 int * /*pwidthInit*/,
298 int /*fSorted*/
301 extern void afbUnnaturalTileFS(
302 DrawablePtr /*pDrawable*/,
303 GCPtr/*pGC*/,
304 int /*nInit*/,
305 DDXPointPtr /*pptInit*/,
306 int * /*pwidthInit*/,
307 int /*fSorted*/
310 extern void afbUnnaturalStippleFS(
311 DrawablePtr /*pDrawable*/,
312 GCPtr/*pGC*/,
313 int /*nInit*/,
314 DDXPointPtr /*pptInit*/,
315 int * /*pwidthInit*/,
316 int /*fSorted*/
319 extern void afbOpaqueStippleFS(
320 DrawablePtr /*pDrawable*/,
321 GCPtr/*pGC*/,
322 int /*nInit*/,
323 DDXPointPtr /*pptInit*/,
324 int * /*pwidthInit*/,
325 int /*fSorted*/
328 extern void afbUnnaturalOpaqueStippleFS(
329 DrawablePtr /*pDrawable*/,
330 GCPtr/*pGC*/,
331 int /*nInit*/,
332 DDXPointPtr /*pptInit*/,
333 int * /*pwidthInit*/,
334 int /*fSorted*/
337 /* afbfont.c */
339 extern Bool afbRealizeFont(
340 ScreenPtr /*pscr*/,
341 FontPtr /*pFont*/
344 extern Bool afbUnrealizeFont(
345 ScreenPtr /*pscr*/,
346 FontPtr /*pFont*/
348 /* afbgc.c */
350 extern Bool afbCreateGC(
351 GCPtr /*pGC*/
354 extern void afbReduceRop(
355 int /*alu*/,
356 Pixel /*src*/,
357 unsigned long /*planemask*/,
358 int /*depth*/,
359 unsigned char * /*rrops*/
362 /* afbgetsp.c */
364 extern void afbGetSpans(
365 DrawablePtr /*pDrawable*/,
366 int /*wMax*/,
367 DDXPointPtr /*ppt*/,
368 int * /*pwidth*/,
369 int /*nspans*/,
370 char * /*pdstStart*/
372 /* afbhrzvert.c */
374 extern void afbHorzS(
375 PixelType * /*addrl*/,
376 int /*nlwidth*/,
377 int /*sizeDst*/,
378 int /*depthDst*/,
379 int /*x1*/,
380 int /*y1*/,
381 int /*len*/,
382 unsigned char * /*rrops*/
385 extern void afbVertS(
386 PixelType * /*addrl*/,
387 int /*nlwidth*/,
388 int /*sizeDst*/,
389 int /*depthDst*/,
390 int /*x1*/,
391 int /*y1*/,
392 int /*len*/,
393 unsigned char * /*rrops*/
395 /* afbigbblak.c */
397 extern void afbImageGlyphBlt (
398 DrawablePtr /*pDrawable*/,
399 GCPtr/*pGC*/,
400 int /*x*/,
401 int /*y*/,
402 unsigned int /*nglyph*/,
403 CharInfoPtr * /*ppci*/,
404 pointer /*pglyphBase*/
406 /* afbigbwht.c */
408 /* afbimage.c */
410 extern void afbPutImage(
411 DrawablePtr /*dst*/,
412 GCPtr /*pGC*/,
413 int /*depth*/,
414 int /*x*/,
415 int /*y*/,
416 int /*w*/,
417 int /*h*/,
418 int /*leftPad*/,
419 int /*format*/,
420 char * /*pImage*/
423 extern void afbGetImage(
424 DrawablePtr /*pDrawable*/,
425 int /*sx*/,
426 int /*sy*/,
427 int /*w*/,
428 int /*h*/,
429 unsigned int /*format*/,
430 unsigned long /*planeMask*/,
431 char * /*pdstLine*/
433 /* afbline.c */
435 extern void afbLineSS(
436 DrawablePtr /*pDrawable*/,
437 GCPtr /*pGC*/,
438 int /*mode*/,
439 int /*npt*/,
440 DDXPointPtr /*pptInit*/
443 extern void afbLineSD(
444 DrawablePtr /*pDrawable*/,
445 GCPtr /*pGC*/,
446 int /*mode*/,
447 int /*npt*/,
448 DDXPointPtr /*pptInit*/
451 /* afbmisc.c */
453 extern void afbQueryBestSize(
454 int /*class*/,
455 unsigned short * /*pwidth*/,
456 unsigned short * /*pheight*/,
457 ScreenPtr /*pScreen*/
459 /* afbpntarea.c */
461 extern void afbSolidFillArea(
462 DrawablePtr /*pDraw*/,
463 int /*nbox*/,
464 BoxPtr /*pbox*/,
465 unsigned char * /*rrops*/
468 extern void afbStippleAreaPPW(
469 DrawablePtr /*pDraw*/,
470 int /*nbox*/,
471 BoxPtr /*pbox*/,
472 PixmapPtr /*pstipple*/,
473 unsigned char * /*rrops*/
475 extern void afbStippleArea(
476 DrawablePtr /*pDraw*/,
477 int /*nbox*/,
478 BoxPtr /*pbox*/,
479 PixmapPtr /*pstipple*/,
480 int /*xOff*/,
481 int /*yOff*/,
482 unsigned char * /*rrops*/
484 /* afbplygblt.c */
486 extern void afbPolyGlyphBlt(
487 DrawablePtr /*pDrawable*/,
488 GCPtr /*pGC*/,
489 int /*x*/,
490 int /*y*/,
491 unsigned int /*nglyph*/,
492 CharInfoPtr * /*ppci*/,
493 pointer /*pglyphBase*/
496 /* afbpixmap.c */
498 extern PixmapPtr afbCreatePixmap(
499 ScreenPtr /*pScreen*/,
500 int /*width*/,
501 int /*height*/,
502 int /*depth*/
505 extern Bool afbDestroyPixmap(
506 PixmapPtr /*pPixmap*/
509 extern void afbXRotatePixmap(
510 PixmapPtr /*pPix*/,
511 int /*rw*/
514 extern void afbYRotatePixmap(
515 PixmapPtr /*pPix*/,
516 int /*rh*/
519 extern void afbCopyRotatePixmap(
520 PixmapPtr /*psrcPix*/,
521 PixmapPtr * /*ppdstPix*/,
522 int /*xrot*/,
523 int /*yrot*/
525 extern void afbPaintWindow(
526 WindowPtr /*pWin*/,
527 RegionPtr /*pRegion*/,
528 int /*what*/
530 /* afbpolypnt.c */
532 extern void afbPolyPoint(
533 DrawablePtr /*pDrawable*/,
534 GCPtr /*pGC*/,
535 int /*mode*/,
536 int /*npt*/,
537 xPoint * /*pptInit*/
539 /* afbpushpxl.c */
541 extern void afbPushPixels(
542 GCPtr /*pGC*/,
543 PixmapPtr /*pBitMap*/,
544 DrawablePtr /*pDrawable*/,
545 int /*dx*/,
546 int /*dy*/,
547 int /*xOrg*/,
548 int /*yOrg*/
551 /* afbscrinit.c */
553 extern Bool afbScreenInit(
554 ScreenPtr /*pScreen*/,
555 pointer /*pbits*/,
556 int /*xsize*/,
557 int /*ysize*/,
558 int /*dpix*/,
559 int /*dpiy*/,
560 int /*width*/
563 /* afbseg.c */
565 extern void afbSegmentSS(
566 DrawablePtr /*pDrawable*/,
567 GCPtr /*pGC*/,
568 int /*nseg*/,
569 xSegment * /*pSeg*/
572 extern void afbSegmentSD(
573 DrawablePtr /*pDrawable*/,
574 GCPtr /*pGC*/,
575 int /*nseg*/,
576 xSegment * /*pSeg*/
578 /* afbsetsp.c */
580 extern void afbSetSpans(
581 DrawablePtr /*pDrawable*/,
582 GCPtr /*pGC*/,
583 char * /*psrc*/,
584 DDXPointPtr /*ppt*/,
585 int * /*pwidth*/,
586 int /*nspans*/,
587 int /*fSorted*/
589 /* afbtegblt.c */
591 extern void afbTEGlyphBlt(
592 DrawablePtr /*pDrawable*/,
593 GCPtr/*pGC*/,
594 int /*x*/,
595 int /*y*/,
596 unsigned int /*nglyph*/,
597 CharInfoPtr * /*ppci*/,
598 pointer /*pglyphBase*/
600 /* afbtileC.c */
602 extern void afbTileAreaPPWCopy(
603 DrawablePtr /*pDraw*/,
604 int /*nbox*/,
605 BoxPtr /*pbox*/,
606 int /*alu*/,
607 PixmapPtr /*ptile*/,
608 unsigned long /*planemask*/
610 /* afbtileG.c */
612 extern void afbTileAreaPPWGeneral(
613 DrawablePtr /*pDraw*/,
614 int /*nbox*/,
615 BoxPtr /*pbox*/,
616 int /*alu*/,
617 PixmapPtr /*ptile*/,
618 unsigned long /*planemask*/
621 extern void afbTileAreaCopy(
622 DrawablePtr /*pDraw*/,
623 int /*nbox*/,
624 BoxPtr /*pbox*/,
625 int /*alu*/,
626 PixmapPtr /*ptile*/,
627 int /*xOff*/,
628 int /*yOff*/,
629 unsigned long /*planemask*/
631 /* afbtileG.c */
633 extern void afbTileAreaGeneral(
634 DrawablePtr /*pDraw*/,
635 int /*nbox*/,
636 BoxPtr /*pbox*/,
637 int /*alu*/,
638 PixmapPtr /*ptile*/,
639 int /*xOff*/,
640 int /*yOff*/,
641 unsigned long /*planemask*/
644 extern void afbOpaqueStippleAreaPPWCopy(
645 DrawablePtr /*pDraw*/,
646 int /*nbox*/,
647 BoxPtr /*pbox*/,
648 int /*alu*/,
649 PixmapPtr /*ptile*/,
650 unsigned char */*rropsOS*/,
651 unsigned long /*planemask*/
653 /* afbtileG.c */
655 extern void afbOpaqueStippleAreaPPWGeneral(
656 DrawablePtr /*pDraw*/,
657 int /*nbox*/,
658 BoxPtr /*pbox*/,
659 int /*alu*/,
660 PixmapPtr /*ptile*/,
661 unsigned char */*rropsOS*/,
662 unsigned long /*planemask*/
665 extern void afbOpaqueStippleAreaCopy(
666 DrawablePtr /*pDraw*/,
667 int /*nbox*/,
668 BoxPtr /*pbox*/,
669 int /*alu*/,
670 PixmapPtr /*ptile*/,
671 int /*xOff*/,
672 int /*yOff*/,
673 unsigned char */*rropsOS*/,
674 unsigned long /*planemask*/
676 /* afbtileG.c */
678 extern void afbOpaqueStippleAreaGeneral(
679 DrawablePtr /*pDraw*/,
680 int /*nbox*/,
681 BoxPtr /*pbox*/,
682 int /*alu*/,
683 PixmapPtr /*ptile*/,
684 int /*xOff*/,
685 int /*yOff*/,
686 unsigned char */*rropsOS*/,
687 unsigned long /*planemask*/
690 /* afbwindow.c */
692 extern Bool afbCreateWindow(
693 WindowPtr /*pWin*/
696 extern Bool afbDestroyWindow(
697 WindowPtr /*pWin*/
700 extern Bool afbMapWindow(
701 WindowPtr /*pWindow*/
704 extern Bool afbPositionWindow(
705 WindowPtr /*pWin*/,
706 int /*x*/,
707 int /*y*/
710 extern Bool afbUnmapWindow(
711 WindowPtr /*pWindow*/
714 extern void afbCopyWindow(
715 WindowPtr /*pWin*/,
716 DDXPointRec /*ptOldOrg*/,
717 RegionPtr /*prgnSrc*/
720 extern Bool afbChangeWindowAttributes(
721 WindowPtr /*pWin*/,
722 unsigned long /*mask*/
724 /* afbzerarc.c */
726 extern void afbZeroPolyArcSS(
727 DrawablePtr /*pDraw*/,
728 GCPtr /*pGC*/,
729 int /*narcs*/,
730 xArc * /*parcs*/
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.)
745 private field of GC
748 typedef struct {
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 */
751 } afbPrivGC;
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 */
758 #endif
760 #define afbGetGCPrivate(pGC) \
761 ((afbPrivGC *)((pGC)->devPrivates[afbGCPrivateIndex].ptr))
763 /* private field of window */
764 typedef struct {
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;
771 } afbPrivWin;
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) {\
785 PixmapPtr _pPix; \
786 if ((pDrawable)->type == DRAWABLE_WINDOW) \
787 _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
788 else \
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) {\
795 PixmapPtr _pPix; \
796 if ((pDrawable)->type == DRAWABLE_WINDOW) \
797 _pPix = (PixmapPtr)(pDrawable)->pScreen->devPrivates[afbScreenPrivateIndex].ptr; \
798 else \
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))
843 #ifdef MFB_LINE_BANK
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 */
878 int leftEdge;
879 int rightEdge;
880 int topEdge;
881 int bottomEdge;
882 PixelType *pdstBase; /* longword with character origin */
883 int widthGlyph; /* width in bytes of this glyph */
884 } afbTEXTPOS;
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))
913 #undef fnSET
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.
930 #undef DoRop
931 #define DoRop(result, alu, src, dst) \
933 if (alu == GXcopy) \
934 result = fnCOPY (src, dst); \
935 else if (alu == GXxor) \
936 result = fnXOR (src, dst); \
937 else \
938 switch (alu) { \
939 case GXclear: \
940 result = fnCLEAR (src, dst); \
941 break; \
942 case GXand: \
943 result = fnAND (src, dst); \
944 break; \
945 case GXandReverse: \
946 result = fnANDREVERSE (src, dst); \
947 break; \
948 case GXandInverted: \
949 result = fnANDINVERTED (src, dst); \
950 break; \
951 default: \
952 case GXnoop: \
953 result = fnNOOP (src, dst); \
954 break; \
955 case GXor: \
956 result = fnOR (src, dst); \
957 break; \
958 case GXnor: \
959 result = fnNOR (src, dst); \
960 break; \
961 case GXequiv: \
962 result = fnEQUIV (src, dst); \
963 break; \
964 case GXinvert: \
965 result = fnINVERT (src, dst); \
966 break; \
967 case GXorReverse: \
968 result = fnORREVERSE (src, dst); \
969 break; \
970 case GXcopyInverted: \
971 result = fnCOPYINVERTED (src, dst); \
972 break; \
973 case GXorInverted: \
974 result = fnORINVERTED (src, dst); \
975 break; \
976 case GXnand: \
977 result = fnNAND (src, dst); \
978 break; \
979 case GXset: \
980 result = fnSET (src, dst); \
981 break; \
986 /* C expression fragments for various operations. These get passed in
987 * as -D's on the compile command line. See afb/Imakefile. This
988 * fixes XBUG 6319.
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 ~