|
|
1.1 root 1: #ifndef lint
2: static char *rcsid_put_c = "$Header: put.c,v 10.1 86/11/19 10:43:52 jg Exp $";
3: #endif lint
4: /* Copyright 1985 Massachusetts Institute of Technology */
5:
6: /* put.c - Perform a raster operation with a source bitmap
7: *
8: * PixmapPut Puts a pixmap up on the screen
9: * PixmapBitsPut Puts masked region of pixmap up on screen
10: * BitmapBitsPut Puts masked region of bitmap up on screen
11: *
12: * Author:
13: * Scott Bates
14: * Brown University
15: * IRIS, Box 1946
16: * Providence, RI 02912
17: *
18: *
19: * Copyright (c) 1986 Brown University
20: *
21: * Permission to use, copy, modify and distribute this software and its
22: * documentation for any purpose and without fee is hereby granted, provided
23: * that the above copyright notice appear in all copies, and that both
24: * that copyright notice and this permission notice appear in supporting
25: * documentation, and that the name of Brown University not be used in
26: * advertising or publicity pertaining to distribution of the software
27: * without specific, written prior permission. Brown University makes no
28: * representations about the suitability of this software for any purpose.
29: * It is provided "as-is" without express or implied warranty.
30: */
31:
32: #include "private.h"
33: #include "bitblt.h"
34:
35: /*
36: * Copy pixmap to screen
37: */
38:
39: PixmapPut (src, srcx, srcy, width, height, dstx, dsty, clips, clipcount,
40: func, zmask)
41: PIXMAP *src;
42: register width, height;
43: int srcx, srcy;
44: register dstx, dsty;
45: int clipcount, zmask;
46: register func;
47: CLIP *clips;
48: {
49: register Blt_Rectangle *dest = &DstRect;
50:
51: #ifdef TRACE_X
52: fprintf(stderr, "In PixmapPut\n");
53: fflush(stderr);
54: #endif TRACE_X
55:
56: /*
57: * There better be at least one plane
58: */
59:
60: if ((zmask & 1) == 0)
61: return;
62:
63: /*
64: * If pixmap needs to be inverted before being displayed
65: * remap funtion to reflect this change.
66: */
67:
68: func = SSMap[func | (src->kind & InvertFlag)];
69:
70: /*
71: * Fill in destination rectangle
72: */
73:
74: FillInRect(dstx, dsty, width, height, dest);
75:
76: /*
77: * If pixmap has no associated bitmap determine which constant
78: * tile to use and tile the destination. Otherwise, copy bitmap
79: * to screen destination.
80: */
81:
82: if (PTYPE(src) == ConstantPixmap) {
83:
84: /*
85: * Tile screen destination
86: */
87:
88: CopyBits ((u_short *) src->data, NIL, NIL, NILRECT,
89: (u_short *) pbm.data, pbm.width, pbm.height, dest,
90: NILMASK, NIL, NIL, MAKE_TILE_RULE(func),
91: clipcount, clips);
92: } else {
93: register Blt_Rectangle *source = &SrcRect;
94: register BITMAP *bm = (BITMAP *) src->data;
95:
96: /*
97: * Fill in source rectangle
98: */
99:
100: FillInRect(srcx, srcy, width, height, source);
101:
102: /*
103: * Copy bitmap to screen
104: */
105:
106: CopyBits ((u_short *)bm->data, bm->width, bm->height, source,
107: (u_short *)pbm.data, pbm.width, pbm.height, dest,
108: NILMASK, NIL, NIL, func, clipcount, clips);
109: }
110: }
111:
112: /*
113: * Copy pixmap to screen using a mask
114: */
115:
116: /*ARGSUSED*/
117: PixmapBitsPut (width, height, format, data, xymask, dstx, dsty,
118: clips, clipcount, func, zmask)
119: char *data;
120: int width, height, format, dstx, dsty, clipcount, zmask;
121: BITMAP *xymask;
122: CLIP *clips;
123: int func;
124: {
125: #ifdef TRACE_X
126: fprintf(stderr, "In PixmapBitsPut\n");
127: fflush(stderr);
128: #endif TRACE_X
129:
130: /*
131: * Since this hardware has only one bit plane PixmapBitsPut
132: * and BitmapBitsPut are the same.
133: */
134:
135: BitmapBitsPut (width, height, data, 1, 0, xymask, dstx, dsty,
136: clips, clipcount, func, zmask);
137: }
138:
139: /*
140: * Copy bitmap to screen using a mask
141: */
142:
143: BitmapBitsPut (width, height, data, fore, back, xymask, dstx, dsty,
144: clips, clipcount, func, zmask)
145: char *data;
146: register width, height, dstx, dsty;
147: int fore, back, clipcount, zmask;
148: BITMAP *xymask;
149: CLIP *clips;
150: register func;
151: {
152: register Blt_Rectangle *source = &SrcRect;
153: register Blt_Rectangle *dest = &DstRect;
154: int new_width, new_height;
155: u_short *clipmask;
156:
157: #ifdef TRACE_X
158: fprintf(stderr, "In BitmapBitsPut\n");
159: fflush(stderr);
160: #endif TRACE_X
161:
162: /*
163: * There better be at least one plane
164: */
165:
166: if ((zmask & 1) == 0)
167: return;
168:
169: /*
170: * Change function to reflect desired foreground and
171: * background colors
172: */
173:
174: if (fore & 1)
175: func += 0x20;
176: if (back & 1)
177: func += 0x10;
178: func = FBMap[func];
179:
180: /*
181: * Reverse bits in each short of the image data. Image data
182: * recieved from the client is in VAX bit order and needs to
183: * be reversed for this hardware.
184: */
185:
186: ReverseShortBits((u_short *) data, BitmapSize(width, height) >> 1);
187:
188: /*
189: * Clip xymask and destnation rectangle to minimum size
190: */
191:
192: if(xymask) {
193: new_width = MIN (xymask->width, width);
194: new_height = MIN (xymask->height, height);
195: clipmask = (u_short *) xymask->data;
196: } else {
197: new_width = width;
198: new_height = height;
199: clipmask = NILMASK;
200: }
201:
202: /*
203: * Fill in source and destination rectangles
204: */
205:
206: FillInRect(0, 0, width, height, source);
207: FillInRect(dstx, dsty, new_width, new_height, dest);
208:
209: /*
210: * Copy bitmap to screen using a mask
211: */
212:
213: CopyBits ((u_short *) data, width, height, source,
214: (u_short *) pbm.data, pbm.width, pbm.height, dest,
215: clipmask, new_width, new_height, func, clipcount, clips);
216: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.