[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]
gEDA-cvs: pcb.git: branch: master updated (ede7157be717b4cd22e1e51b6045a2ea5f28de26)
The branch, master has been updated
via ede7157be717b4cd22e1e51b6045a2ea5f28de26 (commit)
from 5e0bb671c487f2ba723e2965b476d6fea437e700 (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 | 47 +++++++++++++++++++++++++++++++++++++++-
1 files changed, 45 insertions(+), 2 deletions(-)
=================
Commit Messages
=================
commit ede7157be717b4cd22e1e51b6045a2ea5f28de26
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/common: Control update of NoHoles cache based on clip region
If at least 50% of the bounding box of a polygon is within the
clip region, compute the whole NoHoles polygon and cache it for
later rendering.
If less of the polygon is within the clip region, just compute
what we need to draw the piece we've been asked for.
:100644 100644 5020745... e975f3b... M src/hid/common/draw_helpers.c
=========
Changes
=========
commit ede7157be717b4cd22e1e51b6045a2ea5f28de26
Author: Peter Clifton <pcjc2@xxxxxxxxx>
Commit: Peter Clifton <pcjc2@xxxxxxxxx>
hid/common: Control update of NoHoles cache based on clip region
If at least 50% of the bounding box of a polygon is within the
clip region, compute the whole NoHoles polygon and cache it for
later rendering.
If less of the polygon is within the clip region, just compute
what we need to draw the piece we've been asked for.
diff --git a/src/hid/common/draw_helpers.c b/src/hid/common/draw_helpers.c
index 5020745..e975f3b 100644
--- a/src/hid/common/draw_helpers.c
+++ b/src/hid/common/draw_helpers.c
@@ -93,6 +93,42 @@ fill_clipped_contour (hidGC gc, PLINE *pl, const BoxType *clip_box)
poly_Free (&clipped_pieces);
}
+/* If at least 50% of the bounding box of the polygon is on the screen,
+ * lets compute the complete no-holes polygon.
+ */
+#define BOUNDS_INSIDE_CLIP_THRESHOLD 0.5
+static int
+should_compute_no_holes (PolygonType *poly, const BoxType *clip_box)
+{
+ int x1, x2, y1, y2;
+ float poly_bounding_area;
+ float clipped_poly_area;
+
+ /* If there is no passed clip box, compute the whole thing */
+ if (clip_box == NULL)
+ return 1;
+
+ x1 = MAX (poly->BoundingBox.X1, clip_box->X1);
+ x2 = MIN (poly->BoundingBox.X2, clip_box->X2);
+ y1 = MAX (poly->BoundingBox.Y1, clip_box->Y1);
+ y2 = MIN (poly->BoundingBox.Y2, clip_box->Y2);
+
+ /* Check if the polygon is outside the clip box */
+ if ((x2 <= x1) || (y2 <= y1))
+ return 0;
+
+ poly_bounding_area = (float)(poly->BoundingBox.X2 - poly->BoundingBox.X1) *
+ (float)(poly->BoundingBox.Y2 - poly->BoundingBox.Y1);
+
+ clipped_poly_area = (float)(x2 - x1) * (float)(y2 - y1);
+
+ if (clipped_poly_area / poly_bounding_area >= BOUNDS_INSIDE_CLIP_THRESHOLD)
+ return 1;
+
+ return 0;
+}
+#undef BOUNDS_INSIDE_CLIP_THRESHOLD
+
void common_fill_pcb_polygon (hidGC gc, PolygonType *poly,
const BoxType *clip_box)
{
@@ -102,9 +138,16 @@ void common_fill_pcb_polygon (hidGC gc, PolygonType *poly,
if (!poly->NoHolesValid)
{
- ComputeNoHoles (poly);
+ /* If enough of the polygon is on-screen, compute the entire
+ * NoHoles version and cache it for later rendering, otherwise
+ * just compute what we need to render now.
+ */
+ if (should_compute_no_holes (poly, clip_box))
+ ComputeNoHoles (poly);
+ else
+ NoHolesPolygonDicer (poly, clip_box, fill_contour_cb, gc);
}
- if (poly->NoHoles)
+ if (poly->NoHolesValid && poly->NoHoles)
{
PLINE *pl;
_______________________________________________
geda-cvs mailing list
geda-cvs@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-cvs