diff options
author | drh@sqlite.org <drh> | 2003-01-08 23:02:19 (GMT) |
---|---|---|
committer | drh@sqlite.org <drh> | 2003-01-08 23:02:19 (GMT) |
commit | 22a94540142e210e4175c5aad1c09ec7a8c058d9 (patch) | |
tree | ac3d9da91203ca0c8d8e76775c90ca1893242007 /generic/tkCanvLine.c | |
parent | 49c51cd1627b228e3282db5386000bbb9e068268 (diff) | |
download | tk-22a94540142e210e4175c5aad1c09ec7a8c058d9.zip tk-22a94540142e210e4175c5aad1c09ec7a8c058d9.tar.gz tk-22a94540142e210e4175c5aad1c09ec7a8c058d9.tar.bz2 |
Implement Cohen-Sutherland polygon clipping for long lines in the canvas widget
so that coordinates do not overflow the 16-bit limit imposed by X11 and Win32.
Bug #663981.
Diffstat (limited to 'generic/tkCanvLine.c')
-rw-r--r-- | generic/tkCanvLine.c | 18 |
1 files changed, 7 insertions, 11 deletions
diff --git a/generic/tkCanvLine.c b/generic/tkCanvLine.c index 6431830..f597843 100644 --- a/generic/tkCanvLine.c +++ b/generic/tkCanvLine.c @@ -10,7 +10,7 @@ * See the file "license.terms" for information on usage and redistribution * of this file, and for a DISCLAIMER OF ALL WARRANTIES. * - * RCS: @(#) $Id: tkCanvLine.c,v 1.11 2002/08/05 04:30:38 dgp Exp $ + * RCS: @(#) $Id: tkCanvLine.c,v 1.12 2003/01/08 23:02:28 drh Exp $ */ #include <stdio.h> @@ -848,11 +848,10 @@ DisplayLine(canvas, itemPtr, display, drawable, x, y, width, height) * must be redisplayed (not used). */ { LineItem *linePtr = (LineItem *) itemPtr; - XPoint staticPoints[MAX_STATIC_POINTS]; + XPoint staticPoints[MAX_STATIC_POINTS*3]; XPoint *pointPtr; - XPoint *pPtr; - double *coordPtr, linewidth; - int i, numPoints; + double linewidth; + int numPoints; Tk_State state = itemPtr->state; Pixmap stipple = linePtr->outline.stipple; @@ -897,7 +896,7 @@ DisplayLine(canvas, itemPtr, display, drawable, x, y, width, height) if (numPoints <= MAX_STATIC_POINTS) { pointPtr = staticPoints; } else { - pointPtr = (XPoint *) ckalloc((unsigned) (numPoints * sizeof(XPoint))); + pointPtr = (XPoint *)ckalloc((unsigned)(numPoints * 3*sizeof(XPoint))); } if ((linePtr->smooth) && (linePtr->numPoints > 2)) { @@ -905,11 +904,8 @@ DisplayLine(canvas, itemPtr, display, drawable, x, y, width, height) linePtr->numPoints, linePtr->splineSteps, pointPtr, (double *) NULL); } else { - for (i = 0, coordPtr = linePtr->coordPtr, pPtr = pointPtr; - i < linePtr->numPoints; i += 1, coordPtr += 2, pPtr++) { - Tk_CanvasDrawableCoords(canvas, coordPtr[0], coordPtr[1], - &pPtr->x, &pPtr->y); - } + numPoints = TkCanvTranslatePath((TkCanvas*)canvas, numPoints, + linePtr->coordPtr, 0, pointPtr); } /* |