#define LARGE_COORDINATE 1000000
#define SMALL_COORDINATE -LARGE_COORDINATE
+#include "config.h"
#include <gdkregion.h>
#include "gdkregion-generic.h"
#include "gdkpoly-generic.h"
+#include "gdkalias.h"
/*
* InsertEdgeInET
*
*/
static void
-InsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock)
- EdgeTable *ET;
- EdgeTableEntry *ETE;
- int scanline;
- ScanLineListBlock **SLLBlock;
- int *iSLLBlock;
+InsertEdgeInET (EdgeTable *ET,
+ EdgeTableEntry *ETE,
+ int scanline,
+ ScanLineListBlock **SLLBlock,
+ int *iSLLBlock)
{
EdgeTableEntry *start, *prev;
ScanLineList *pSLL, *pPrevSLL;
*/
static void
-CreateETandAET(count, pts, ET, AET, pETEs, pSLLBlock)
- int count;
- GdkPoint *pts;
- EdgeTable *ET;
- EdgeTableEntry *AET;
- EdgeTableEntry *pETEs;
- ScanLineListBlock *pSLLBlock;
+CreateETandAET (int count,
+ const GdkPoint *pts,
+ EdgeTable *ET,
+ EdgeTableEntry *AET,
+ EdgeTableEntry *pETEs,
+ ScanLineListBlock *pSLLBlock)
{
- GdkPoint *top, *bottom;
- GdkPoint *PrevPt, *CurrPt;
+ const GdkPoint *top, *bottom;
+ const GdkPoint *PrevPt, *CurrPt;
int iSLLBlock = 0;
int dy;
*/
static void
-loadAET(AET, ETEs)
- EdgeTableEntry *AET, *ETEs;
+loadAET(EdgeTableEntry *AET,
+ EdgeTableEntry *ETEs)
{
EdgeTableEntry *pPrevAET;
EdgeTableEntry *tmp;
*
*/
static void
-computeWAET(AET)
- EdgeTableEntry *AET;
+computeWAET (EdgeTableEntry *AET)
{
EdgeTableEntry *pWETE;
int inside = 1;
*/
static int
-InsertionSort(AET)
- EdgeTableEntry *AET;
+InsertionSort (EdgeTableEntry *AET)
{
EdgeTableEntry *pETEchase;
EdgeTableEntry *pETEinsert;
* Clean up our act.
*/
static void
-FreeStorage(pSLLBlock)
- ScanLineListBlock *pSLLBlock;
+FreeStorage (ScanLineListBlock *pSLLBlock)
{
ScanLineListBlock *tmpSLLBlock;
* stack by the calling procedure.
*
*/
-static int PtsToRegion(numFullPtBlocks, iCurPtBlock, FirstPtBlock, reg)
- int numFullPtBlocks, iCurPtBlock;
- POINTBLOCK *FirstPtBlock;
- GdkRegion *reg;
+static int
+PtsToRegion (int numFullPtBlocks,
+ int iCurPtBlock,
+ POINTBLOCK *FirstPtBlock,
+ GdkRegion *reg)
{
GdkRegionBox *rects;
GdkPoint *pts;
numRects = ((numFullPtBlocks * NUMPTSTOBUFFER) + iCurPtBlock) >> 1;
- reg->rects = g_renew (GdkRegionBox, reg->rects, numRects);
-
- reg->size = numRects;
+ GROWREGION(reg, numRects);
+
CurPtBlock = FirstPtBlock;
rects = reg->rects - 1;
numRects = 0;
return(TRUE);
}
-/*
- * polytoregion
+/**
+ * gdk_region_polygon:
+ * @points: an array of #GdkPoint structs
+ * @n_points: the number of elements in the @points array
+ * @fill_rule: specifies which pixels are included in the region when the
+ * polygon overlaps itself.
+ *
+ * Creates a new #GdkRegion using the polygon defined by a
+ * number of points.
*
- * Scan converts a polygon by returning a run-length
- * encoding of the resultant bitmap -- the run-length
- * encoding is in the form of an array of rectangles.
+ * Returns: a new #GdkRegion based on the given polygon
*/
GdkRegion *
-gdk_region_polygon(GdkPoint *Pts, gint Count, GdkFillRule rule)
+gdk_region_polygon (const GdkPoint *points,
+ gint n_points,
+ GdkFillRule fill_rule)
{
GdkRegion *region;
EdgeTableEntry *pAET; /* Active Edge Table */
int iPts = 0; /* number of pts in buffer */
EdgeTableEntry *pWETE; /* Winding Edge Table Entry*/
ScanLineList *pSLL; /* current scanLineList */
- GdkPoint *pts; /* output buffer */
+ GdkPoint *pts; /* output buffer */
EdgeTableEntry *pPrevAET; /* ptr to previous AET */
EdgeTable ET; /* header node for ET */
EdgeTableEntry AET; /* header node for AET */
region = gdk_region_new ();
/* special case a rectangle */
- pts = Pts;
- if (((Count == 4) ||
- ((Count == 5) && (pts[4].x == pts[0].x) && (pts[4].y == pts[0].y))) &&
- (((pts[0].y == pts[1].y) &&
- (pts[1].x == pts[2].x) &&
- (pts[2].y == pts[3].y) &&
- (pts[3].x == pts[0].x)) ||
- ((pts[0].x == pts[1].x) &&
- (pts[1].y == pts[2].y) &&
- (pts[2].x == pts[3].x) &&
- (pts[3].y == pts[0].y)))) {
- region->extents.x1 = MIN(pts[0].x, pts[2].x);
- region->extents.y1 = MIN(pts[0].y, pts[2].y);
- region->extents.x2 = MAX(pts[0].x, pts[2].x);
- region->extents.y2 = MAX(pts[0].y, pts[2].y);
+ if (((n_points == 4) ||
+ ((n_points == 5) && (points[4].x == points[0].x) && (points[4].y == points[0].y))) &&
+ (((points[0].y == points[1].y) &&
+ (points[1].x == points[2].x) &&
+ (points[2].y == points[3].y) &&
+ (points[3].x == points[0].x)) ||
+ ((points[0].x == points[1].x) &&
+ (points[1].y == points[2].y) &&
+ (points[2].x == points[3].x) &&
+ (points[3].y == points[0].y)))) {
+ region->extents.x1 = MIN(points[0].x, points[2].x);
+ region->extents.y1 = MIN(points[0].y, points[2].y);
+ region->extents.x2 = MAX(points[0].x, points[2].x);
+ region->extents.y2 = MAX(points[0].y, points[2].y);
if ((region->extents.x1 != region->extents.x2) &&
(region->extents.y1 != region->extents.y2)) {
region->numRects = 1;
return(region);
}
- pETEs = g_new (EdgeTableEntry, Count);
+ pETEs = g_new (EdgeTableEntry, n_points);
pts = FirstPtBlock.pts;
- CreateETandAET(Count, Pts, &ET, &AET, pETEs, &SLLBlock);
+ CreateETandAET(n_points, points, &ET, &AET, pETEs, &SLLBlock);
pSLL = ET.scanlines.next;
curPtBlock = &FirstPtBlock;
- if (rule == GDK_EVEN_ODD_RULE) {
+ if (fill_rule == GDK_EVEN_ODD_RULE) {
/*
* for each scanline
*/
g_free (pETEs);
return(region);
}
+
+#define __GDK_POLYREG_GENERIC_C__
+#include "gdkaliasdef.c"