|
|
1.1 ! root 1: /*********************************************************** ! 2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts, ! 3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts. ! 4: ! 5: All Rights Reserved ! 6: ! 7: Permission to use, copy, modify, and distribute this software and its ! 8: documentation for any purpose and without fee is hereby granted, ! 9: provided that the above copyright notice appear in all copies and that ! 10: both that copyright notice and this permission notice appear in ! 11: supporting documentation, and that the names of Digital or MIT not be ! 12: used in advertising or publicity pertaining to distribution of the ! 13: software without specific, written prior permission. ! 14: ! 15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ! 16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL ! 17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ! 18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, ! 19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ! 20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS ! 21: SOFTWARE. ! 22: ! 23: ******************************************************************/ ! 24: /* $Header: mipushpxl.c,v 1.14 87/09/11 07:20:28 toddb Exp $ */ ! 25: #include "X.h" ! 26: #include "gcstruct.h" ! 27: #include "scrnintstr.h" ! 28: #include "pixmapstr.h" ! 29: #include "miscstruct.h" ! 30: #include "../mfb/maskbits.h" ! 31: ! 32: #define NPT 128 ! 33: ! 34: /* miPushPixels -- squeegees the fill style of pGC through pBitMap ! 35: * into pDrawable. pBitMap is a stencil (dx by dy of it is used, it may ! 36: * be bigger) which is placed on the drawable at xOrg, yOrg. Where a 1 bit ! 37: * is set in the bitmap, the fill style is put onto the drawable using ! 38: * the GC's logical function. The drawable is not changed where the bitmap ! 39: * has a zero bit or outside the area covered by the stencil. ! 40: ! 41: WARNING: ! 42: this code works if the 1-bit deep pixmap format returned by GetSpans ! 43: is the same as the format defined by the mfb code (i.e. 32-bit padding ! 44: per scanline, scanline unit = 32 bits; later, this might mean ! 45: bitsizeof(int) padding and sacnline unit == bitsizeof(int).) ! 46: ! 47: */ ! 48: void ! 49: miPushPixels(pGC, pBitMap, pDrawable, dx, dy, xOrg, yOrg) ! 50: GCPtr pGC; ! 51: PixmapPtr pBitMap; ! 52: DrawablePtr pDrawable; ! 53: int dx, dy, xOrg, yOrg; ! 54: { ! 55: int h, dxDiv32, ibEnd; ! 56: unsigned long *pwLineStart; ! 57: register unsigned long *pw, *pwEnd; ! 58: register unsigned long msk; ! 59: register int ib, w; ! 60: register int ipt; /* index into above arrays */ ! 61: Bool fInBox; ! 62: DDXPointRec pt[NPT], ptThisLine; ! 63: int width[NPT]; ! 64: ! 65: ipt = 0; ! 66: dxDiv32 = dx/32; ! 67: ! 68: for(h = 0, ptThisLine.x = 0, ptThisLine.y = 0; ! 69: h < dy; ! 70: h++, ptThisLine.y++) ! 71: { ! 72: ! 73: pw = (unsigned long *)(*pBitMap->drawable.pScreen->GetSpans)(pBitMap, ! 74: dx, &ptThisLine, &dx, 1); ! 75: pwLineStart = pw; ! 76: /* Process all words which are fully in the pixmap */ ! 77: ! 78: fInBox = FALSE; ! 79: pwEnd = pwLineStart + dxDiv32; ! 80: while(pw < pwEnd) ! 81: { ! 82: w = *pw; ! 83: msk = endtab[1]; ! 84: for(ib = 0; ib < 32; ib++) ! 85: { ! 86: if(w & msk) ! 87: { ! 88: if(!fInBox) ! 89: { ! 90: pt[ipt].x = ((pw - pwLineStart) << 5) + ib + xOrg; ! 91: pt[ipt].y = h + yOrg; ! 92: /* start new box */ ! 93: fInBox = TRUE; ! 94: } ! 95: } ! 96: else ! 97: { ! 98: if(fInBox) ! 99: { ! 100: width[ipt] = ((pw - pwLineStart) << 5) + ! 101: ib + xOrg - pt[ipt].x; ! 102: if (++ipt >= NPT) ! 103: { ! 104: (*pGC->FillSpans)(pDrawable, pGC, ! 105: NPT, pt, width, TRUE); ! 106: ipt = 0; ! 107: } ! 108: /* end box */ ! 109: fInBox = FALSE; ! 110: } ! 111: } ! 112: msk = SCRRIGHT(msk, 1); ! 113: } ! 114: pw++; ! 115: } ! 116: ibEnd = dx & 0x1F; ! 117: if(ibEnd) ! 118: { ! 119: /* Process final partial word on line */ ! 120: w = *pw; ! 121: msk = endtab[1]; ! 122: for(ib = 0; ib < ibEnd; ib++) ! 123: { ! 124: if(w & msk) ! 125: { ! 126: if(!fInBox) ! 127: { ! 128: /* start new box */ ! 129: pt[ipt].x = ((pw - pwLineStart) << 5) + ib + xOrg; ! 130: pt[ipt].y = h + yOrg; ! 131: fInBox = TRUE; ! 132: } ! 133: } ! 134: else ! 135: { ! 136: if(fInBox) ! 137: { ! 138: /* end box */ ! 139: width[ipt] = ((pw - pwLineStart) << 5) + ! 140: ib + xOrg - pt[ipt].x; ! 141: if (++ipt >= NPT) ! 142: { ! 143: (*pGC->FillSpans)(pDrawable, ! 144: pGC, NPT, pt, width, TRUE); ! 145: ipt = 0; ! 146: } ! 147: fInBox = FALSE; ! 148: } ! 149: } ! 150: msk = SCRRIGHT(msk, 1); ! 151: } ! 152: } ! 153: /* If scanline ended with last bit set, end the box */ ! 154: if(fInBox) ! 155: { ! 156: width[ipt] = ((pw - pwLineStart) << 5) + ib + xOrg - pt[ipt].x; ! 157: if (++ipt >= NPT) ! 158: { ! 159: (*pGC->FillSpans)(pDrawable, pGC, NPT, pt, width, TRUE); ! 160: ipt = 0; ! 161: } ! 162: } ! 163: Xfree(pw); ! 164: } ! 165: /* Flush any remaining spans */ ! 166: if (ipt) ! 167: { ! 168: (*pGC->FillSpans)(pDrawable, pGC, ipt, pt, width, TRUE); ! 169: } ! 170: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.