summaryrefslogtreecommitdiffstats
path: root/src/edge.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2013-12-27 00:38:17 +0000
committerDavid Robillard <d@drobilla.net>2013-12-27 00:38:17 +0000
commit76298e353df88996de4b423f3090811723b73d37 (patch)
tree307edcd3cebb36acf404af5ffb8aaad48de72cb3 /src/edge.c
parentf3d304f86be2d4639ba61267a1ca861900fb9d7d (diff)
downloadganv-76298e353df88996de4b423f3090811723b73d37.tar.gz
ganv-76298e353df88996de4b423f3090811723b73d37.tar.bz2
ganv-76298e353df88996de4b423f3090811723b73d37.zip
Performance improvements.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5214 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/edge.c')
-rw-r--r--src/edge.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/edge.c b/src/edge.c
index e1d9fb7..d6ca68a 100644
--- a/src/edge.c
+++ b/src/edge.c
@@ -249,21 +249,11 @@ ganv_edge_bounds(GanvItem* item,
}
}
-static void
-ganv_edge_update(GanvItem* item, int flags)
+void
+ganv_edge_get_coords(const GanvEdge* edge, GanvEdgeCoords* coords)
{
- GanvEdge* edge = GANV_EDGE(item);
GanvEdgeImpl* impl = edge->impl;
- if (parent_class->update) {
- (*parent_class->update)(item, flags);
- }
-
- // Request redraw of old location
- ganv_edge_request_redraw(item->canvas, &impl->old_coords);
-
- // Calculate new coordinates from tail and head
- GanvEdgeCoords* coords = &impl->coords;
GANV_NODE_GET_CLASS(impl->tail)->tail_vector(
impl->tail, impl->head,
&coords->x1, &coords->y1, &coords->cx1, &coords->cy1);
@@ -273,6 +263,7 @@ ganv_edge_update(GanvItem* item, int flags)
const double dx = coords->x2 - coords->x1;
const double dy = coords->y2 - coords->y1;
+
coords->handle_x = coords->x1 + (dx / 2.0);
coords->handle_y = coords->y1 + (dy / 2.0);
@@ -280,6 +271,23 @@ ganv_edge_update(GanvItem* item, int flags)
coords->cy1 = coords->y1 + (coords->cy1 * (ceil(fabs(dy)) / 4.0));
coords->cx2 = coords->x2 + (coords->cx2 * (ceil(fabs(dx)) / 4.0));
coords->cy2 = coords->y2 + (coords->cy2 * (ceil(fabs(dy)) / 4.0));
+}
+
+static void
+ganv_edge_update(GanvItem* item, int flags)
+{
+ GanvEdge* edge = GANV_EDGE(item);
+ GanvEdgeImpl* impl = edge->impl;
+
+ if (parent_class->update) {
+ (*parent_class->update)(item, flags);
+ }
+
+ // Request redraw of old location
+ ganv_edge_request_redraw(item->canvas, &impl->old_coords);
+
+ // Calculate new coordinates from tail and head
+ ganv_edge_get_coords(edge, &impl->coords);
// Update old coordinates
impl->old_coords = impl->coords;