Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve line updates #779

Merged
merged 5 commits into from
Feb 28, 2018
Merged

Improve line updates #779

merged 5 commits into from
Feb 28, 2018

Conversation

manthey
Copy link
Contributor

@manthey manthey commented Feb 22, 2018

Speed up line style updates.

Before, any change to a line style would recompute the geometry information as well. Now, if the position of vertices has not changes, the geometry is not recomputed. Further, many style were being called by function when they were their default values (such as the strokeOffset not being set). These properly are treated as fixed values, avoiding many function calls. The polygon feature, when stroked, is better at passing constant values for stroke opacity to the lines.

In practice, this results in a large speed up. For a condition where there are lines with ~100,000 vertices, the line _build call was reduced from 450-500 ms to 12-15 ms.

Also correct some minor issues with docs for the polygon feature.
Before, any change to a line style would recompute the geometry
information as well.  Now, if the position of vertices has not changes,
the geometry is not recomputed.  Further, many style were being called
by function when they were their default values (such as the
strokeOffset not being set).  These properly are treated as fixed
values, avoiding many function calls.  The polygon feature, when
stroked, is better at passing constant values for stroke opacity to the
lines.

In practice, this results in a large speed up.  For a condition where
there are lines with ~100,000 vertices, the line _build call was reduced
from 450-500 ms to 12-15 ms.
@manthey
Copy link
Contributor Author

manthey commented Feb 22, 2018

@kheffah: This resolves a performance issue reported in DigitalSlideArchive/HistomicsTK#459.

Some code was in a loop that should have been out of it.  This adds a
test for the correct behavior.

Also, if a polygon is degenerate, it should not generate stroke
information.
return m_this.style.get('stroke')(d[2], d[3]) ? m_this.style.get('strokeOpacity')(d[0], d[1], d[2], d[3]) : 0;
}
strokeOpacity: util.isFunction(polyStyle.stroke) || !polyStyle.stroke ?
function (d) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

*/
this._build = function () {
createGLLines();
createGLLines(m_this.dataTime().getMTime() < m_this.buildTime().getMTime() && m_geometry);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

Copy link
Member

@aashish24 aashish24 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

@manthey manthey merged commit ce723a7 into master Feb 28, 2018
@manthey manthey deleted the improve-line-updates branch February 28, 2018 18:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants