]> Pileus Git - ~andy/gtk/blobdiff - gdk/gdkpolyreg-generic.c
Include "config.h" instead of <config.h> Command used: find -name
[~andy/gtk] / gdk / gdkpolyreg-generic.c
index 916d257b5f2ac7af9196b875e8a4b3a2e7b158e6..95433383a2428a0f7d99ec35d4e6dbdaf0c6fb84 100644 (file)
@@ -46,10 +46,11 @@ SOFTWARE.
 #define LARGE_COORDINATE 1000000
 #define SMALL_COORDINATE -LARGE_COORDINATE
 
-#include <config.h>
+#include "config.h"
 #include <gdkregion.h>
 #include "gdkregion-generic.h"
 #include "gdkpoly-generic.h"
+#include "gdkalias.h"
 
 /*
  *     InsertEdgeInET
@@ -61,12 +62,11 @@ SOFTWARE.
  *
  */
 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;
@@ -149,16 +149,15 @@ InsertEdgeInET(ET, ETE, scanline, SLLBlock, iSLLBlock)
  */
 
 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;
 
@@ -241,8 +240,8 @@ CreateETandAET(count, pts, ET, AET, pETEs, pSLLBlock)
  */
 
 static void
-loadAET(AET, ETEs)
-    EdgeTableEntry *AET, *ETEs;
+loadAET(EdgeTableEntry *AET,
+        EdgeTableEntry *ETEs)
 {
     EdgeTableEntry *pPrevAET;
     EdgeTableEntry *tmp;
@@ -289,8 +288,7 @@ loadAET(AET, ETEs)
  *
  */
 static void
-computeWAET(AET)
-    EdgeTableEntry *AET;
+computeWAET (EdgeTableEntry *AET)
 {
     EdgeTableEntry *pWETE;
     int inside = 1;
@@ -328,8 +326,7 @@ computeWAET(AET)
  */
 
 static int
-InsertionSort(AET)
-    EdgeTableEntry *AET;
+InsertionSort (EdgeTableEntry *AET)
 {
     EdgeTableEntry *pETEchase;
     EdgeTableEntry *pETEinsert;
@@ -365,8 +362,7 @@ InsertionSort(AET)
  *     Clean up our act.
  */
 static void
-FreeStorage(pSLLBlock)
-    ScanLineListBlock   *pSLLBlock;
+FreeStorage (ScanLineListBlock *pSLLBlock)
 {
     ScanLineListBlock   *tmpSLLBlock;
 
@@ -386,10 +382,11 @@ FreeStorage(pSLLBlock)
  *     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;
@@ -402,9 +399,8 @@ static int PtsToRegion(numFullPtBlocks, iCurPtBlock, FirstPtBlock, reg)
  
     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;
@@ -451,15 +447,22 @@ static int PtsToRegion(numFullPtBlocks, iCurPtBlock, FirstPtBlock, reg)
     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       */
@@ -467,7 +470,7 @@ gdk_region_polygon(GdkPoint *Pts, gint Count, GdkFillRule rule)
     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     */
@@ -481,21 +484,20 @@ gdk_region_polygon(GdkPoint *Pts, gint Count, GdkFillRule rule)
     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;
@@ -504,14 +506,14 @@ gdk_region_polygon(GdkPoint *Pts, gint Count, GdkFillRule rule)
        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
          */
@@ -617,3 +619,6 @@ gdk_region_polygon(GdkPoint *Pts, gint Count, GdkFillRule rule)
     g_free (pETEs);
     return(region);
 }
+
+#define __GDK_POLYREG_GENERIC_C__
+#include "gdkaliasdef.c"