|
|
1.1 ! root 1: #ifndef lint ! 2: static char *rcsid_fill_c = "$Header: fill.c,v 10.4 86/11/30 16:06:12 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[] = "@(#)fill.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: /* fill.c Perform a simple raster operation a section of the screen ! 44: * ! 45: * PixFill Do a function on the screen ! 46: * ! 47: */ ! 48: ! 49: #include "Xsun.h" ! 50: extern struct pixrect *PixRect; ! 51: ! 52: /*ARGSUSED*/ ! 53: PixFill (srcpix, xymask, dstx, dsty, width, height, clips, clipcount, ! 54: func, zmask) ! 55: int srcpix, dstx, dsty, width, height, clipcount, zmask; ! 56: BITMAP *xymask; ! 57: int func; ! 58: CLIP *clips; ! 59: { ! 60: int op = SUN_FROM_X_OP(func) | PIX_COLOR(srcpix) | PIX_DONTCLIP; ! 61: int allmask = -1; ! 62: ! 63: SetZmask(PixRect, &zmask); ! 64: if (xymask == NULL) { ! 65: do { ! 66: int cleft, ctop, cwidth, cheight; ! 67: ! 68: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 69: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 70: int tleft = (cleft > dstx ? cleft : dstx); ! 71: int ttop = (ctop > dsty ? ctop : dsty); ! 72: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 73: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 74: ! 75: CheckCursor(tleft, ttop, twidth, theight); ! 76: pr_rop(PixRect, tleft, ttop, twidth, theight, op, NULL, 0, 0); ! 77: } ! 78: } while (--clipcount > 0); ! 79: } ! 80: else { ! 81: struct pixrect stencil; ! 82: struct mpr_data foo_data; ! 83: extern struct pixrectops mem_ops; ! 84: ! 85: foo_data.md_linebytes = mpr_linebytes(xymask->width, 1); ! 86: foo_data.md_image = (short *) xymask->data; ! 87: foo_data.md_offset.x = 0; ! 88: foo_data.md_offset.y = 0; ! 89: foo_data.md_primary = 0; ! 90: foo_data.md_flags = 0; ! 91: stencil.pr_ops = &mem_ops; ! 92: stencil.pr_size.x = xymask->width; ! 93: stencil.pr_size.y = xymask->height; ! 94: stencil.pr_depth = 1; ! 95: stencil.pr_data = (caddr_t) &foo_data; ! 96: do { ! 97: int cleft, ctop, cwidth, cheight; ! 98: ! 99: GetNextClip(clips, cleft, ctop, cwidth, cheight); ! 100: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { ! 101: int tleft = (cleft > dstx ? cleft : dstx); ! 102: int ttop = (ctop > dsty ? ctop : dsty); ! 103: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; ! 104: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; ! 105: ! 106: CheckCursor(tleft, ttop, twidth, theight); ! 107: pr_stencil(PixRect, tleft, ttop, twidth, theight, op, &stencil, ! 108: tleft - dstx, ttop - dsty, NULL, 0, 0); ! 109: } ! 110: } while (--clipcount > 0); ! 111: } ! 112: RestoreCursor(); ! 113: SetZmask(PixRect, &allmask); ! 114: } ! 115: /* ! 116: * the following is bogus on a color sun, but as I know nothing about Suns, ! 117: * might as well make b/w work.... -JG ! 118: */ ! 119: extern int errno; ! 120: #include <errno.h> ! 121: ! 122: int StippleFill (srcpix, xoff, yoff, stipmask, dstx, dsty, width, height, ! 123: clips, clipcount, func, zmask) ! 124: int srcpix; /* source pixel */ ! 125: int xoff, yoff; /* stipple origin */ ! 126: BITMAP *stipmask; /* stipple mask */ ! 127: int dstx, dsty; /* destination */ ! 128: int width, height; ! 129: CLIP *clips; /* clipping rectangles */ ! 130: int clipcount; ! 131: int func; /* GX display function */ ! 132: int zmask; /* plane mask */ ! 133: { ! 134: static char funcmap[16][2] = { ! 135: {GXandInverted, GXandInverted}, /* GXclear */ ! 136: {GXandInverted, GXnoop}, /* GXand */ ! 137: {GXandInverted, GXxor}, /* GXandReverse */ ! 138: {GXandInverted, GXor}, /* GXcopy */ ! 139: {GXnoop, GXandInverted}, /* GXandInverted */ ! 140: {GXnoop, GXnoop}, /* GXnoop */ ! 141: {GXnoop, GXxor}, /* GXxor */ ! 142: {GXnoop, GXor}, /* GXor */ ! 143: {GXxor, GXandInverted}, /* GXnor */ ! 144: {GXxor, GXnoop}, /* GXequiv */ ! 145: {GXxor, GXxor}, /* GXinvert */ ! 146: {GXxor, GXor}, /* GXorReverse */ ! 147: {GXor, GXandInverted}, /* GXcopyInverted */ ! 148: {GXor, GXnoop}, /* GXorInverted */ ! 149: {GXor, GXxor}, /* GXnand */ ! 150: {GXor, GXor} /* GXset */ ! 151: }; ! 152: int newfunc = funcmap [func][srcpix & 1]; ! 153: PIXMAP *tile, *MakePixmap(); ! 154: ! 155: if ((stipmask->width != 16) || (stipmask->height != 16)) { ! 156: errno = EINVAL; ! 157: return (0); ! 158: } ! 159: tile = MakePixmap (stipmask, 1, 0); ! 160: TileFill (tile, xoff, yoff, 0, dstx, dsty, width, height, ! 161: clips, clipcount, newfunc, zmask); ! 162: FreePixmap (tile); ! 163: return (1); ! 164: } ! 165: #endif sun
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.