|
|
1.1 ! root 1: #ifndef lint ! 2: static char *rcsid_put_c = "$Header: put.c,v 10.3 86/11/29 13:48:41 jg 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: if (PINVERT(src)) { ! 94: op = SUN_FROM_X_OP_INVERT(func); ! 95: } ! 96: pr_rop(PixRect, tleft, ttop, twidth, theight, op | PIX_DONTCLIP, Src, sx, sy); ! 97: } ! 98: } while (--clipcount > 0); ! 99: pr_destroy(Src); ! 100: } ! 101: break; ! 102: case ConstantPixmap: ! 103: /* spread constant from (dstx,dsty) by (width,height) */ ! 104: do { ! 105: int cleft, ctop, cwidth, cheight; ! 106: ! 107: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 108: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 109: int tleft = (cleft > dstx ? cleft : dstx); ! 110: int ttop = (ctop > dsty ? ctop : dsty); ! 111: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 112: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 113: CheckCursor(tleft, ttop, twidth, theight); ! 114: /* XXX - is this the right tile mode? */ ! 115: pr_rop(PixRect, tleft, ttop, twidth, theight, PIX_SRC | PIX_COLOR(PINVERT(src) ^ (int) src->data), NULL, 0, 0); ! 116: } ! 117: } while (--clipcount > 0); ! 118: break; ! 119: case ZColorPixmap: ! 120: Src = mem_point(src->width, src->height, PixRect->pr_depth, src->data); ! 121: do { ! 122: int cleft, ctop, cwidth, cheight; ! 123: ! 124: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 125: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 126: int tleft = (cleft > dstx ? cleft : dstx); ! 127: int ttop = (ctop > dsty ? ctop : dsty); ! 128: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 129: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 130: int sx = (tleft - dstx) + srcx; ! 131: int sy = (ttop - dsty) + srcy; ! 132: ! 133: CheckCursor(tleft, ttop, twidth, theight); ! 134: CheckCursor(sx, sy, twidth, theight); ! 135: pr_rop(PixRect, tleft, ttop, twidth, theight, op | PIX_DONTCLIP, Src, sx, sy); ! 136: } ! 137: } while (--clipcount > 0); ! 138: pr_destroy(Src); ! 139: break; ! 140: case XYColorPixmap: ! 141: /* XXX - not yet implemented - do a plane at a time */ ! 142: break; ! 143: } ! 144: RestoreCursor(); ! 145: SetZmask(PixRect, &allmask); ! 146: } ! 147: ! 148: ! 149: /*ARGSUSED*/ ! 150: PixmapBitsPut (width, height, format, data, xymask, dstx, dsty, ! 151: clips, clipcount, func, zmask) ! 152: char *data; ! 153: int width, height, format, dstx, dsty, clipcount, zmask; ! 154: BITMAP *xymask; ! 155: CLIP *clips; ! 156: int func; ! 157: { ! 158: if (PixRect->pr_depth == 1) ! 159: BitsPut(width, height, data, 1, 0, xymask, dstx, dsty, ! 160: clips, clipcount, func, zmask, 1); ! 161: else if (PixRect->pr_depth <= 8) ! 162: switch (format) { ! 163: case ZFormat: { ! 164: char *newdata; ! 165: ! 166: if (width&1) { ! 167: register int i; ! 168: register char *old = data, *new; ! 169: ! 170: new = newdata = (char *) Xalloc((width+1)*height); ! 171: for (i = 0; i < height; i++) { ! 172: bcopy(old, new, width); ! 173: old += width; ! 174: new += width+1; ! 175: } ! 176: } else ! 177: newdata = data; ! 178: BitsPut(width, height, newdata, 1, 0, xymask, dstx, dsty, ! 179: clips, clipcount, func, zmask, PixRect->pr_depth); ! 180: if (newdata != data) ! 181: free (newdata); ! 182: } ! 183: break; ! 184: case XYFormat: ! 185: /* XXX - not yet supported - do one plane at a time */ ! 186: break; ! 187: } ! 188: } ! 189: ! 190: BitmapBitsPut (width, height, data, fore, back, xymask, dstx, dsty, ! 191: clips, clipcount, func, zmask) ! 192: char *data; ! 193: int width, height, fore, back, dstx, dsty, clipcount, zmask; ! 194: register BITMAP *xymask; ! 195: CLIP *clips; ! 196: register int func; ! 197: { ! 198: InvertPixelOrder((short *) data, BitmapSize(width, height) >> 1); ! 199: BitsPut(width, height, data, fore, back, xymask, dstx, dsty, ! 200: clips, clipcount, func, zmask, 1); ! 201: } ! 202: ! 203: static ! 204: BitsPut (width, height, data, fore, back, xymask, dstx, dsty, ! 205: clips, clipcount, func, zmask, srcdepth) ! 206: char *data; ! 207: int width, height, fore, back, dstx, dsty, clipcount, zmask; ! 208: register BITMAP *xymask; ! 209: CLIP *clips; ! 210: register int func; ! 211: int srcdepth; ! 212: { ! 213: struct pixrect *Src; ! 214: extern char FBMap[]; ! 215: int allmask = -1; ! 216: int op; ! 217: ! 218: if ((PixRect->pr_depth == 1) && !(zmask & 1)) ! 219: return; ! 220: SetZmask(PixRect, &zmask); ! 221: if (fore & 1) ! 222: func += 0x20; ! 223: if (back & 1) ! 224: func += 0x10; ! 225: ! 226: func = FBMap[func]; ! 227: op = SUN_FROM_X_OP(func); ! 228: ! 229: Src = mem_point(width, height, srcdepth, data); ! 230: if (xymask == NULL) { ! 231: do { ! 232: int cleft, ctop, cwidth, cheight; ! 233: ! 234: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 235: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 236: int tleft = (cleft > dstx ? cleft : dstx); ! 237: int ttop = (ctop > dsty ? ctop : dsty); ! 238: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 239: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 240: int sx = (tleft - dstx); ! 241: int sy = (ttop - dsty); ! 242: ! 243: CheckCursor(cleft, ctop, cwidth, cheight); ! 244: pr_rop(PixRect, tleft, ttop, twidth, theight, op | PIX_DONTCLIP, Src, sx, sy); ! 245: } ! 246: } while (--clipcount > 0); ! 247: } ! 248: else { ! 249: struct pixrect *stencil; ! 250: ! 251: stencil = mem_point(xymask->width, xymask->height, 1, xymask->data); ! 252: do { ! 253: int cleft, ctop, cwidth, cheight; ! 254: ! 255: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 256: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 257: CheckCursor(cleft, ctop, cwidth, cheight); ! 258: pr_stencil(PixRect, dstx, dsty, width, height, op, ! 259: stencil, 0, 0, Src, 0, 0); ! 260: } ! 261: } while (--clipcount > 0); ! 262: pr_destroy(stencil); ! 263: } ! 264: RestoreCursor(); ! 265: pr_destroy(Src); ! 266: SetZmask(PixRect, &allmask); ! 267: return; ! 268: } ! 269: #endif sun
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.