|
|
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: /* $Header: mfbpolypnt.c,v 1.13 87/09/11 07:48:39 toddb Exp $ */
25:
26: #include "X.h"
27: #include "Xprotostr.h"
28: #include "pixmapstr.h"
29: #include "gcstruct.h"
30: #include "windowstr.h"
31: #include "miscstruct.h"
32: #include "regionstr.h"
33: #include "scrnintstr.h"
34:
35: #include "mfb.h"
36: #include "maskbits.h"
37:
38: /* macro for checking a point in a box
39: note that this also tosses out negative coordinates
40: */
41: #define PointInBox(pbox, x, y) \
42: (((x) >= (pbox)->x1) && ((x) < (pbox)->x2) && \
43: ((y) >= (pbox)->y1) && ((y) < (pbox)->y2)) \
44: ? 1 : 0
45:
46: void
47: mfbPolyPoint(pDrawable, pGC, mode, npt, pptInit)
48: DrawablePtr pDrawable;
49: GCPtr pGC;
50: int mode; /* Origin or Previous */
51: int npt;
52: xPoint *pptInit;
53: {
54:
55: BoxPtr pboxInit;
56: int nboxInit;
57: register BoxPtr pbox;
58: register int nbox;
59: int xorg;
60: int yorg;
61:
62: int *addrlBase;
63: register int *addrl;
64: int nlwidth;
65:
66: int nptTmp;
67: register xPoint *ppt;
68:
69: register int x;
70: register int y;
71: register int rop;
72:
73: if (!(pGC->planemask & 1))
74: return;
75:
76: pboxInit = ((mfbPrivGC *)(pGC->devPriv))->pCompositeClip->rects;
77: nboxInit = ((mfbPrivGC *)(pGC->devPriv))->pCompositeClip->numRects;
78: rop = ((mfbPrivGC *)(pGC->devPriv))->rop;
79:
80: if (pDrawable->type == DRAWABLE_WINDOW)
81: {
82: xorg = ((WindowPtr)pDrawable)->absCorner.x;
83: yorg = ((WindowPtr)pDrawable)->absCorner.y;
84: addrlBase = (int *)
85: (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devPrivate);
86: nlwidth = (int)
87: (((PixmapPtr)(pDrawable->pScreen->devPrivate))->devKind) >> 2;
88: }
89: else
90: {
91: xorg = 0;
92: yorg = 0;
93: addrlBase = (int *)(((PixmapPtr)pDrawable)->devPrivate);
94: nlwidth = (int)(((PixmapPtr)pDrawable)->devKind) >> 2;
95: }
96:
97: /* translate the point list
98: do this here rather than in the loop because there are
99: two cases to deal with
100: */
101: ppt = pptInit;
102: nptTmp = npt;
103: if (mode == CoordModeOrigin)
104: {
105: while(nptTmp--)
106: {
107: ppt->x += xorg;
108: ppt++->y += yorg;
109: }
110: }
111: else
112: {
113: ppt->x += xorg;
114: ppt->y += yorg;
115: nptTmp--;
116: while(nptTmp--)
117: {
118: ppt++;
119: ppt->x += (ppt-1)->x;
120: ppt->y += (ppt-1)->y;
121: }
122: }
123:
124: ppt = pptInit;
125: /* NOTE
126: the if(rop) could be moved outside of the loop, at
127: the cost of having three times as much code.
128: */
129: while (npt--)
130: {
131: nbox = nboxInit;
132: pbox = pboxInit;
133: x = ppt->x;
134: y = ppt++->y;
135:
136: while(nbox--)
137: {
138: if (PointInBox(pbox, x, y))
139: {
140: addrl = addrlBase +
141: (y * nlwidth) +
142: (x >> 5);
143:
144: if (rop == RROP_BLACK)
145: *addrl &= rmask[x & 0x1f];
146: else if (rop == RROP_WHITE)
147: *addrl |= mask[x & 0x1f];
148: else if (rop == RROP_INVERT)
149: *addrl ^= mask[x & 0x1f];
150:
151: break;
152: }
153: else
154: pbox++;
155: }
156: }
157: }
158:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.