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