[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (7dc2d854f3e58680577b2bb71cd68b2b769e3025)
The branch, master has been updated
via 7dc2d854f3e58680577b2bb71cd68b2b769e3025 (commit)
from 670ce234f07f33a6ea09be3de4ceebd6d7002b7a (commit)
Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.
=========
Summary
=========
src/hid/common/draw_helpers.c | 42 ++++++++++++++++++++++++++++++++++++++++-
1 files changed, 41 insertions(+), 1 deletions(-)
=================
Commit Messages
=================
commit 7dc2d854f3e58680577b2bb71cd68b2b769e3025
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/common: Clip no-holes polygon pieces before calling fill_contour
This avoids integer overflow in some HIDs (GTK, Lesstif?) when
drawing at high zoom level. Such overflow would lead to incorrectly
drawn polygons.
It is possible that a similar bug could effect thin-drawn polygons,
but that has not manifested its-self so far. If we were to clip these
in the future, we need to be careful to extend the clip region
slightly off-screen, so the outlines are not drawn.
Ideally we would clip these vertices using a Sutherland-Hodgman
clipping algorithm, then we could simply discard edges which are
clipped completely.
:100644 100644 ded1bc8... 81fb850... M src/hid/common/draw_helpers.c
=========
Changes
=========
commit 7dc2d854f3e58680577b2bb71cd68b2b769e3025
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/common: Clip no-holes polygon pieces before calling fill_contour
This avoids integer overflow in some HIDs (GTK, Lesstif?) when
drawing at high zoom level. Such overflow would lead to incorrectly
drawn polygons.
It is possible that a similar bug could effect thin-drawn polygons,
but that has not manifested its-self so far. If we were to clip these
in the future, we need to be careful to extend the clip region
slightly off-screen, so the outlines are not drawn.
Ideally we would clip these vertices using a Sutherland-Hodgman
clipping algorithm, then we could simply discard edges which are
clipped completely.
diff --git a/src/hid/common/draw_helpers.c b/src/hid/common/draw_helpers.c
index ded1bc8..81fb850 100644
--- a/src/hid/common/draw_helpers.c
+++ b/src/hid/common/draw_helpers.c
@@ -63,6 +63,41 @@ static void fill_contour_cb (PLINE *pl, void *user_data)
poly_FreeContours (&local_pl);
}
+static void
+fill_clipped_contour (hidGC gc, PLINE *pl, const BoxType *clip_box)
+{
+ PLINE *pl_copy;
+ POLYAREA *clip_poly;
+ POLYAREA *piece_poly;
+ POLYAREA *clipped_pieces;
+ POLYAREA *draw_piece;
+ int x;
+
+ clip_poly = RectPoly (clip_box->X1, clip_box->X2,
+ clip_box->Y1, clip_box->Y2);
+ poly_CopyContour (&pl_copy, pl);
+ piece_poly = ContourToPoly (pl_copy);
+ x = poly_Boolean_free (piece_poly, clip_poly,
+ &clipped_pieces, PBO_ISECT);
+ if (x != err_ok)
+ {
+ poly_Free (&clipped_pieces);
+ return;
+ }
+
+ if (clipped_pieces == NULL)
+ return;
+
+ draw_piece = clipped_pieces;
+ do
+ {
+ /* NB: The polygon won't have any holes in it */
+ fill_contour (gc, draw_piece->contours);
+ }
+ while ((draw_piece = draw_piece->f) != clipped_pieces);
+ poly_Free (&clipped_pieces);
+}
+
void common_fill_pcb_polygon (hidGC gc, PolygonType *poly,
const BoxType *clip_box)
{
@@ -79,7 +114,12 @@ void common_fill_pcb_polygon (hidGC gc, PolygonType *poly,
PLINE *pl;
for (pl = poly->NoHoles; pl != NULL; pl = pl->next)
- fill_contour (gc, pl);
+ {
+ if (clip_box == NULL)
+ fill_contour (gc, pl);
+ else
+ fill_clipped_contour (gc, pl, clip_box);
+ }
}
/* Draw other parts of the polygon if fullpoly flag is set */
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs