1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
|
/*
* Acceleration for the Creator and Creator3D framebuffer - Polygon rops.
*
* Copyright (C) 1999 Jakub Jelinek (jakub@redhat.com)
* Copyright (C) 1999 David S. Miller (davem@redhat.com)
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
* JAKUB JELINEK OR DAVID MILLER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
* IN THE SOFTWARE.
*
*/
/* $XFree86$ */
#include "ffb.h"
#include "ffb_regs.h"
#include "ffb_rcache.h"
#include "ffb_fifo.h"
#include "ffb_stip.h"
#include "pixmapstr.h"
#include "scrnintstr.h"
#define PSZ 8
#include "cfb.h"
#undef PSZ
#include "cfb32.h"
#include "mi.h"
void
CreatorFillPolygon (DrawablePtr pDrawable, GCPtr pGC, int shape, int mode, int count, DDXPointPtr ppt)
{
WindowPtr pWin = (WindowPtr) pDrawable;
CreatorPrivGCPtr gcPriv = CreatorGetGCPrivate (pGC);
FFBPtr pFfb = GET_FFB_FROM_SCREEN (pGC->pScreen);
ffb_fbcPtr ffb = pFfb->regs;
BoxRec box;
int lx, rx, ty, by;
int t, b, i, j, k, l, tt;
int xy[12] FFB_ALIGN64;
int xOrg, yOrg;
FFBLOG(("CreatorFillPolygon: ALU(%x) PMSK(%08x) shape(%d) mode(%d) count(%d)\n",
pGC->alu, pGC->planemask, shape, mode, count));
if (count < 3)
return;
if (shape != Convex && count > 3) {
miFillPolygon (pDrawable, pGC, shape, mode, count, ppt);
return;
}
xOrg = pDrawable->x;
yOrg = pDrawable->y;
ppt->x += xOrg;
ppt->y += yOrg;
lx = ppt->x;
rx = ppt->x;
ty = ppt->y;
by = ppt->y;
t = b = 0;
tt = 1;
for (i = 1; i < count; i++) {
if (mode == CoordModeOrigin) {
ppt[i].x += xOrg;
ppt[i].y += yOrg;
} else {
ppt[i].x += ppt[i-1].x;
ppt[i].y += ppt[i-1].y;
}
if (ppt[i].x < lx)
lx = ppt[i].x;
if (ppt[i].x > rx)
rx = ppt[i].x;
if (ppt[i].y < ty) {
ty = ppt[i].y;
t = i;
tt = 1;
} else if (ppt[i].y == ty)
tt++;
if (ppt[i].y > by) {
by = ppt[i].y;
b = i;
}
}
if (tt > 2) {
miFillConvexPoly(pDrawable, pGC, count, ppt);
return;
} else if (tt == 2) {
i = t - 1;
if (i < 0)
i = count - 1;
if (ppt[i].y == ppt[t].y)
t = i;
}
box.x1 = lx;
box.x2 = rx + 1;
box.y1 = ty;
box.y2 = by + 1;
switch (RECT_IN_REGION(pGC->pScreen, cfbGetCompositeClip(pGC), &box)) {
case rgnPART:
miFillConvexPoly(pDrawable, pGC, count, ppt);
case rgnOUT:
return;
}
if(gcPriv->stipple == NULL) {
FFB_ATTR_GC(pFfb, pGC, pWin,
FFB_PPC_APE_DISABLE | FFB_PPC_CS_CONST,
FFB_DRAWOP_POLYGON);
} else {
unsigned int fbc;
FFBSetStipple(pFfb, ffb, gcPriv->stipple,
FFB_PPC_CS_CONST, FFB_PPC_CS_MASK);
FFB_WRITE_PMASK(pFfb, ffb, pGC->planemask);
FFB_WRITE_DRAWOP(pFfb, ffb, FFB_DRAWOP_POLYGON);
fbc = FFB_FBC_WIN(pWin);
fbc = (fbc & ~FFB_FBC_XE_MASK) | FFB_FBC_XE_OFF;
FFB_WRITE_FBC(pFfb, ffb, fbc);
}
xy[0] = ppt[t].y;
xy[1] = ppt[t].x;
j = t + 1;
if (j == count) j = 0;
xy[2] = ppt[j].y;
xy[3] = ppt[j].x;
j = t + 2;
if (j >= count)
j -= count;
for (i = 2 * count - 4; i; i -= k) {
b = 2;
for (k = 0; k < i && k < 8; k+=2) {
xy[4 + k] = ppt[j].y;
xy[4 + k + 1] = ppt[j].x;
if (xy[4 + k] > xy[b])
b = 4 + k;
j++; if (j == count) j = 0;
}
FFBFifo(pFfb, 4 + k);
for (l = 0; l < b - 2; l+=2)
FFB_WRITE64P(&ffb->by, &xy[l]);
FFB_WRITE64P(&ffb->bh, &xy[l]);
for (l+=2; l <= k; l+=2)
FFB_WRITE64P(&ffb->by, &xy[l]);
FFB_WRITE64P(&ffb->ebyi, &xy[l]);
xy[2] = xy[l];
xy[3] = xy[l+1];
}
pFfb->rp_active = 1;
FFBSync(pFfb, ffb);
}
|