|
|
1.1 root 1: /* bitblt routines */
2: #include "jerq.h"
3:
4: void
5: bitblt (sb, r, db, p, f)
6: Bitmap *sb, *db;
7: Rectangle r; /* in source bitmap */
8: Point p; /* in dest bitmap */
9: Code f;
10: {
11: int wd = r.corner.x - r.origin.x;
12: int ht = r.corner.y - r.origin.y;
13:
14: if(sb->flag & BI_OFFSCREEN)
15: r.origin = sub(r.origin, sb->rect.origin);
16: if(db->flag & BI_OFFSCREEN)
17: p = sub(p, db->rect.origin);
18: #ifdef X11
19: XSetFunction(dpy, gc, f);
20: XCopyArea(dpy, sb->dr, db->dr, gc, r.origin.x, r.origin.y,
21: wd, ht, p.x, p.y);
22: #endif X11
23: #ifdef SUNTOOLS
24: if(sb->flag & BI_OFFSCREEN){
25: if(db->flag & BI_OFFSCREEN) /* pr to pr */
26: pr_rop((Pixrect *)db->dr, p.x, p.y, wd, ht, f,
27: (Pixrect *)sb->dr, r.origin.x, r.origin.y);
28: else /* pr to pw */
29: pw_write((Pixwin *)db->dr, p.x, p.y, wd, ht, f,
30: (Pixrect *)sb->dr, r.origin.x, r.origin.y);
31: }
32: else{
33: if(db->flag & BI_OFFSCREEN) /* pw to pr */
34: pw_read((Pixrect *)db->dr, p.x, p.y, wd, ht, f,
35: (Pixwin *)sb->dr, r.origin.x, r.origin.y);
36: else /* pw to pw */
37: pw_copy((Pixwin *)db->dr, p.x, p.y, wd, ht, f,
38: (Pixwin *)sb->dr, r.origin.x, r.origin.y);
39: }
40: #endif SUNTOOLS
41: }
42:
43: void
44: point (b, p, f)
45: Bitmap *b;
46: Point p;
47: Code f;
48: {
49: int i;
50:
51: if(b->flag & BI_OFFSCREEN)
52: p = sub(p, b->rect.origin);
53: #ifdef X11
54: XSetFunction(dpy, gc, f);
55: XDrawPoint(dpy, b->dr, gc, p.x, p.y);
56: #endif X11
57: #ifdef SUNTOOLS
58: switch(f){
59: case F_STORE:
60: case F_OR:
61: if(b->flag & BI_OFFSCREEN)
62: pr_put((Pixrect *)b->dr, p.x, p.y, 1);
63: else
64: pw_put((Pixwin *)b->dr, p.x, p.y, 1);
65: break;
66: case F_CLR:
67: if(b->flag & BI_OFFSCREEN)
68: pr_put((Pixrect *)b->dr, p.x, p.y, 0);
69: else
70: pw_put((Pixwin *)b->dr, p.x, p.y, 0);
71: break;
72: case F_XOR:
73: if(b->flag & BI_OFFSCREEN) {
74: i = pr_get((Pixrect *)b->dr,p.x,p.y);
75: pr_put((Pixrect *)b->dr, p.x, p.y, !i);
76: } else {
77: i = pw_get((Pixwin *)b->dr,p.x,p.y);
78: pw_put((Pixwin *)b->dr, p.x, p.y, !i);
79: }
80: break;
81: }
82: #endif SUNTOOLS
83: }
84:
85: void
86: rectf (b, r, f)
87: Bitmap *b;
88: Rectangle r;
89: Code f;
90: {
91: Point diff;
92:
93: diff = sub(r.corner, r.origin);
94: if(b->flag & BI_OFFSCREEN)
95: r.origin = sub(r.origin, b->rect.origin);
96: #ifdef X11
97: XSetFunction(dpy, gc, f);
98: XFillRectangle(dpy, b->dr, gc,r.origin.x,r.origin.y,diff.x,diff.y);
99: #endif X11
100: #ifdef SUNTOOLS
101: switch(f){
102: case F_STORE:
103: case F_OR:
104: f = PIX_NOT(PIX_SRC);
105: break;
106: case F_CLR:
107: f = PIX_SRC;
108: break;
109: case F_XOR:
110: f = PIX_NOT(PIX_SRC) ^ PIX_DST;
111: break;
112: }
113: if(b->flag & BI_OFFSCREEN)
114: pr_rop((Pixrect *)b->dr, r.origin.x, r.origin.y,
115: diff.x, diff.y, f, 0, 0, 0);
116: else
117: pw_write((Pixwin *)b->dr, r.origin.x, r.origin.y,
118: diff.x, diff.y, f, 0, 0, 0);
119: #endif SUNTOOLS
120: }
121:
122: screenswap (bp, rect, screenrect)
123: register Bitmap *bp;
124: Rectangle rect;
125: Rectangle screenrect;
126: {
127: bitblt(&display, screenrect, bp, rect.origin, F_XOR);
128: bitblt(bp, rect, &display, screenrect.origin, F_XOR);
129: bitblt(&display, screenrect, bp, rect.origin, F_XOR);
130: }
131:
132: void
133: segment (b, p, q, f)
134: Bitmap *b;
135: Point p, q;
136: Code f;
137: {
138: int i;
139:
140: if(b->flag & BI_OFFSCREEN){
141: p = sub(p, b->rect.origin);
142: q = sub(q, b->rect.origin);
143: }
144: #ifdef X11
145: XSetFunction(dpy, gc, f);
146: XDrawLine(dpy, b->dr, gc, p.x, p.y, q.x, q.y);
147: #endif X11
148: #ifdef SUNTOOLS
149: /* Blit compatability - don't set the last pixel */
150: if(b->flag & BI_OFFSCREEN){
151: i = pr_get((Pixrect *)b->dr,q.x,q.y);
152: pr_vector((Pixrect *)b->dr, p.x, p.y, q.x, q.y, f, 1);
153: pr_put((Pixrect *)b->dr, q.x, q.y, i);
154: }
155: else{
156: i = pw_get((Pixwin *)b->dr,q.x,q.y);
157: pw_vector((Pixwin *)b->dr, p.x, p.y, q.x, q.y, f, 1);
158: pw_put((Pixwin *)b->dr, q.x, q.y, i);
159: }
160: #endif SUNTOOLS
161: }
162:
163: void
164: texture (b, r, tile, f)
165: Bitmap *b;
166: Rectangle r;
167: Texture *tile;
168: Code f;
169: {
170: #ifdef SUNTOOLS
171: extern struct pixrectops mem_ops;
172: static struct mpr_data d =
173: {mpr_linebytes(16,1), (short *)0, {0, 0}, 0, 0};
174: static struct pixrect textrect = {&mem_ops, 16, 16, 1, (caddr_t)&d};
175: #endif SUNTOOLS
176: Point diff;
177:
178: diff = sub(r.cor, r.org);
179: if (b->flag & BI_OFFSCREEN)
180: r.org = sub(r.org, b->rect.org);
181: #ifdef X11
182: XSetFunction(dpy, gc, f);
183: XSetFillStyle(dpy, gc, FillTiled);
184: XSetTile(dpy, gc, *tile);
185: XFillRectangle(dpy, b->dr, gc, r.org.x, r.org.y, diff.x, diff.y);
186: XSetFillStyle(dpy, gc, FillSolid);
187: #endif X11
188: #ifdef SUNTOOLS
189: d.md_image = *tile;
190: if(b->flag & BI_OFFSCREEN)
191: pr_replrop((Pixrect *)b->dr, r.origin.x, r.origin.y,
192: diff.x, diff.y, f, &textrect, r.origin.x, r.origin.y);
193: else
194: pw_replrop((Pixwin *)b->dr, r.origin.x, r.origin.y,
195: diff.x, diff.y, f, &textrect, r.origin.x, r.origin.y);
196: #endif SUNTOOLS
197: }
198:
199: void
200: texture32 (b, r, tile, c)
201: Bitmap *b;
202: Rectangle r;
203: Texture32 *tile;
204: Code c;
205: {
206: #ifdef SUNTOOLS
207: extern struct pixrectops mem_ops;
208: static struct mpr_data d =
209: {mpr_linebytes(32,1), (short *)0, {0, 0}, 0, 0};
210: static struct pixrect textrect32 =
211: {&mem_ops, 32, 32, 1, (caddr_t)&d};
212: #endif SUNTOOLS
213: Point diff;
214:
215: diff = sub(r.cor, r.org);
216: if (b->flag & BI_OFFSCREEN)
217: r.org = sub(r.org, b->rect.org);
218: #ifdef X11
219: XSetFunction(dpy, gc, c);
220: XSetFillStyle(dpy, gc, FillTiled);
221: XSetTile(dpy, gc, *tile);
222: XFillRectangle(dpy, b->dr, gc, r.org.x, r.org.y, diff.x, diff.y);
223: XSetFillStyle(dpy, gc, FillSolid);
224: #endif X11
225: #ifdef SUNTOOLS
226: d.md_image = (short *)*tile;
227: if(b->flag & BI_OFFSCREEN)
228: pr_replrop((Pixrect *)b->dr, r.origin.x, r.origin.y,
229: diff.x, diff.y, c, &textrect32, r.origin.x, r.origin.y);
230: else
231: pw_replrop((Pixwin *)b->dr, r.origin.x, r.origin.y,
232: diff.x, diff.y, c, &textrect32, r.origin.x, r.origin.y);
233: #endif SUNTOOLS
234: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.