2003-11-14 16:54:54 +01:00
|
|
|
/***********************************************************
|
|
|
|
|
|
|
|
Copyright 1987, 1998 The Open Group
|
|
|
|
|
|
|
|
Permission to use, copy, modify, distribute, and sell this software and its
|
|
|
|
documentation for any purpose is hereby granted without fee, provided that
|
|
|
|
the above copyright notice appear in all copies and that both that
|
|
|
|
copyright notice and this permission notice appear in supporting
|
|
|
|
documentation.
|
|
|
|
|
|
|
|
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 THE
|
|
|
|
OPEN GROUP 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.
|
|
|
|
|
|
|
|
Except as contained in this notice, the name of The Open Group shall not be
|
|
|
|
used in advertising or otherwise to promote the sale, use or other dealings
|
|
|
|
in this Software without prior written authorization from The Open Group.
|
|
|
|
|
|
|
|
Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts.
|
|
|
|
|
|
|
|
All Rights Reserved
|
|
|
|
|
|
|
|
Permission to use, copy, modify, and distribute this software and its
|
|
|
|
documentation for any purpose and without fee is hereby granted,
|
|
|
|
provided that the above copyright notice appear in all copies and that
|
|
|
|
both that copyright notice and this permission notice appear in
|
|
|
|
supporting documentation, and that the name of Digital not be
|
|
|
|
used in advertising or publicity pertaining to distribution of the
|
|
|
|
software without specific, written prior permission.
|
|
|
|
|
|
|
|
DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
|
|
|
|
ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
|
|
|
|
DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
|
|
|
|
ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
|
|
|
|
WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
|
|
|
|
ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
|
|
|
|
SOFTWARE.
|
|
|
|
|
|
|
|
******************************************************************/
|
2005-07-03 09:02:09 +02:00
|
|
|
#ifdef HAVE_DIX_CONFIG_H
|
|
|
|
#include <dix-config.h>
|
|
|
|
#endif
|
|
|
|
|
2005-04-20 14:25:48 +02:00
|
|
|
#include <X11/X.h>
|
2003-11-14 16:54:54 +01:00
|
|
|
#include "gcstruct.h"
|
|
|
|
#include "miscanfill.h"
|
|
|
|
#include "mipoly.h"
|
|
|
|
#include "pixmap.h"
|
2003-11-14 17:49:22 +01:00
|
|
|
#include "mi.h"
|
2003-11-14 16:54:54 +01:00
|
|
|
|
|
|
|
/*
|
|
|
|
*
|
|
|
|
* Written by Brian Kelleher; Oct. 1985
|
|
|
|
*
|
|
|
|
* Routine to fill a polygon. Two fill rules are
|
|
|
|
* supported: frWINDING and frEVENODD.
|
|
|
|
*
|
|
|
|
* See fillpoly.h for a complete description of the algorithm.
|
|
|
|
*/
|
|
|
|
|
Rework symbol visibility for easier maintenance
Save in a few special cases, _X_EXPORT should not be used in C source
files. Instead, it should be used in headers, and the proper C source
include that header. Some special cases are symbols that need to be
shared between modules, but not expected to be used by external drivers,
and symbols that are accessible via LoaderSymbol/dlopen.
This patch also adds conditionally some new sdk header files, depending
on extensions enabled. These files were added to match pattern for
other extensions/modules, that is, have the headers "deciding" symbol
visibility in the sdk. These headers are:
o Xext/panoramiXsrv.h, Xext/panoramiX.h
o fbpict.h (unconditionally)
o vidmodeproc.h
o mioverlay.h (unconditionally, used only by xaa)
o xfixes.h (unconditionally, symbols required by dri2)
LoaderSymbol and similar functions now don't have different prototypes,
in loaderProcs.h and xf86Module.h, so that both headers can be included,
without the need of defining IN_LOADER.
xf86NewInputDevice() device prototype readded to xf86Xinput.h, but
not exported (and with a comment about it).
2008-12-03 08:43:34 +01:00
|
|
|
Bool
|
2012-03-21 20:55:09 +01:00
|
|
|
miFillGeneralPoly(DrawablePtr dst, GCPtr pgc, int count, /* number of points */
|
|
|
|
DDXPointPtr ptsIn /* the points */
|
2008-05-28 04:57:07 +02:00
|
|
|
)
|
2003-11-14 16:54:54 +01:00
|
|
|
{
|
2012-03-21 20:55:09 +01:00
|
|
|
EdgeTableEntry *pAET; /* the Active Edge Table */
|
|
|
|
int y; /* the current scanline */
|
|
|
|
int nPts = 0; /* number of pts in buffer */
|
|
|
|
EdgeTableEntry *pWETE; /* Winding Edge Table */
|
|
|
|
ScanLineList *pSLL; /* Current ScanLineList */
|
|
|
|
DDXPointPtr ptsOut; /* ptr to output buffers */
|
2003-11-14 16:54:54 +01:00
|
|
|
int *width;
|
2012-03-21 20:55:09 +01:00
|
|
|
DDXPointRec FirstPoint[NUMPTSTOBUFFER]; /* the output buffers */
|
2003-11-14 16:54:54 +01:00
|
|
|
int FirstWidth[NUMPTSTOBUFFER];
|
2012-03-21 20:55:09 +01:00
|
|
|
EdgeTableEntry *pPrevAET; /* previous AET entry */
|
|
|
|
EdgeTable ET; /* Edge Table header node */
|
|
|
|
EdgeTableEntry AET; /* Active ET header node */
|
|
|
|
EdgeTableEntry *pETEs; /* Edge Table Entries buff */
|
|
|
|
ScanLineListBlock SLLBlock; /* header for ScanLineList */
|
2003-11-14 16:54:54 +01:00
|
|
|
int fixWAET = 0;
|
|
|
|
|
|
|
|
if (count < 3)
|
2012-03-21 20:55:09 +01:00
|
|
|
return TRUE;
|
2003-11-14 16:54:54 +01:00
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!(pETEs = malloc(sizeof(EdgeTableEntry) * count)))
|
|
|
|
return FALSE;
|
2003-11-14 16:54:54 +01:00
|
|
|
ptsOut = FirstPoint;
|
|
|
|
width = FirstWidth;
|
2012-03-21 20:55:09 +01:00
|
|
|
if (!miCreateETandAET(count, ptsIn, &ET, &AET, pETEs, &SLLBlock)) {
|
|
|
|
free(pETEs);
|
|
|
|
return FALSE;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
pSLL = ET.scanlines.next;
|
|
|
|
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pgc->fillRule == EvenOddRule) {
|
2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* for each scanline
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
for (y = ET.ymin; y < ET.ymax; y++) {
|
2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* Add a new edge to the active edge table when we
|
|
|
|
* get to the next edge.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pSLL && y == pSLL->scanline) {
|
2003-11-14 16:54:54 +01:00
|
|
|
miloadAET(&AET, pSLL->edgelist);
|
|
|
|
pSLL = pSLL->next;
|
|
|
|
}
|
|
|
|
pPrevAET = &AET;
|
|
|
|
pAET = AET.next;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* for each active edge
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
while (pAET) {
|
2003-11-14 16:54:54 +01:00
|
|
|
ptsOut->x = pAET->bres.minor;
|
2012-03-21 20:55:09 +01:00
|
|
|
ptsOut++->y = y;
|
2003-11-14 16:54:54 +01:00
|
|
|
*width++ = pAET->next->bres.minor - pAET->bres.minor;
|
|
|
|
nPts++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send out the buffer when its full
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (nPts == NUMPTSTOBUFFER) {
|
|
|
|
(*pgc->ops->FillSpans) (dst, pgc,
|
|
|
|
nPts, FirstPoint, FirstWidth, 1);
|
2003-11-14 16:54:54 +01:00
|
|
|
ptsOut = FirstPoint;
|
|
|
|
width = FirstWidth;
|
|
|
|
nPts = 0;
|
|
|
|
}
|
|
|
|
EVALUATEEDGEEVENODD(pAET, pPrevAET, y)
|
2012-03-21 20:55:09 +01:00
|
|
|
EVALUATEEDGEEVENODD(pAET, pPrevAET, y);
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|
|
|
|
miInsertionSort(&AET);
|
|
|
|
}
|
|
|
|
}
|
2012-03-21 20:55:09 +01:00
|
|
|
else { /* default to WindingNumber */
|
|
|
|
|
2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* for each scanline
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
for (y = ET.ymin; y < ET.ymax; y++) {
|
2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* Add a new edge to the active edge table when we
|
|
|
|
* get to the next edge.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pSLL && y == pSLL->scanline) {
|
2003-11-14 16:54:54 +01:00
|
|
|
miloadAET(&AET, pSLL->edgelist);
|
|
|
|
micomputeWAET(&AET);
|
|
|
|
pSLL = pSLL->next;
|
|
|
|
}
|
|
|
|
pPrevAET = &AET;
|
|
|
|
pAET = AET.next;
|
|
|
|
pWETE = pAET;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* for each active edge
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
while (pAET) {
|
2003-11-14 16:54:54 +01:00
|
|
|
/*
|
|
|
|
* if the next edge in the active edge table is
|
|
|
|
* also the next edge in the winding active edge
|
|
|
|
* table.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (pWETE == pAET) {
|
2003-11-14 16:54:54 +01:00
|
|
|
ptsOut->x = pAET->bres.minor;
|
2012-03-21 20:55:09 +01:00
|
|
|
ptsOut++->y = y;
|
2003-11-14 16:54:54 +01:00
|
|
|
*width++ = pAET->nextWETE->bres.minor - pAET->bres.minor;
|
|
|
|
nPts++;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* send out the buffer
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (nPts == NUMPTSTOBUFFER) {
|
|
|
|
(*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint,
|
|
|
|
FirstWidth, 1);
|
2003-11-14 16:54:54 +01:00
|
|
|
ptsOut = FirstPoint;
|
2012-03-21 20:55:09 +01:00
|
|
|
width = FirstWidth;
|
2003-11-14 16:54:54 +01:00
|
|
|
nPts = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
pWETE = pWETE->nextWETE;
|
|
|
|
while (pWETE != pAET)
|
|
|
|
EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
|
|
|
|
pWETE = pWETE->nextWETE;
|
|
|
|
}
|
|
|
|
EVALUATEEDGEWINDING(pAET, pPrevAET, y, fixWAET);
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* reevaluate the Winding active edge table if we
|
|
|
|
* just had to resort it or if we just exited an edge.
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
if (miInsertionSort(&AET) || fixWAET) {
|
2003-11-14 16:54:54 +01:00
|
|
|
micomputeWAET(&AET);
|
|
|
|
fixWAET = 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Get any spans that we missed by buffering
|
|
|
|
*/
|
2012-03-21 20:55:09 +01:00
|
|
|
(*pgc->ops->FillSpans) (dst, pgc, nPts, FirstPoint, FirstWidth, 1);
|
2010-05-05 20:44:06 +02:00
|
|
|
free(pETEs);
|
2003-11-14 16:54:54 +01:00
|
|
|
miFreeStorage(SLLBlock.next);
|
2010-06-06 16:18:40 +02:00
|
|
|
return TRUE;
|
2003-11-14 16:54:54 +01:00
|
|
|
}
|