Commit | Line | Data |
---|---|---|
a09e091a JB |
1 | /* |
2 | * Copyright © 1998 Keith Packard | |
3 | * | |
4 | * Permission to use, copy, modify, distribute, and sell this software and its | |
5 | * documentation for any purpose is hereby granted without fee, provided that | |
6 | * the above copyright notice appear in all copies and that both that | |
7 | * copyright notice and this permission notice appear in supporting | |
8 | * documentation, and that the name of Keith Packard not be used in | |
9 | * advertising or publicity pertaining to distribution of the software without | |
10 | * specific, written prior permission. Keith Packard makes no | |
11 | * representations about the suitability of this software for any purpose. It | |
12 | * is provided "as is" without express or implied warranty. | |
13 | * | |
14 | * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, | |
15 | * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO | |
16 | * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR | |
17 | * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, | |
18 | * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER | |
19 | * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR | |
20 | * PERFORMANCE OF THIS SOFTWARE. | |
21 | */ | |
22 | ||
23 | #ifdef HAVE_DIX_CONFIG_H | |
24 | #include <dix-config.h> | |
25 | #endif | |
26 | ||
27 | #include "fb.h" | |
28 | ||
29 | typedef void (*FbDots) (FbBits * dst, | |
30 | FbStride dstStride, | |
31 | int dstBpp, | |
32 | BoxPtr pBox, | |
33 | xPoint * pts, | |
34 | int npt, | |
35 | int xorg, | |
36 | int yorg, int xoff, int yoff, FbBits and, FbBits xor); | |
37 | ||
38 | void | |
39 | fbDots(FbBits * dstOrig, | |
40 | FbStride dstStride, | |
41 | int dstBpp, | |
42 | BoxPtr pBox, | |
43 | xPoint * pts, | |
44 | int npt, | |
45 | int xorg, int yorg, int xoff, int yoff, FbBits andOrig, FbBits xorOrig) | |
46 | { | |
47 | FbStip *dst = (FbStip *) dstOrig; | |
48 | int x1, y1, x2, y2; | |
49 | int x, y; | |
50 | FbStip *d; | |
51 | FbStip and = andOrig; | |
52 | FbStip xor = xorOrig; | |
53 | ||
54 | dstStride = FbBitsStrideToStipStride(dstStride); | |
55 | x1 = pBox->x1; | |
56 | y1 = pBox->y1; | |
57 | x2 = pBox->x2; | |
58 | y2 = pBox->y2; | |
59 | while (npt--) { | |
60 | x = pts->x + xorg; | |
61 | y = pts->y + yorg; | |
62 | pts++; | |
63 | if (x1 <= x && x < x2 && y1 <= y && y < y2) { | |
64 | x = (x + xoff) * dstBpp; | |
65 | d = dst + ((y + yoff) * dstStride) + (x >> FB_STIP_SHIFT); | |
66 | x &= FB_STIP_MASK; | |
67 | if (dstBpp == 24) { | |
68 | FbStip leftMask, rightMask; | |
69 | int n, rot; | |
70 | FbStip andT, xorT; | |
71 | ||
72 | rot = FbFirst24Rot(x); | |
73 | andT = FbRot24Stip(and, rot); | |
74 | xorT = FbRot24Stip(xor, rot); | |
75 | FbMaskStip(x, 24, leftMask, n, rightMask); | |
76 | if (leftMask) { | |
77 | WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, leftMask)); | |
78 | andT = FbNext24Stip(andT); | |
79 | xorT = FbNext24Stip(xorT); | |
80 | d++; | |
81 | } | |
82 | if (rightMask) | |
83 | WRITE(d, FbDoMaskRRop(READ(d), andT, xorT, rightMask)); | |
84 | } | |
85 | else { | |
86 | FbStip mask; | |
87 | ||
88 | mask = FbStipMask(x, dstBpp); | |
89 | WRITE(d, FbDoMaskRRop(READ(d), and, xor, mask)); | |
90 | } | |
91 | } | |
92 | } | |
93 | } | |
94 | ||
95 | void | |
96 | fbPolyPoint(DrawablePtr pDrawable, | |
97 | GCPtr pGC, int mode, int nptInit, xPoint * pptInit) | |
98 | { | |
99 | FbGCPrivPtr pPriv = fbGetGCPrivate(pGC); | |
100 | RegionPtr pClip = fbGetCompositeClip(pGC); | |
101 | FbBits *dst; | |
102 | FbStride dstStride; | |
103 | int dstBpp; | |
104 | int dstXoff, dstYoff; | |
105 | FbDots dots; | |
106 | FbBits and, xor; | |
107 | xPoint *ppt; | |
108 | int npt; | |
109 | BoxPtr pBox; | |
110 | int nBox; | |
111 | ||
112 | /* make pointlist origin relative */ | |
113 | ppt = pptInit; | |
114 | npt = nptInit; | |
115 | if (mode == CoordModePrevious) { | |
116 | npt--; | |
117 | while (npt--) { | |
118 | ppt++; | |
119 | ppt->x += (ppt - 1)->x; | |
120 | ppt->y += (ppt - 1)->y; | |
121 | } | |
122 | } | |
123 | fbGetDrawable(pDrawable, dst, dstStride, dstBpp, dstXoff, dstYoff); | |
124 | and = pPriv->and; | |
125 | xor = pPriv->xor; | |
126 | dots = fbDots; | |
127 | switch (dstBpp) { | |
128 | case 8: | |
129 | dots = fbDots8; | |
130 | break; | |
131 | case 16: | |
132 | dots = fbDots16; | |
133 | break; | |
134 | case 24: | |
135 | dots = fbDots24; | |
136 | break; | |
137 | case 32: | |
138 | dots = fbDots32; | |
139 | break; | |
140 | } | |
141 | for (nBox = RegionNumRects(pClip), pBox = RegionRects(pClip); | |
142 | nBox--; pBox++) | |
143 | (*dots) (dst, dstStride, dstBpp, pBox, pptInit, nptInit, | |
144 | pDrawable->x, pDrawable->y, dstXoff, dstYoff, and, xor); | |
145 | fbFinishAccess(pDrawable); | |
146 | } |