1: #ifndef lint 2: static char *rcsid_tile_c = "$Header: tile.c,v 10.2 86/02/01 16:21:30 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[] = "@(#)tile.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: /* tile.c Perform a raster operation involving a pattern 44: * 45: * TileFill Patterns a portion of the screen 46: * DrawFilled Draw a filled generalized line/polygon/combination 47: * 48: */ 49: 50: /* 51: * ToDo: 52: * Implement draw filled 53: * Implement tile fill with xymap 54: * Use static pixrects 55: */ 56: 57: #include "Xsun.h" 58: 59: extern struct pixrect *PixRect; 60: 61: char *Xalloc(); 62: 63: static 64: PixrectFill(Tile, xymask, dstx, dsty, width, height, op, clips, clipcount, xoff, yoff) 65: struct pixrect *Tile; 66: BITMAP *xymask; 67: int dstx, dsty, width, height; 68: unsigned op; 69: CLIP *clips; 70: int clipcount; 71: int xoff, yoff; 72: { 73: if (xymask == NULL) { 74: /* spread tile from (dstx,dsty) by (width,height) */ 75: do { 76: int cleft, ctop, cwidth, cheight; 77: 78: GetNextClip(clips, cleft, ctop, cwidth, cheight); 79: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { 80: int tleft = (cleft > dstx ? cleft : dstx); 81: int ttop = (ctop > dsty ? ctop : dsty); 82: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; 83: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; 84: /* XXX - is this the right tile mode? */ 85: CheckCursor(tleft, ttop, twidth, theight); 86: pr_replrop(PixRect, tleft, ttop, twidth, theight, op, 87: Tile, tleft - xoff, ttop - yoff); 88: } 89: } while (--clipcount > 0); 90: } 91: else { 92: /* spread tile thru xymask */ 93: struct pixrect *stencil = mem_point(xymask->width, xymask->width, 1, xymask->data); 94: 95: #ifdef notdef 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: CheckCursor(tleft, ttop, twidth, theight); 106: /* XXX - need combination of stencil & replrop */ 107: pr_stencil(PixRect, tleft, ttop, twidth, theight, op, &stencil, tleft, ttop, NULL, 0, 0); 108: } 109: } while (--clipcount > 0); 110: #endif 111: pr_destroy(stencil); 112: } 113: } 114: 115: static 116: ConstantFill(tile, xymask, dstx, dsty, width, height, op, clips, clipcount) 117: PIXMAP *tile; 118: BITMAP *xymask; 119: int dstx, dsty, width, height; 120: unsigned op; 121: CLIP *clips; 122: int clipcount; 123: { 124: op |= PIX_COLOR((PINVERT(tile) ^ (int) tile->data)); 125: if (xymask == NULL) { 126: /* spread constant from (dstx,dsty) by (width,height) */ 127: do { 128: int cleft, ctop, cwidth, cheight; 129: 130: GetNextClip(clips, cleft, ctop, cwidth, cheight); 131: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { 132: int tleft = (cleft > dstx ? cleft : dstx); 133: int ttop = (ctop > dsty ? ctop : dsty); 134: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; 135: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; 136: CheckCursor(tleft, ttop, twidth, theight); 137: /* XXX - is this the right tile mode? */ 138: pr_rop(PixRect, tleft, ttop, twidth, theight, op, NULL, 0, 0); 139: } 140: } while (--clipcount > 0); 141: } 142: else { 143: /* spread constant thru xymask */ 144: struct pixrect *stencil = mem_point(xymask->width, xymask->width, 1, xymask->data); 145: 146: do { 147: int cleft, ctop, cwidth, cheight; 148: 149: GetNextClip(clips, cleft, ctop, cwidth, cheight); 150: if (OverLap(cleft, ctop, cwidth, cheight, dstx, dsty, width, height)) { 151: int tleft = (cleft > dstx ? cleft : dstx); 152: int ttop = (ctop > dsty ? ctop : dsty); 153: int twidth = (cleft + cwidth < dstx + width ? cleft + cwidth : dstx + width) - tleft; 154: int theight = (ctop + cheight < dsty + height ? ctop + cheight : dsty + height) - ttop; 155: 156: CheckCursor(tleft, ttop, twidth, theight); 157: pr_stencil(PixRect, tleft, ttop, twidth, theight, op, stencil, tleft, ttop, NULL, 0, 0); 158: } 159: } while (--clipcount > 0); 160: pr_destroy(stencil); 161: } 162: } 163: 164: 165: /*ARGSUSED*/ 166: TileFill (tile, xoff, yoff, xymask, dstx, dsty, width, height, 167: clips, clipcount, func, zmask) 168: PIXMAP *tile; 169: BITMAP *xymask; 170: int xoff, yoff, dstx, dsty, width, height, zmask; 171: register int func; 172: CLIP *clips; 173: { 174: int op = SUN_FROM_X_OP(func) | PIX_DONTCLIP; 175: int allmask = -1; 176: 177: if ((PixRect->pr_depth == 1) && !(zmask & 1)) 178: return; 179: SetZmask(PixRect, &zmask); 180: switch (PTYPE(tile)) { 181: case BitmapPixmap: 182: { 183: struct pixrect *Tile = 184: mem_point(tile->width, tile->height, 1, ((BITMAP *) tile->data)->data); /* XXX - slow !!! */ 185: 186: PixrectFill(Tile, xymask, dstx, dsty, width, height, op, clips, clipcount, xoff, yoff); 187: pr_destroy(Tile); 188: } 189: break; 190: case ConstantPixmap: 191: ConstantFill(tile, xymask, dstx, dsty, width, height, op, clips, clipcount); 192: break; 193: case XYColorPixmap: 194: /* XXX - not yet implemented - do plane by plane */ 195: break; 196: case ZColorPixmap: 197: { 198: struct pixrect *Tile = 199: mem_point(tile->width, tile->height, PixRect->pr_depth, tile->data); /* XXX - slow !!! */ 200: 201: PixrectFill(Tile, xymask, dstx, dsty, width, height, op, clips, clipcount, xoff, yoff); 202: pr_destroy(Tile); 203: } 204: break; 205: } 206: SetZmask(PixRect, &allmask); 207: RestoreCursor(); 208: } 209: 210: /*ARGSUSED*/ 211: DrawFilled (verts, vertcount, xbase, ybase, srcpix, tile, xoff, yoff, 212: clips, clipcount, func, zmask) 213: Vertex *verts; 214: register PIXMAP *tile; 215: int vertcount, xbase, ybase, srcpix, xoff, yoff, clipcount, zmask; 216: register int func; 217: CLIP *clips; 218: { 219: /* XXX - need pr_polygon_2() */ 220: } 221: #endif sun