|
|
1.1 ! root 1: #ifndef lint ! 2: static char *rcsid_tile_c = "$Header: tile.c,v 10.1 86/11/29 13:53:11 jg Rel $"; ! 3: #endif lint ! 4: /* ! 5: ! 6: Copyright 1986 by the University of Utah ! 7: ! 8: Permission to use, copy, modify, and distribute this ! 9: software and its documentation for any purpose and without ! 10: fee is hereby granted, provided that the above copyright ! 11: notice appear in all copies and that both that copyright ! 12: notice and this permission notice appear in supporting ! 13: documentation, and that the name of the University of Utah ! 14: not be used in advertising or publicity pertaining to ! 15: distribution of the software without specific, written ! 16: prior permission. The University of Utah makes no ! 17: representations about the suitability of this software for ! 18: any purpose. It is provided "as is" without express or ! 19: implied warranty. ! 20: ! 21: */ ! 22: ! 23: /* tile.c Perform a raster operation involving a pattern ! 24: * ! 25: * TileFill Patterns a portion of the screen ! 26: * DrawFilled Draw a filled generalized line/polygon/combination ! 27: * ! 28: */ ! 29: ! 30: /* ! 31: * ToDo: ! 32: * Implement tile fill with xymap ! 33: */ ! 34: ! 35: #include "Xapollo.h" ! 36: ! 37: extern boolean borrow_flag; ! 38: extern gpr_$bitmap_desc_t TileBM; ! 39: extern int old_op; ! 40: ! 41: status_$t status; ! 42: ! 43: static ! 44: tilefill(tile, xymask, dstx, dsty, width, height, op, clips, clipcount, xoff, yoff) ! 45: PIXMAP *tile; ! 46: BITMAP *xymask; ! 47: int dstx, dsty, width, height; ! 48: unsigned op; ! 49: CLIP *clips; ! 50: int clipcount; ! 51: int xoff, yoff; ! 52: { ! 53: gpr_$position_t dstorg; ! 54: gpr_$window_t cwindow; ! 55: gpr_$window_t srcwin; ! 56: int twidth = tile->width, ! 57: theight = tile->height; ! 58: int zmask, i, j; ! 59: ! 60: if (xymask == NULL) { ! 61: cache_tile(tile, &theight, &twidth); ! 62: zmask = (1 << Screen.depth) - 1; ! 63: set_zmask(zmask); ! 64: set_op( 3 ); ! 65: gpr_$set_fill_value((gpr_$pixel_value_t)1, status); ! 66: gpr_$set_fill_background_value((gpr_$pixel_value_t)0, status); ! 67: gpr_$set_fill_pattern( TileBM, (short)1, status); ! 68: srcwin.x_coord = dstx; ! 69: srcwin.x_size = width; ! 70: srcwin.y_coord = dsty; ! 71: srcwin.y_size = height; ! 72: do { ! 73: ! 74: GetNextClip(clips, cwindow); ! 75: /* CheckCursor(cwindow.x_coord, cwindow.y_coord, ! 76: cwindow.x_size, cwindow.y_size); ! 77: */ ! 78: CheckCursor(dstx, dsty, width, height); ! 79: gpr_$set_clip_window( cwindow, status); ! 80: /* optimize only absolute case */ ! 81: if ((xoff == 0) && (yoff == 0)) ! 82: gpr_$rectangle( srcwin, status); ! 83: else { ! 84: gpr_$position_t dstorg; ! 85: ! 86: srcwin.x_coord = 0; ! 87: srcwin.y_coord = 0; ! 88: srcwin.x_size = twidth; ! 89: srcwin.y_size = theight; ! 90: dstorg.x_coord = dstx; ! 91: for (i=0; i< width; i += twidth) { ! 92: dstorg.y_coord = dsty; ! 93: if ((dstorg.x_coord <= ! 94: (cwindow.x_coord + cwindow.x_size)) && ! 95: ((dstorg.x_coord + twidth) >= ! 96: cwindow.x_coord)) ! 97: for (j=0; j<height; j += theight) { ! 98: if ((dstorg.y_coord <= ! 99: (cwindow.y_coord + cwindow.y_size)) && ! 100: ((dstorg.y_coord + theight) >= ! 101: cwindow.y_coord)) ! 102: gpr_$pixel_blt(TileBM, srcwin, dstorg, status); ! 103: dstorg.y_coord += theight; ! 104: } ! 105: dstorg.x_coord += twidth; ! 106: } ! 107: } ! 108: } while (--clipcount > 0); ! 109: gpr_$set_fill_pattern( gpr_$nil_bitmap_desc, (short)1, status); ! 110: return; ! 111: } ! 112: else { ! 113: /* xymask not implemented yet */ ! 114: } ! 115: RestoreCursor(); ! 116: if (!borrow_flag) gpr_$release_display(status); ! 117: } ! 118: ! 119: static ! 120: constfill(tile, xymask, dstx, dsty, width, height, op, clips, clipcount) ! 121: PIXMAP *tile; ! 122: BITMAP *xymask; ! 123: int dstx, dsty, width, height; ! 124: unsigned op; ! 125: CLIP *clips; ! 126: int clipcount; ! 127: { ! 128: gpr_$window_t cwindow, ! 129: dstwin; ! 130: int i; ! 131: int data = (int)tile->data; ! 132: ! 133: /* set drawing color based on invert flag ^ tiling value */ ! 134: data ^= PINVERT(tile); ! 135: gpr_$set_plane_mask((gpr_$mask_t) Screen.plane_mask, status); ! 136: gpr_$set_fill_value((gpr_$pixel_value_t)data, status); ! 137: set_op( op ); ! 138: dstwin.x_coord = dstx; ! 139: dstwin.x_size = width; ! 140: dstwin.y_coord = dsty; ! 141: dstwin.y_size = height; ! 142: if (xymask == NULL) { ! 143: do { ! 144: GetNextClip(clips, cwindow); ! 145: CheckCursor(dstx, dsty, width, height); ! 146: /* CheckCursor(cwindow.x_coord, cwindow.y_coord, ! 147: cwindow.x_size, cwindow.y_size); ! 148: */ ! 149: gpr_$set_clip_window( cwindow, status); ! 150: gpr_$rectangle( dstwin, status ); ! 151: } while (--clipcount > 0); ! 152: } ! 153: else { ! 154: /* xymask not implemented yet */ ! 155: } ! 156: RestoreCursor(); ! 157: } ! 158: ! 159: ! 160: /*ARGSUSED*/ ! 161: TileFill (tile, xoff, yoff, xymask, dstx, dsty, width, height, ! 162: clips, clipcount, func, zmask) ! 163: PIXMAP *tile; ! 164: BITMAP *xymask; ! 165: int xoff, yoff, dstx, dsty, width, height, zmask; ! 166: register int func; ! 167: CLIP *clips; ! 168: { ! 169: ! 170: if ((Screen.depth == 1) && !(zmask & 1)) ! 171: return; ! 172: ! 173: switch (PTYPE(tile)) { ! 174: case BitmapPixmap: ! 175: tilefill(tile, xymask, dstx, dsty, width, height, func, clips, clipcount, xoff, yoff); ! 176: break; ! 177: case ConstantPixmap: ! 178: constfill(tile, xymask, dstx, dsty, width, height, func, clips, clipcount); ! 179: break; ! 180: case XYColorPixmap: ! 181: /* Not yet implemented */ ! 182: break; ! 183: case ZColorPixmap: ! 184: /* Not yet implemented */ ! 185: fprintf(stderr, "TileFill: ZColorPixmap\n"); ! 186: break; ! 187: } ! 188: } ! 189: ! 190: /*ARGSUSED*/ ! 191: DrawFilled (verts, vertcount, xbase, ybase, srcpix, tile, xoff, yoff, ! 192: clips, clipcount, func, zmask) ! 193: Vertex *verts; ! 194: register PIXMAP *tile; ! 195: int vertcount, xbase, ybase, srcpix, xoff, yoff, clipcount, zmask; ! 196: register int func; ! 197: CLIP *clips; ! 198: { ! 199: gpr_$window_t cwindow; ! 200: status_$t status; ! 201: short *x, *y, *oldx, *oldy, *savx, *savy; ! 202: /* int data = (int)tile->data; */ ! 203: Vertex *v = verts; ! 204: int vc = vertcount; ! 205: ! 206: x = (short *)malloc(vertcount * 2); ! 207: y = (short *)malloc(vertcount * 2); ! 208: savx = x; ! 209: savy = y; ! 210: do { ! 211: if (v->flags & VertexRelative) { ! 212: *x = v->x + *oldx; ! 213: *y = v->y + *oldy; ! 214: } ! 215: else { ! 216: *x = v->x + xbase; ! 217: *y = v->y + ybase; ! 218: } ! 219: /* XXX - ignore VertexCurved for now */ ! 220: /* XXX - ignore VertexDrawLastPoint for now */ ! 221: oldx = x; ! 222: oldy = y; ! 223: x++; ! 224: y++; ! 225: v++; ! 226: } while (--vc > 0); ! 227: ! 228: /* switch (PTYPE(tile)) { ! 229: case BitmapPixmap: ! 230: fprintf(stderr,"DrawFilled: BitmapPixmap\n"); ! 231: return; ! 232: case XYColorPixmap: ! 233: fprintf(stderr,"DrawFilled: XYColorPixmap\n"); ! 234: return; ! 235: case ZColorPixmap: ! 236: fprintf(stderr,"DrawFilled: ZColorPixmap\n"); ! 237: return; ! 238: case ConstantPixmap: ! 239: fprintf(stderr,"DrawFilled: ConstantPixmap\n"); ! 240: break; ! 241: } ! 242: /* set drawing color based on invert flag ^ tiling value */ ! 243: /*data ^= PINVERT(tile); */ ! 244: gpr_$set_fill_value((gpr_$pixel_value_t)srcpix, status); ! 245: set_zmask( zmask ); ! 246: do { ! 247: x = savx; y = savy; ! 248: GetNextClip(clips, cwindow); ! 249: CheckCursor(cwindow.x_coord, cwindow.y_coord, ! 250: cwindow.x_size, cwindow.y_size); ! 251: gpr_$set_clip_window( cwindow, status); ! 252: gpr_$start_pgon((short)*x, (short)*y, status); ! 253: check_status( status, "DrawFilled"); ! 254: gpr_$pgon_polyline( *x, *y, (short)vertcount, status); ! 255: check_status( status, "DrawFilled"); ! 256: gpr_$close_fill_pgon( status ); ! 257: check_status( status, "DrawFilled"); ! 258: } while (--clipcount > 0); ! 259: RestoreCursor(); ! 260: free(x); ! 261: free(y); ! 262: } ! 263: ! 264: cache_tile(tile, twidth, theight) ! 265: PIXMAP *tile; ! 266: int *twidth, *theight; ! 267: { ! 268: gpr_$bitmap_desc_t bm; ! 269: long ptr; ! 270: int line_width; ! 271: status_$t status; ! 272: boolean flag; ! 273: gpr_$window_t srcwin; ! 274: gpr_$position_t dstorg; ! 275: ! 276: flag = gpr_$acquire_display(status); ! 277: gpr_$set_bitmap(TileBM, status); ! 278: gpr_$set_raster_op( (short)0, (short)3, status); ! 279: old_op = -1; ! 280: srcwin.x_coord = 0; ! 281: srcwin.x_size = *twidth; ! 282: srcwin.y_coord = 0; ! 283: srcwin.y_size = *theight; ! 284: dstorg.y_coord = 0; ! 285: dstorg.x_coord = 0; ! 286: gpr_$pixel_blt(tile->data->data, srcwin, dstorg, status); ! 287: dstorg.x_coord = *twidth; ! 288: gpr_$pixel_blt(tile->data->data, srcwin, dstorg, status); ! 289: ! 290: *twidth = *twidth * 2; ! 291: srcwin.x_coord = 0; ! 292: srcwin.x_size = *twidth; ! 293: srcwin.y_coord = 0; ! 294: srcwin.y_size = *theight; ! 295: dstorg.y_coord = *theight; ! 296: dstorg.x_coord = 0; ! 297: gpr_$pixel_blt(TileBM, srcwin, dstorg, status); ! 298: gpr_$set_bitmap(Screen.bm, status); ! 299: *theight = *theight * 2; ! 300: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.