diff options
author | David Robillard <d@drobilla.net> | 2014-01-03 22:24:11 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2014-01-03 22:24:11 +0000 |
commit | 3517286a9404d556c384276d63b73b588fadbcfe (patch) | |
tree | 21d755eaeebace222216b3ab294ea200171fe3a2 /src/Canvas.cpp | |
parent | 9191aae81ab497d9cbf5a256b2b2e9dbf1af5d67 (diff) | |
download | ganv-3517286a9404d556c384276d63b73b588fadbcfe.tar.gz ganv-3517286a9404d556c384276d63b73b588fadbcfe.tar.bz2 ganv-3517286a9404d556c384276d63b73b588fadbcfe.zip |
Draw and layout performance improvements.
git-svn-id: http://svn.drobilla.net/lad/trunk/ganv@5248 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src/Canvas.cpp')
-rw-r--r-- | src/Canvas.cpp | 18 |
1 files changed, 10 insertions, 8 deletions
diff --git a/src/Canvas.cpp b/src/Canvas.cpp index ca28025..73e78cb 100644 --- a/src/Canvas.cpp +++ b/src/Canvas.cpp @@ -716,16 +716,18 @@ GanvCanvasImpl::layout_dot(const std::string& filename) #ifdef GANV_FDGL inline Region -get_region(const GanvNode* node) +get_region(GanvNode* node) { + GanvItem* item = &node->item; + double x1, y1, x2, y2; - ganv_item_get_bounds(GANV_ITEM(node), &x1, &y1, &x2, &y2); + ganv_item_get_bounds(item, &x1, &y1, &x2, &y2); Region reg; reg.area.x = x2 - x1; reg.area.y = y2 - y1; - reg.pos.x = GANV_ITEM(node)->x + (reg.area.x / 2.0); - reg.pos.y = GANV_ITEM(node)->y + (reg.area.y / 2.0); + reg.pos.x = item->x + (reg.area.x / 2.0); + reg.pos.y = item->y + (reg.area.y / 2.0); // No need for i2w here since we only care about top-level items return reg; @@ -806,7 +808,7 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) if (!GANV_IS_MODULE(*i) && !GANV_IS_CIRCLE(*i)) { continue; } - GanvNode* const node = GANV_NODE(*i); + GanvNode* const node = *i; const Region reg = get_region(node); GanvNode* partner = ganv_node_get_partner(node); @@ -844,7 +846,7 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) if (i == j || (!GANV_IS_MODULE(*i) && !GANV_IS_CIRCLE(*i))) { continue; } - GanvNode* const node2 = GANV_NODE(*j); + GanvNode* const node2 = *j; if ((!node2->impl->has_in_edges && !node2->impl->has_out_edges) && !node2->impl->is_source) { continue; @@ -861,7 +863,7 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) continue; } - GanvNode* const node = GANV_NODE(*i); + GanvNode* const node = *i; static const float damp = 0.3; // Velocity damping @@ -887,7 +889,7 @@ GanvCanvasImpl::layout_calculate(double dur, bool update) } // Update position - GanvItem* item = GANV_ITEM(node); + GanvItem* item = &node->item; const double x0 = item->x; const double y0 = item->y; const Vector dpos = vec_mult(node->impl->vel, dur); |