Mercurial > code > home > repos > light9
changeset 1346:2809a8b732f6
optimize graph lookup calls during zoom steps
Ignore-this: ab3499a36e5bc2e495fe4abdd2209e35
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Sun, 05 Jun 2016 02:04:12 +0000 |
parents | 13f758eda3b4 |
children | 5c54a1f94050 |
files | light9/web/adjustable.coffee light9/web/graph.coffee light9/web/timeline.coffee |
diffstat | 3 files changed, 26 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/adjustable.coffee Sun Jun 05 00:49:15 2016 +0000 +++ b/light9/web/adjustable.coffee Sun Jun 05 02:04:12 2016 +0000 @@ -97,15 +97,18 @@ # getValueForPos super(@config) - + _getValue: () -> - @config.graph.floatValue(@config.subj, @config.pred) + # this is a big speedup- callers use _getValue about 4x as much as + # the graph changes and graph.floatValue is slow + @_currentValue getTarget: () -> @config.getTargetTransform(@_getValue()) subscribe: (onChange) -> @config.graph.subscribe @config.subj, @config.pred, null, (patch) => + @_currentValue = @config.graph.floatValue(@config.subj, @config.pred) onChange() continueDrag: (pos) ->
--- a/light9/web/graph.coffee Sun Jun 05 00:49:15 2016 +0000 +++ b/light9/web/graph.coffee Sun Jun 05 02:04:12 2016 +0000 @@ -1,3 +1,5 @@ +log = console.log + # Patch is {addQuads: <quads>, delQuads: <quads>} # <quads> is [{subject: s, ...}, ...]
--- a/light9/web/timeline.coffee Sun Jun 05 00:49:15 2016 +0000 +++ b/light9/web/timeline.coffee Sun Jun 05 02:04:12 2016 +0000 @@ -38,22 +38,26 @@ ko.computed => @debug = ko.toJSON(@viewState) - ko.computed => - @fullZoomX = d3.scaleLinear().domain([0, @viewState.zoomSpec.duration()]).range([0, @width()]) - @zoomInX = d3.scaleLinear().domain([@viewState.zoomSpec.t1(), @viewState.zoomSpec.t2()]).range([0, @width()]) - @dia.setTimeAxis(@width(), @$.zoomed.$.audio.offsetTop, @zoomInX) - @$.adjusters.updateAllCoords() + ko.computed( => + @fullZoomX = d3.scaleLinear().domain([0, @viewState.zoomSpec.duration()]).range([0, @width()]) + @zoomInX = d3.scaleLinear().domain([@viewState.zoomSpec.t1(), @viewState.zoomSpec.t2()]).range([0, @width()]) + @dia.setTimeAxis(@width(), @$.zoomed.$.audio.offsetTop, @zoomInX) + @$.adjusters.updateAllCoords() + ).extend({rateLimit: 5}) - ko.computed => - # zoomInX changing doesn't retrigger this, so I'll do it here - ko.toJS(@viewState.zoomSpec) - - @$.dia.setCursor(@$.audio.offsetTop, @$.audio.offsetHeight, - @$.zoomed.$.time.offsetTop, - @$.zoomed.$.time.offsetHeight, - @fullZoomX, @zoomInX, @viewState.cursor) - - @adjs = @makeZoomAdjs().concat(@persistDemo()) + ko.computed( => + # zoomInX changing doesn't retrigger this, so I'll do it here + ko.toJS(@viewState.zoomSpec) + + @$.dia.setCursor(@$.audio.offsetTop, @$.audio.offsetHeight, + @$.zoomed.$.time.offsetTop, + @$.zoomed.$.time.offsetHeight, + @fullZoomX, @zoomInX, @viewState.cursor) + ) + + setTimeout => + @adjs = @makeZoomAdjs().concat(@persistDemo()) + , 2000 @trackMouse() @bindKeys() @bindWheelZoom()