bf45b61deb8e09918d17d44459a087536ab95588 kent Wed Apr 19 14:56:50 2017 -0700 Removing some unused flaky code. diff --git src/lib/mgPolygon.c src/lib/mgPolygon.c index 61c7ef6..902d703 100644 --- src/lib/mgPolygon.c +++ src/lib/mgPolygon.c @@ -232,207 +232,25 @@ else if (lastdir == DOWNDIR) xor_pt(bpr,ox-pxmin,oy-pymin); else lastdir = DOWNDIR; } ox = x; oy = y; } drawAfterOnOff(mg, color, bpr, width, height); freez(&on_off_buf); return; } -/* ---- This section of code is for convex, polygons. It's faster. ---- */ - -#ifdef SOME_OFF_BY_ONE_PROBLEMS -static int *xdda_ebuf(int *ebuf, int x1, int y1, int x2, int y2) -/* Calculate the x-positions of a line from x1,y1 to x2/y2 */ -{ -int incx, incy; -int x; -int duty_cycle; -int delta_x, delta_y; -int dots; - -delta_y = y2-y1; -delta_x = x2-x1; -incx = incy = 1; -x = x1; -if (delta_y < 0) - { - delta_y = -delta_y; - incy = -1; - } - -if (delta_x < 0) - { - delta_x = -delta_x; - incx = -1; - } - -duty_cycle = (delta_x - delta_y)/2; -if (delta_x >= delta_y) - { - int lasty = y1-1; - dots = delta_x+1; - while (--dots >= 0) - { - if (lasty != y1) - { - *ebuf++ = x1; - lasty = y1; - } - duty_cycle -= delta_y; - x1 += incx; - if (duty_cycle < 0) - { - duty_cycle += delta_x; /* update duty cycle */ - y1+=incy; - } - } - } -else - { - dots = delta_y+1; - while (--dots >= 0) - { - *ebuf++ = x1; - duty_cycle += delta_x; - y1+=incy; - if (duty_cycle > 0) - { - duty_cycle -= delta_y; /* update duty cycle */ - x1 += incx; - } - } - } -return(ebuf); -} -#endif /* SOME_OFF_BY_ONE_PROBLEMS */ - - -#ifdef CONVEX_OPTIMIZATION -int *fill_ebuf(struct gfxPoint *thread, int count, int *ebuf) -/* Make list of x coordinates for a couple of lines. Assumes that - * the y coordinates are monotonic. Ebuf needs to be as big as the - * total height of thread. Returns next free space in ebuf. */ -{ -int x, y, ox, oy; -int i; - -ox = thread->x; -oy = thread->y; - -for (i=0; inext; - x = thread->x; - y = thread->y; - if (y!=oy) - ebuf = xdda_ebuf(ebuf,ox,oy,x,y) - 1; - ox = x; - oy = y; - } -return(ebuf+1); -} - -static void blast_hlines(struct memGfx *mg, - int *thread1, /* List of start X positions. */ - int *thread2, /* Backwards list of end positions. */ - int y, /* Y position. */ - int count, /* Number of horizontal lines to draw. */ - Color color) /* Color. */ -/* Draw a whole bunch of horizontal lines. */ -{ -int x1, x2; -thread2 += count; -while (--count >= 0) - { - x1 = *thread1++; - x2 = *(--thread2); - if (x1 > x2) - mgLineH(mg, y, x2, x1, color); - else - mgLineH(mg, y, x1, x2, color); - y += 1; - } -} - -void mgDrawPolyFilled(struct memGfx *mg, struct gfxPoly *poly, Color color) -/* Draw filled polygon, possibly with outline in a seperate color. */ -{ -struct gfxPoint *p; -struct gfxPoint *np; -struct gfxPoint *peak; -struct gfxPoint *valley; -int highy; -int i; -int pcount; -int lasty; - -peak = p = poly->ptList; -i = poly->ptCount; -highy = p->y; -pcount = 0; -while (--i > 0) - { - p = p->next; - if (p->y <= highy) - { - peak = p; - highy = p->y; - } - } -p = peak; -np = p->next; -i = poly->ptCount; -while (--i >= 0) - { - if (np->y < p->y) - { - int totalHeight; - int *thread1, *thread2; - valley = p; - p = np; - np = np->next; - while (--i >= 0) - { - if (np->y > p->y) - { - fillConcave(mg, poly, color); - return; /*sorry its concave*/ - } - p = np; - np = np->next; - } - totalHeight = valley->y - highy + 1; - AllocArray(thread1, totalHeight); - AllocArray(thread2, totalHeight); - fill_ebuf(peak, pcount, thread1); - pcount = fill_ebuf(valley, poly->ptCount - pcount, thread2) - - thread2; - blast_hlines(mg, thread1, thread2, highy, pcount, color); - freeMem(thread1); - freeMem(thread2); - return; - } - pcount++; - p = np; - np = np->next; - } -return; /*all points of poly have same y value */ -} -#endif /* CONVEX_OPTIMIZATION */ void mgDrawPoly(struct memGfx *mg, struct gfxPoly *poly, Color color, boolean filled) /* Draw polygon, possibly filled in color. */ { if (filled) fillConcave(mg, poly, color); - // mgDrawPolyFilled(mg, poly, color); mgDrawPolyOutline(mg, poly, color); }