|
|
1.1 ! root 1: #ifndef lint ! 2: static char *rcsid_put_c = "$Header: put.c,v 10.2 86/02/01 16:21:13 tony Rel $"; ! 3: #endif lint ! 4: #ifdef sun ! 5: /* ! 6: * The Sun X drivers are a product of Sun Microsystems, Inc. and are provided ! 7: * for unrestricted use provided that this legend is included on all tape ! 8: * media and as a part of the software program in whole or part. Users ! 9: * may copy or modify these drivers without charge, but are not authorized ! 10: * to license or distribute them to anyone else except as part of a product or ! 11: * program developed by the user. ! 12: * ! 13: * THE SUN X DRIVERS ARE PROVIDED AS IS WITH NO WARRANTIES OF ANY KIND ! 14: * INCLUDING THE WARRANTIES OF DESIGN, MERCHANTIBILITY AND FITNESS FOR A ! 15: * PARTICULAR PURPOSE, OR ARISING FROM A COURSE OF DEALING, USAGE OR TRADE ! 16: * PRACTICE. ! 17: * ! 18: * The Sun X Drivers are provided with no support and without any obligation ! 19: * on the part of Sun Microsystems, Inc. to assist in their use, correction, ! 20: * modification or enhancement. ! 21: * ! 22: * SUN MICROSYSTEMS, INC. SHALL HAVE NO LIABILITY WITH RESPECT TO THE ! 23: * INFRINGEMENT OF COPYRIGHTS, TRADE SECRETS OR ANY PATENTS BY THE SUN X ! 24: * DRIVERS OR ANY PART THEREOF. ! 25: * ! 26: * In no event will Sun Microsystems, Inc. be liable for any lost revenue ! 27: * or profits or other special, indirect and consequential damages, even if ! 28: * Sun has been advised of the possibility of such damages. ! 29: * ! 30: * Sun Microsystems, Inc. ! 31: * 2550 Garcia Avenue ! 32: * Mountain View, California 94043 ! 33: */ ! 34: ! 35: #ifndef lint ! 36: static char sccsid[] = "@(#)put.c 2.1 86/01/28 Copyright 1986 Sun Micro"; ! 37: #endif ! 38: ! 39: /*- ! 40: * Copyright (c) 1986 by Sun Microsystems, Inc. ! 41: */ ! 42: ! 43: /* put.c Perform a raster operation with a source bitmap ! 44: * ! 45: * PixmapPut Puts a pixmap up on the screen ! 46: * PixmapBitsPut Puts a pixmap up on the screen ! 47: * BitmapBitsPut Puts a pixmap up on the screen ! 48: * ! 49: */ ! 50: ! 51: /* ! 52: * ToDo: ! 53: * XYColorPixmap putting & bitsputting ! 54: */ ! 55: ! 56: #include "Xsun.h" ! 57: ! 58: extern struct pixrect *PixRect; ! 59: ! 60: char *Xalloc(); ! 61: ! 62: PixmapPut (src, srcx, srcy, width, height, dstx, dsty, clips, clipcount, ! 63: func, zmask) ! 64: register PIXMAP *src; ! 65: int srcx, srcy, width, height, dstx, dsty, clipcount, zmask; ! 66: register int func; ! 67: CLIP *clips; ! 68: { ! 69: struct pixrect *Src; ! 70: int op = SUN_FROM_X_OP(func); ! 71: int allmask = -1; ! 72: ! 73: SetZmask(PixRect, &zmask); ! 74: switch (PTYPE(src)) { ! 75: case BitmapPixmap: ! 76: { ! 77: BITMAP *bm = (BITMAP *) src->data; ! 78: Src = mem_point(bm->width, bm->height, 1, bm->data); ! 79: do { ! 80: int cleft, ctop, cwidth, cheight; ! 81: ! 82: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 83: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 84: int tleft = (cleft > dstx ? cleft : dstx); ! 85: int ttop = (ctop > dsty ? ctop : dsty); ! 86: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 87: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 88: int sx = (tleft - dstx) + srcx; ! 89: int sy = (ttop - dsty) + srcy; ! 90: ! 91: CheckCursor(tleft, ttop, twidth, theight); ! 92: CheckCursor(sx, sy, twidth, theight); ! 93: pr_rop(PixRect, tleft, ttop, twidth, theight, op | PIX_DONTCLIP, Src, sx, sy); ! 94: } ! 95: } while (--clipcount > 0); ! 96: pr_destroy(Src); ! 97: } ! 98: break; ! 99: case ConstantPixmap: ! 100: /* spread constant from (dstx,dsty) by (width,height) */ ! 101: do { ! 102: int cleft, ctop, cwidth, cheight; ! 103: ! 104: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 105: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 106: int tleft = (cleft > dstx ? cleft : dstx); ! 107: int ttop = (ctop > dsty ? ctop : dsty); ! 108: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 109: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 110: CheckCursor(tleft, ttop, twidth, theight); ! 111: /* XXX - is this the right tile mode? */ ! 112: pr_rop(PixRect, tleft, ttop, twidth, theight, PIX_SRC | PIX_COLOR(PINVERT(src) ^ (int) src->data), NULL, 0, 0); ! 113: } ! 114: } while (--clipcount > 0); ! 115: break; ! 116: case ZColorPixmap: ! 117: Src = mem_point(src->width, src->height, PixRect->pr_depth, src->data); ! 118: do { ! 119: int cleft, ctop, cwidth, cheight; ! 120: ! 121: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 122: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 123: int tleft = (cleft > dstx ? cleft : dstx); ! 124: int ttop = (ctop > dsty ? ctop : dsty); ! 125: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 126: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 127: int sx = (tleft - dstx) + srcx; ! 128: int sy = (ttop - dsty) + srcy; ! 129: ! 130: CheckCursor(tleft, ttop, twidth, theight); ! 131: CheckCursor(sx, sy, twidth, theight); ! 132: pr_rop(PixRect, tleft, ttop, twidth, theight, op | PIX_DONTCLIP, Src, sx, sy); ! 133: } ! 134: } while (--clipcount > 0); ! 135: pr_destroy(Src); ! 136: break; ! 137: case XYColorPixmap: ! 138: /* XXX - not yet implemented - do a plane at a time */ ! 139: break; ! 140: } ! 141: RestoreCursor(); ! 142: SetZmask(PixRect, &allmask); ! 143: } ! 144: ! 145: ! 146: /*ARGSUSED*/ ! 147: PixmapBitsPut (width, height, format, data, xymask, dstx, dsty, ! 148: clips, clipcount, func, zmask) ! 149: char *data; ! 150: int width, height, format, dstx, dsty, clipcount, zmask; ! 151: BITMAP *xymask; ! 152: CLIP *clips; ! 153: int func; ! 154: { ! 155: if (PixRect->pr_depth == 1) ! 156: BitsPut(width, height, data, 1, 0, xymask, dstx, dsty, ! 157: clips, clipcount, func, zmask, 1); ! 158: else if (PixRect->pr_depth <= 8) ! 159: switch (format) { ! 160: case ZFormat: { ! 161: char *newdata; ! 162: ! 163: if (width&1) { ! 164: register int i; ! 165: register char *old = data, *new; ! 166: ! 167: new = newdata = (char *) Xalloc((width+1)*height); ! 168: for (i = 0; i < height; i++) { ! 169: bcopy(old, new, width); ! 170: old += width; ! 171: new += width+1; ! 172: } ! 173: } else ! 174: newdata = data; ! 175: BitsPut(width, height, newdata, 1, 0, xymask, dstx, dsty, ! 176: clips, clipcount, func, zmask, PixRect->pr_depth); ! 177: if (newdata != data) ! 178: free (newdata); ! 179: } ! 180: break; ! 181: case XYFormat: ! 182: /* XXX - not yet supported - do one plane at a time */ ! 183: break; ! 184: } ! 185: } ! 186: ! 187: BitmapBitsPut (width, height, data, fore, back, xymask, dstx, dsty, ! 188: clips, clipcount, func, zmask) ! 189: char *data; ! 190: int width, height, fore, back, dstx, dsty, clipcount, zmask; ! 191: register BITMAP *xymask; ! 192: CLIP *clips; ! 193: register int func; ! 194: { ! 195: InvertPixelOrder((short *) data, BitmapSize(width, height) >> 1); ! 196: BitsPut(width, height, data, fore, back, xymask, dstx, dsty, ! 197: clips, clipcount, func, zmask, 1); ! 198: } ! 199: ! 200: static ! 201: BitsPut (width, height, data, fore, back, xymask, dstx, dsty, ! 202: clips, clipcount, func, zmask, srcdepth) ! 203: char *data; ! 204: int width, height, fore, back, dstx, dsty, clipcount, zmask; ! 205: register BITMAP *xymask; ! 206: CLIP *clips; ! 207: register int func; ! 208: int srcdepth; ! 209: { ! 210: struct pixrect *Src; ! 211: extern char FBMap[]; ! 212: int allmask = -1; ! 213: int op; ! 214: ! 215: if ((PixRect->pr_depth == 1) && !(zmask & 1)) ! 216: return; ! 217: SetZmask(PixRect, &zmask); ! 218: if (fore & 1) ! 219: func += 0x20; ! 220: if (back & 1) ! 221: func += 0x10; ! 222: ! 223: func = FBMap[func]; ! 224: op = SUN_FROM_X_OP(func); ! 225: ! 226: Src = mem_point(width, height, srcdepth, data); ! 227: if (xymask == NULL) { ! 228: do { ! 229: int cleft, ctop, cwidth, cheight; ! 230: ! 231: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 232: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 233: int tleft = (cleft > dstx ? cleft : dstx); ! 234: int ttop = (ctop > dsty ? ctop : dsty); ! 235: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 236: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 237: int sx = (tleft - dstx); ! 238: int sy = (ttop - dsty); ! 239: ! 240: CheckCursor(cleft, ctop, cwidth, cheight); ! 241: pr_rop(PixRect, tleft, ttop, twidth, theight, op | PIX_DONTCLIP, Src, sx, sy); ! 242: } ! 243: } while (--clipcount > 0); ! 244: } ! 245: else { ! 246: struct pixrect *stencil; ! 247: ! 248: stencil = mem_point(xymask->width, xymask->height, 1, xymask->data); ! 249: do { ! 250: int cleft, ctop, cwidth, cheight; ! 251: ! 252: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 253: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 254: CheckCursor(cleft, ctop, cwidth, cheight); ! 255: pr_stencil(PixRect, dstx, dsty, width, height, op, ! 256: stencil, 0, 0, Src, 0, 0); ! 257: } ! 258: } while (--clipcount > 0); ! 259: pr_destroy(stencil); ! 260: } ! 261: RestoreCursor(); ! 262: pr_destroy(Src); ! 263: SetZmask(PixRect, &allmask); ! 264: return; ! 265: } ! 266: #endif sun
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.