Mercurial > code > home > repos > light9
changeset 1517:3bb58b74c9c1
timeline: add cache of floats between graph updates for smoother redraws
Ignore-this: dbdc4782855087f4ec12f1d24d440484
author | Drew Perttula <drewp@bigasterisk.com> |
---|---|
date | Wed, 12 Apr 2017 06:04:18 +0000 |
parents | b1fed8880ada |
children | 7480e26c75ed |
files | light9/web/graph.coffee light9/web/timeline/timeline.coffee |
diffstat | 2 files changed, 16 insertions(+), 3 deletions(-) [+] |
line wrap: on
line diff
--- a/light9/web/graph.coffee Thu Apr 06 11:15:56 2017 +0000 +++ b/light9/web/graph.coffee Wed Apr 12 06:04:18 2017 +0000 @@ -136,6 +136,7 @@ # if we had a Store already, this lets N3.Store free all its indices/etc @graph = N3.Store() @_addPrefixes(@prefixes) + @cachedFloatValues = new Map(); _addPrefixes: (prefixes) -> @@ -179,6 +180,7 @@ # In most cases you want applyAndSendPatch. # # This is the only method that writes to @graph! + @cachedFloatValues.clear() for quad in patch.delQuads @graph.removeTriple(quad) for quad in patch.addQuads @@ -233,7 +235,13 @@ throw new Error("too many values: " + JSON.stringify(quads)) floatValue: (s, p) -> - parseFloat(N3.Util.getLiteralValue(@_singleValue(s, p))) + key = s + '|' + p + hit = @cachedFloatValues.get(key) + return hit if hit != undefined + + ret = parseFloat(N3.Util.getLiteralValue(@_singleValue(s, p))) + @cachedFloatValues.set(key, ret) + return ret stringValue: (s, p) -> N3.Util.getLiteralValue(@_singleValue(s, p))
--- a/light9/web/timeline/timeline.coffee Thu Apr 06 11:15:56 2017 +0000 +++ b/light9/web/timeline/timeline.coffee Wed Apr 12 06:04:18 2017 +0000 @@ -433,7 +433,12 @@ @graph.subjects(@uri, @uri, @uri) return if @isDetached? - return + return + + @updateDisplay() + + updateDisplay: -> + # update our note DOM and SVG elements based on the graph U = (x) -> @graph.Uri(x) @@ -559,6 +564,7 @@ addHandler: -> @graph.runHandler(@update.bind(@)) + update: -> U = (x) -> @graph.Uri(x) @effect = @graph.uriValue(@uri, U(':effectClass')) @@ -735,7 +741,6 @@ _line(@ctx, @cursorPath.bot0, @cursorPath.bot1, '#ff0303', '3px') @ctx.stroke() - Polymer is: 'light9-adjusters-canvas' behaviors: [ Polymer.IronResizableBehavior ]