|
|
1.1 root 1: #ifndef lint
2: static char *rcsid_put_c = "$Header: put.c,v 10.1 86/11/29 13:52:41 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: /* put.c Perform a raster operation with a source bitmap
24: *
25: * PixmapPut Puts a pixmap up on the screen
26: * PixmapBitsPut Puts a pixmap up on the screen
27: * BitmapBitsPut Puts a pixmap up on the screen
28: *
29: */
30:
31: /*
32: * ToDo:
33: * masks & XY format Pixmaps
34: */
35:
36: #include "Xapollo.h"
37:
38: #define GPIXARY_SIZE 2048
39: status_$t status;
40: long gpixary[GPIXARY_SIZE];
41:
42: char *Xalloc();
43:
44: PixmapPut (src, srcx, srcy, width, height, dstx, dsty, clips, clipcount,
45: op, zmask)
46: register PIXMAP *src;
47: int srcx, srcy, width, height, dstx, dsty, clipcount, zmask;
48: register int op;
49: CLIP *clips;
50: {
51: gpr_$position_t dest;
52: gpr_$window_t sou, cwindow;
53: int cleft, ctop, cwidth, cheight;
54: int i;
55:
56: set_zmask(zmask);
57: set_op( op );
58: switch (PTYPE(src)) {
59: case BitmapPixmap:
60: {
61: BITMAP *bm = (BITMAP *) src->data;
62: do {
63:
64: GetNextClip(clips, cwindow);
65: if (OverLap(cwindow, dstx, dsty, width, height))
66: {
67: CheckCursor(dstx, dsty, width, height);
68: gpr_$set_clip_window( cwindow, status);
69: sou.x_coord = srcx;
70: sou.y_coord = srcy;
71: sou.x_size = width;
72: sou.y_size = height;
73: dest.x_coord = dstx;
74: dest.y_coord = dsty;
75: gpr_$pixel_blt((gpr_$bitmap_desc_t)bm->data, sou, dest, status);
76: }
77: } while (--clipcount > 0);
78: }
79: break;
80: case ConstantPixmap:
81: do {
82:
83: GetNextClip(clips, cwindow);
84: if (OverLap(cwindow, dstx, dsty, width, height))
85: {
86: CheckCursor(dstx, dsty, width, height);
87: /* Not yet implemented */
88: }
89: } while (--clipcount > 0);
90: break;
91: case ZColorPixmap:
92: gpr_$set_plane_mask((gpr_$mask_t)(zmask & Screen.plane_mask), status);
93: do {
94:
95: GetNextClip(clips, cwindow);
96: /* Not yet implemented */
97:
98: } while (--clipcount > 0);
99: break;
100: case XYColorPixmap:
101: /* Not yet implemented */
102: break;
103: }
104: RestoreCursor();
105: }
106:
107:
108: /*ARGSUSED*/
109: PixmapBitsPut (width, height, format, data, xymask, dstx, dsty,
110: clips, clipcount, func, zmask)
111: unsigned char *data;
112: int width, height, format, dstx, dsty, clipcount, zmask;
113: BITMAP *xymask;
114: CLIP *clips;
115: int func;
116: {
117: if (Screen.depth == 1)
118: BitsPut(width, height, data, 1, 0, xymask, dstx, dsty,
119: clips, clipcount, func, zmask, 1);
120: else if (Screen.depth <= 8)
121: switch (format) {
122: case ZFormat: {
123: gpr_$window_t dstwin;
124: long *pixary, *p, *mask_ary;
125: int i, j, size;
126:
127: dstwin.x_coord = dstx;
128: dstwin.x_size = width;
129: dstwin.y_coord = dsty;
130: dstwin.y_size = height;
131: if ((size = width*height) > GPIXARY_SIZE)
132: pixary = (long *)malloc(size * 4);
133: else
134: pixary = gpixary;
135: if (xymask) {
136: mask_ary = malloc(size*4);
137: gpr_$set_bitmap( xymask->data, status);
138: gpr_$read_pixels( *mask_ary, dstwin, status);
139: gpr_$set_bitmap(Screen.bm, status);
140: gpr_$read_pixels( *pixary, dstwin, status);
141: }
142: p = pixary;
143: for (i=0;i<width;i++)
144: for (j=0;j<height;j++)
145: if (xymask && !(*mask_ary++))
146: continue;
147: *p++ = *data++;
148: gpr_$write_pixels(*pixary, dstwin, status);
149: check_status(status, "PixmapBitsput");
150: if (size > GPIXARY_SIZE)
151: free(pixary);
152: break;
153: }
154: break;
155: case XYFormat:
156: /* Not yet supported */
157: break;
158: }
159:
160: }
161:
162: BitmapBitsPut (width, height, data, fore, back, xymask, dstx, dsty,
163: clips, clipcount, func, zmask)
164: char *data;
165: int width, height, fore, back, dstx, dsty, clipcount, zmask;
166: register BITMAP *xymask;
167: CLIP *clips;
168: register int func;
169: {
170: InvertPixelOrder((short *) data, BitmapSize(width, height) >> 1);
171: BitsPut(width, height, data, fore, back, xymask, dstx, dsty,
172: clips, clipcount, func, zmask, 1);
173: }
174:
175: static
176: BitsPut (width, height, data, fore, back, xymask, dstx, dsty,
177: clips, clipcount, func, zmask, srcdepth)
178: char *data;
179: int width, height, fore, back, dstx, dsty, clipcount, zmask;
180: register BITMAP *xymask;
181: CLIP *clips;
182: register int func;
183: int srcdepth;
184: {
185: extern char FBMap[];
186: extern int old_op;
187: gpr_$window_t srcwin, cwindow;
188: gpr_$position_t dstorg;
189: gpr_$plane_t dplane = 0;
190: BITMAP *bm;
191: int op;
192:
193: if ((Screen.depth == 1) && !(zmask & 1))
194: return;
195: if (fore & 1)
196: func += 0x20;
197: if (back & 1)
198: func += 0x10;
199:
200: srcwin.x_coord = 0;
201: srcwin.y_coord = 0;
202: srcwin.x_size = width;
203: srcwin.y_size = height;
204: dstorg.x_coord = dstx;
205: dstorg.y_coord = dsty;
206: bm = make_bitmap( data, width, height, NULL);
207: func = FBMap[func];
208: CheckCursor(dstx, dsty, dstx+width, dsty+height);
209: if (xymask == NULL) {
210: gpr_$set_raster_op((gpr_$plane_t)0, (gpr_$raster_op_t)func, status);
211: do {
212: GetNextClip(clips, cwindow);
213: gpr_$set_clip_window( cwindow, status);
214: gpr_$bit_blt(bm->data, srcwin, (gpr_$plane_t)0,
215: dstorg, (gpr_$plane_t)dplane, status);
216: check_status(status, "BitsPut: ");
217: } while (--clipcount > 0);
218: old_op = func;
219: }
220: else {
221: /* this is slightly bogus and doesn't work correctly, but without it icons are
222: * invisible
223: */
224: int botop = (back == 0 ? 7 : 4);
225: int topop = (fore == 0 ? 7 : 4);
226:
227: do {
228: GetNextClip(clips, cwindow);
229: CheckCursor(cwindow.x_coord, cwindow.y_coord,
230: cwindow.x_size, cwindow.y_size);
231: gpr_$set_clip_window( cwindow, status);
232: gpr_$set_raster_op((gpr_$plane_t)0, botop, status);
233: gpr_$bit_blt(xymask->data, srcwin, (gpr_$plane_t)0, dstorg,
234: dplane, status);
235: gpr_$set_raster_op((gpr_$plane_t)0, (short)3, status);
236: gpr_$bit_blt(bm->data, srcwin, (gpr_$plane_t)0, dstorg,
237: (gpr_$plane_t)dplane, status);
238: } while (--clipcount);
239: old_op = topop;
240: }
241: FreeBitmap(bm);
242: RestoreCursor();
243: return;
244: }
245:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.