|
|
1.1 root 1: /***********************************************************
2: Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
3: and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
4:
5: All Rights Reserved
6:
7: Permission to use, copy, modify, and distribute this software and its
8: documentation for any purpose and without fee is hereby granted,
9: provided that the above copyright notice appear in all copies and that
10: both that copyright notice and this permission notice appear in
11: supporting documentation, and that the names of Digital or MIT not be
12: used in advertising or publicity pertaining to distribution of the
13: software without specific, written prior permission.
14:
15: DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
16: ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
17: DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
18: ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
19: WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
20: ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
21: SOFTWARE.
22:
23: ******************************************************************/
24:
25: #include "X.h"
26:
27: #include "windowstr.h"
28: #include "regionstr.h"
29: #include "pixmapstr.h"
30: #include "scrnintstr.h"
31:
32: #include "cfb.h"
33: #include "cfbmskbits.h"
34: /*
35: NOTE
36: PaintArea32() doesn't need to rotate the tile, since
37: cfbPositionWIndow() and cfbChangeWIndowAttributes() do it;
38: cfbPaintAreaOther(), however, needs to rotate things.
39: */
40:
41: /* Paint Area None -- just return */
42: void
43: cfbPaintAreaNone(pWin, pRegion, what)
44: WindowPtr pWin;
45: RegionPtr pRegion;
46: int what;
47: {
48: if ( pWin->drawable.depth != PSZ )
49: FatalError( "cfbPaintAreaNone: invalid depth\n" );
50: }
51:
52: /* Paint Area Parent Relative -- Find first ancestor which isn't parent
53: * relative and paint as it would, but with this region */
54: void
55: cfbPaintAreaPR(pWin, pRegion, what)
56: WindowPtr pWin;
57: RegionPtr pRegion;
58: int what;
59: {
60: WindowPtr pParent;
61:
62: if ( pWin->drawable.depth != PSZ )
63: FatalError( "cfbPaintAreaPR: invalid depth\n" );
64:
65: pParent = pWin->parent;
66: while(pParent->backgroundTile == (PixmapPtr)ParentRelative)
67: pParent = pParent->parent;
68:
69: if(what == PW_BORDER)
70: (*pParent->PaintWindowBorder)(pParent, pRegion, what);
71: else
72: (*pParent->PaintWindowBackground)(pParent, pRegion, what);
73: }
74:
75: void
76: cfbPaintAreaSolid(pWin, pRegion, what)
77: WindowPtr pWin;
78: RegionPtr pRegion;
79: int what;
80: {
81: int nbox; /* number of boxes to fill */
82: register BoxPtr pbox; /* pointer to list of boxes to fill */
83: register int srcpix;/* source pixel of the window */
84:
85: PixmapPtr pPixmap;
86: int nlwScreen; /* width in longwords of the screen's pixmap */
87: int w; /* width of current box */
88: register int h; /* height of current box */
89: int startmask;
90: int endmask; /* masks for reggedy bits at either end of line */
91: int nlwMiddle; /* number of longwords between sides of boxes */
92: register int nlwExtra;
93: /* to get from right of box to left of next span */
94: register int nlw; /* loop version of nlwMiddle */
95: register int *p; /* pointer to bits we're writing */
96: int *pbits; /* pointer to start of screen */
97:
98: if ( pWin->drawable.depth != PSZ )
99: FatalError( "cfbPaintAreaSolid: invalid depth\n" );
100:
101: if (what == PW_BACKGROUND)
102: {
103: srcpix = PFILL(pWin->backgroundPixel);
104: }
105: else
106: {
107: srcpix = PFILL(pWin->borderPixel);
108: }
109:
110: pPixmap = (PixmapPtr)(pWin->drawable.pScreen->devPrivate);
111: pbits = (int *)pPixmap->devPrivate;
112: nlwScreen = (pPixmap->devKind) >> 2;
113: nbox = pRegion->numRects;
114: pbox = pRegion->rects;
115:
116: while (nbox--)
117: {
118: w = pbox->x2 - pbox->x1;
119: h = pbox->y2 - pbox->y1;
120: p = pbits + (pbox->y1 * nlwScreen) + (pbox->x1 >> PWSH);
121:
122: if ( ((pbox->x1 & PIM) + w) < PPW)
123: {
124: maskpartialbits(pbox->x1, w, startmask);
125: nlwExtra = nlwScreen;
126: while (h--)
127: {
128: *p = (*p & ~startmask) | (srcpix & startmask);
129: p += nlwExtra;
130: }
131: }
132: else
133: {
134: maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
135: nlwExtra = nlwScreen - nlwMiddle;
136:
137: if (startmask && endmask)
138: {
139: nlwExtra -= 1;
140: while (h--)
141: {
142: nlw = nlwMiddle;
143: *p = (*p & ~startmask) | (srcpix & startmask);
144: p++;
145: while (nlw--)
146: *p++ = srcpix;
147: *p = (*p & ~endmask) | (srcpix & endmask);
148: p += nlwExtra;
149: }
150: }
151: else if (startmask && !endmask)
152: {
153: nlwExtra -= 1;
154: while (h--)
155: {
156: nlw = nlwMiddle;
157: *p = (*p & ~startmask) | (srcpix & startmask);
158: p++;
159: while (nlw--)
160: *p++ = srcpix;
161: p += nlwExtra;
162: }
163: }
164: else if (!startmask && endmask)
165: {
166: while (h--)
167: {
168: nlw = nlwMiddle;
169: while (nlw--)
170: *p++ = srcpix;
171: *p = (*p & ~endmask) | (srcpix & endmask);
172: p += nlwExtra;
173: }
174: }
175: else /* no ragged bits at either end */
176: {
177: while (h--)
178: {
179: nlw = nlwMiddle;
180: while (nlw--)
181: *p++ = srcpix;
182: p += nlwExtra;
183: }
184: }
185: }
186: pbox++;
187: }
188: }
189:
190: /* Tile area with a 32 bit wide tile */
191: void
192: cfbPaintArea32(pWin, pRegion, what)
193: WindowPtr pWin;
194: RegionPtr pRegion;
195: int what;
196: {
197: int nbox; /* number of boxes to fill */
198: register BoxPtr pbox; /* pointer to list of boxes to fill */
199: int srcpix;
200: int *psrc; /* pointer to bits in tile, if needed */
201: int tileHeight; /* height of the tile */
202:
203: PixmapPtr pPixmap;
204: int nlwScreen; /* width in longwords of the screen's pixmap */
205: int w; /* width of current box */
206: register int h; /* height of current box */
207: int startmask;
208: int endmask; /* masks for reggedy bits at either end of line */
209: int nlwMiddle; /* number of longwords between sides of boxes */
210: register int nlwExtra;
211: /* to get from right of box to left of next span */
212:
213: register int nlw; /* loop version of nlwMiddle */
214: register int *p; /* pointer to bits we're writing */
215: int y; /* current scan line */
216:
217:
218: int *pbits; /* pointer to start of screen */
219: cfbPrivWin *pPrivWin;
220:
221: if ( pWin->drawable.depth != PSZ )
222: FatalError( "cfbPaintArea32: invalid depth\n" );
223:
224: pPrivWin = (cfbPrivWin *)(pWin->devPrivate);
225:
226: if (what == PW_BACKGROUND)
227: {
228: tileHeight = pWin->backgroundTile->height;
229: psrc = (int *)(pPrivWin->pRotatedBackground->devPrivate);
230: }
231: else
232: {
233: tileHeight = pWin->borderTile->height;
234: psrc = (int *)(pPrivWin->pRotatedBorder->devPrivate);
235: }
236:
237: pPixmap = (PixmapPtr)(pWin->drawable.pScreen->devPrivate);
238: pbits = (int *)pPixmap->devPrivate;
239: nlwScreen = (pPixmap->devKind) >> 2;
240: nbox = pRegion->numRects;
241: pbox = pRegion->rects;
242:
243: while (nbox--)
244: {
245: w = pbox->x2 - pbox->x1;
246: h = pbox->y2 - pbox->y1;
247: y = pbox->y1;
248: p = pbits + (pbox->y1 * nlwScreen) + (pbox->x1 >> PWSH);
249:
250: if ( ((pbox->x1 & PIM) + w) < PPW)
251: {
252: maskpartialbits(pbox->x1, w, startmask);
253: nlwExtra = nlwScreen;
254: while (h--)
255: {
256: if (tileHeight)
257: {
258: srcpix = psrc[y%tileHeight];
259: y++;
260: }
261: *p = (*p & ~startmask) | (srcpix & startmask);
262: p += nlwExtra;
263: }
264: }
265: else
266: {
267: maskbits(pbox->x1, w, startmask, endmask, nlwMiddle);
268: nlwExtra = nlwScreen - nlwMiddle;
269:
270: if (startmask && endmask)
271: {
272: nlwExtra -= 1;
273: while (h--)
274: {
275: if (tileHeight)
276: {
277: srcpix = psrc[y%tileHeight];
278: y++;
279: }
280: nlw = nlwMiddle;
281: *p = (*p & ~startmask) | (srcpix & startmask);
282: p++;
283: while (nlw--)
284: *p++ = srcpix;
285: *p = (*p & ~endmask) | (srcpix & endmask);
286: p += nlwExtra;
287: }
288: }
289: else if (startmask && !endmask)
290: {
291: nlwExtra -= 1;
292: while (h--)
293: {
294: if (tileHeight)
295: {
296: srcpix = psrc[y%tileHeight];
297: y++;
298: }
299: nlw = nlwMiddle;
300: *p = (*p & ~startmask) | (srcpix & startmask);
301: p++;
302: while (nlw--)
303: *p++ = srcpix;
304: p += nlwExtra;
305: }
306: }
307: else if (!startmask && endmask)
308: {
309: while (h--)
310: {
311: if (tileHeight)
312: {
313: srcpix = psrc[y%tileHeight];
314: y++;
315: }
316: nlw = nlwMiddle;
317: while (nlw--)
318: *p++ = srcpix;
319: *p = (*p & ~endmask) | (srcpix & endmask);
320: p += nlwExtra;
321: }
322: }
323: else /* no ragged bits at either end */
324: {
325: while (h--)
326: {
327: if (tileHeight)
328: {
329: srcpix = psrc[y%tileHeight];
330: y++;
331: }
332: nlw = nlwMiddle;
333: while (nlw--)
334: *p++ = srcpix;
335: p += nlwExtra;
336: }
337: }
338: }
339: pbox++;
340: }
341: }
342:
343: void
344: cfbPaintAreaOther(pWin, pRegion, what)
345: WindowPtr pWin;
346: RegionPtr pRegion;
347: int what;
348:
349: {
350: int nbox; /* number of boxes to fill */
351: register BoxPtr pbox; /* pointer to list of boxes to fill */
352: int tileHeight; /* height of the tile */
353: int tileWidth; /* width of the tile */
354:
355: PixmapPtr pPixmap;
356: int w; /* width of current box */
357: register int h; /* height of current box */
358: int x, y; /* current scan line */
359: int height, width;
360:
361: if ( pWin->drawable.depth != PSZ )
362: FatalError( "cfbPaintAreaOther: invalid depth\n" );
363:
364: if (what == PW_BACKGROUND)
365: {
366: tileHeight = pWin->backgroundTile->height;
367: tileWidth = pWin->backgroundTile->width;
368: pPixmap = pWin->backgroundTile;
369: }
370: else
371: {
372: tileHeight = pWin->borderTile->height;
373: tileWidth = pWin->borderTile->width;
374: pPixmap = pWin->borderTile;
375: }
376:
377: nbox = pRegion->numRects;
378: pbox = pRegion->rects;
379:
380: while (nbox--)
381: {
382: w = pbox->x2;
383: h = pbox->y2;
384:
385: if ( w - pbox->x1 <= PPW)
386: {
387: y = pbox->y1;
388: x = pbox->x1;
389: width = min(tileWidth, w - x);
390: while ((height = h - y) > 0)
391: {
392: height = min(height, tileHeight);
393: cfbTileOddWin(pPixmap, pWin, width, height, x, y);
394: y += tileHeight;
395: }
396: }
397: else
398: {
399: y = pbox->y1;
400: while((height = h - y) > 0)
401: {
402: height = min(height, tileHeight);
403: x = pbox->x1;
404: while ((width = w - x) > 0)
405: {
406: width = min(tileWidth, width);
407: cfbTileOddWin(pPixmap, pWin, width, height, x, y);
408: x += tileWidth;
409: }
410: y += tileHeight;
411: }
412: }
413: pbox++;
414: }
415: }
416:
417:
418:
419: cfbTileOddWin(pSrc, pDstWin, tileWidth, tileHeight, x, y)
420: PixmapPtr pSrc; /* pointer to src tile */
421: WindowPtr pDstWin; /* pointer to dest window */
422: int tileWidth; /* width of tile */
423: int tileHeight; /* height of tile */
424: int x; /* destination x */
425: int y; /* destination y */
426:
427: {
428: int *psrcLine, *pdstLine;
429: register int *pdst, *psrc;
430: register int nl;
431: register int tmpSrc;
432: int widthSrc, widthDst, nlMiddle, startmask, endmask;
433: PixmapPtr pDstPixmap;
434:
435:
436: psrcLine = (int *)pSrc->devPrivate;
437:
438: pDstPixmap = (PixmapPtr)pDstWin->drawable.pScreen->devPrivate;
439: widthDst = (int)pDstPixmap->devKind >> 2;
440: pdstLine = (int *)pDstPixmap->devPrivate + (y * widthDst);
441: widthSrc = (int)pSrc->devKind >> 2;
442:
443: if(tileWidth <= PPW)
444: {
445: int dstBit;
446:
447: psrc = psrcLine;
448: pdst = pdstLine + (x / PPW);
449: dstBit = x & PIM;
450:
451: while(tileHeight--)
452: {
453: getbits(psrc, 0, tileWidth, tmpSrc);
454: /*XXX*/ putbits(tmpSrc, dstBit, tileWidth, pdst, -1);
455: pdst += widthDst;
456: psrc += widthSrc;
457: }
458:
459: }
460: else
461: {
462: register int xoffSrc; /* offset (>= 0, < 32) from which to
463: * fetch whole longwords fetched in src */
464: int nstart; /* number of ragged bits at start of dst */
465: int nend; /* number of regged bits at end of dst */
466: int srcStartOver; /* pulling nstart bits from src overflows
467: * into the next word? */
468:
469: maskbits(x, tileWidth, startmask, endmask, nlMiddle);
470: if (startmask)
471: nstart = PPW - (x & PIM);
472: else
473: nstart = 0;
474: if (endmask)
475: nend = (x + tileWidth) & PIM;
476:
477: xoffSrc = nstart & PIM;
478: srcStartOver = nstart > PLST;
479:
480: pdstLine += (x >> PWSH);
481:
482: while (tileHeight--)
483: {
484: psrc = psrcLine;
485: pdst = pdstLine;
486:
487: if (startmask)
488: {
489: getbits(psrc, 0, nstart, tmpSrc);
490: /*XXX*/ putbits(tmpSrc, (x & PIM), nstart, pdst, -1);
491: pdst++;
492: #ifdef notdef
493: /* XXX - not sure if this is right or not DSHR */
494: if (srcStartOver)
495: psrc++;
496: #endif
497: }
498:
499: nl = nlMiddle;
500: while (nl--)
501: {
502: getbits(psrc, xoffSrc, PPW, tmpSrc);
503: *pdst++ = tmpSrc;
504: psrc++;
505: }
506:
507: if (endmask)
508: {
509: getbits(psrc, xoffSrc, nend, tmpSrc);
510: /*XXX*/ putbits(tmpSrc, 0, nend, pdst, -1);
511: }
512:
513: pdstLine += widthDst;
514: psrcLine += widthSrc;
515: }
516: }
517: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.