📄 mfbfillsp.c
字号:
/* Combined Purdue/PurduePlus patches, level 2.0, 1/17/89 *//***********************************************************Copyright (c) 1987 X ConsortiumPermission is hereby granted, free of charge, to any person obtaining a copyof this software and associated documentation files (the "Software"), to dealin the Software without restriction, including without limitation the rightsto use, copy, modify, merge, publish, distribute, sublicense, and/or sellcopies of the Software, and to permit persons to whom the Software isfurnished to do so, subject to the following conditions:The above copyright notice and this permission notice shall be included inall copies or substantial portions of the Software.THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS ORIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THEX CONSORTIUM BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER INAN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR INCONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.Except as contained in this notice, the name of the X Consortium shall not beused in advertising or otherwise to promote the sale, use or other dealingsin this Software without prior written authorization from the X Consortium.Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts. All Rights ReservedPermission to use, copy, modify, and distribute this software and its documentation for any purpose and without fee is hereby granted, provided that the above copyright notice appear in all copies and thatboth that copyright notice and this permission notice appear in supporting documentation, and that the name of Digital not beused in advertising or publicity pertaining to distribution of thesoftware without specific, written prior permission. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDINGALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALLDIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES ORANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THISSOFTWARE.******************************************************************//* $XConsortium: mfbfillsp.c,v 5.13 94/04/17 20:28:21 dpw Exp $ */#include "X.h"#include "Xmd.h"#include "gcstruct.h"#include "window.h"#include "pixmapstr.h"#include "scrnintstr.h"#include "windowstr.h"#include "mfb.h"#include "maskbits.h"#include "mergerop.h"#include "servermd.h"#include "mi.h"#include "mispans.h"/* scanline filling for monochrome frame buffer written by drewry, oct 1986 these routines all clip. they assume that anything that has calledthem has already translated the points (i.e. pGC->miTranslate isnon-zero, which is howit gets set in mfbCreateGC().) the number of new scnalines created by clipping ==MaxRectsPerBand * nSpans. FillSolid is overloaded to be used for OpaqueStipple as well,if fgPixel == bgPixel. FillTiled is overloaded to be used for OpaqueStipple, iffgPixel != bgPixel. based on the fill style, it uses{RotatedPixmap, gc.alu} or {RotatedPixmap, PrivGC.ropOpStip}*/voidmfbBlackSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GCPtr pGC; int nInit; /* number of spans to fill */ DDXPointPtr pptInit; /* pointer to list of start points */ int *pwidthInit; /* pointer to list of n widths */ int fSorted;{ /* next three parameters are post-clip */ int n; /* number of spans to fill */ register DDXPointPtr ppt; /* pointer to list of start points */ register int *pwidth; /* pointer to list of n widths */ PixelType *addrlBase; /* pointer to start of bitmap */ int nlwidth; /* width in longwords of bitmap */ register PixelType *addrl;/* pointer to current longword in bitmap */ register int nlmiddle; register PixelType startmask; register PixelType endmask; int *pwidthFree; /* copies of the pointers to free */ DDXPointPtr pptFree; if (!(pGC->planemask & 1)) return; n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip); pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); if(!pptFree || !pwidthFree) { if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); return; } pwidth = pwidthFree; ppt = pptFree; n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted); mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase); while (n--) { addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth); if (*pwidth) { if ( ((ppt->x & PIM) + *pwidth) < PPW) { /* all bits inside same longword */ maskpartialbits(ppt->x, *pwidth, startmask); *addrl &= ~startmask; } else { maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle); if (startmask) *addrl++ &= ~startmask; Duff (nlmiddle, *addrl++ = 0x0); if (endmask) *addrl &= ~endmask; } } pwidth++; ppt++; } DEALLOCATE_LOCAL(pptFree); DEALLOCATE_LOCAL(pwidthFree);}voidmfbWhiteSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GCPtr pGC; int nInit; /* number of spans to fill */ DDXPointPtr pptInit; /* pointer to list of start points */ int *pwidthInit; /* pointer to list of n widths */ int fSorted;{ /* next three parameters are post-clip */ int n; /* number of spans to fill */ register DDXPointPtr ppt; /* pointer to list of start points */ register int *pwidth; /* pointer to list of n widths */ PixelType *addrlBase; /* pointer to start of bitmap */ int nlwidth; /* width in longwords of bitmap */ register PixelType *addrl;/* pointer to current longword in bitmap */ register int nlmiddle; register PixelType startmask; register PixelType endmask; int *pwidthFree; /* copies of the pointers to free */ DDXPointPtr pptFree; if (!(pGC->planemask & 1)) return; n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip); pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); if(!pptFree || !pwidthFree) { if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); return; } pwidth = pwidthFree; ppt = pptFree; n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted); mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase); while (n--) { addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth); if (*pwidth) { if ( ((ppt->x & PIM) + *pwidth) < PPW) { /* all bits inside same longword */ maskpartialbits(ppt->x, *pwidth, startmask); *addrl |= startmask; } else { maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle); if (startmask) *addrl++ |= startmask; Duff (nlmiddle, *addrl++ = ~0); if (endmask) *addrl |= endmask; } } pwidth++; ppt++; } DEALLOCATE_LOCAL(pptFree); DEALLOCATE_LOCAL(pwidthFree);}voidmfbInvertSolidFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GCPtr pGC; int nInit; /* number of spans to fill */ DDXPointPtr pptInit; /* pointer to list of start points */ int *pwidthInit; /* pointer to list of n widths */ int fSorted;{ /* next three parameters are post-clip */ int n; /* number of spans to fill */ register DDXPointPtr ppt; /* pointer to list of start points */ register int *pwidth; /* pointer to list of n widths */ PixelType *addrlBase; /* pointer to start of bitmap */ int nlwidth; /* width in longwords of bitmap */ register PixelType *addrl;/* pointer to current longword in bitmap */ register int nlmiddle; register PixelType startmask; register PixelType endmask; int *pwidthFree; /* copies of the pointers to free */ DDXPointPtr pptFree; if (!(pGC->planemask & 1)) return; n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip); pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); if(!pptFree || !pwidthFree) { if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); return; } pwidth = pwidthFree; ppt = pptFree; n = miClipSpans(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip, pptInit, pwidthInit, nInit, ppt, pwidth, fSorted); mfbGetPixelWidthAndPointer(pDrawable, nlwidth, addrlBase); while (n--) { addrl = mfbScanline(addrlBase, ppt->x, ppt->y, nlwidth); if (*pwidth) { if ( ((ppt->x & PIM) + *pwidth) < PPW) { /* all bits inside same longword */ maskpartialbits(ppt->x, *pwidth, startmask); *addrl ^= startmask; } else { maskbits(ppt->x, *pwidth, startmask, endmask, nlmiddle); if (startmask) *addrl++ ^= startmask; Duff (nlmiddle, *addrl++ ^= ~0); if (endmask) *addrl ^= endmask; } } pwidth++; ppt++; } DEALLOCATE_LOCAL(pptFree); DEALLOCATE_LOCAL(pwidthFree);}void mfbWhiteStippleFS(pDrawable, pGC, nInit, pptInit, pwidthInit, fSorted) DrawablePtr pDrawable; GC *pGC; int nInit; /* number of spans to fill */ DDXPointPtr pptInit; /* pointer to list of start points */ int *pwidthInit; /* pointer to list of n widths */ int fSorted;{ /* next three parameters are post-clip */ int n; /* number of spans to fill */ register DDXPointPtr ppt; /* pointer to list of start points */ register int *pwidth; /* pointer to list of n widths */ PixelType *addrlBase; /* pointer to start of bitmap */ int nlwidth; /* width in longwords of bitmap */ register PixelType *addrl;/* pointer to current longword in bitmap */ register PixelType src; register int nlmiddle; register PixelType startmask; register PixelType endmask; PixmapPtr pStipple; PixelType *psrc; int tileHeight; int *pwidthFree; /* copies of the pointers to free */ DDXPointPtr pptFree; if (!(pGC->planemask & 1)) return; n = nInit * miFindMaxBand(((mfbPrivGC *)(pGC->devPrivates[mfbGCPrivateIndex].ptr))->pCompositeClip); pwidthFree = (int *)ALLOCATE_LOCAL(n * sizeof(int)); pptFree = (DDXPointRec *)ALLOCATE_LOCAL(n * sizeof(DDXPointRec)); if(!pptFree || !pwidthFree) { if (pptFree) DEALLOCATE_LOCAL(pptFree); if (pwidthFree) DEALLOCATE_LOCAL(pwidthFree); return; } pwidth = pwidthFree;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -