changeset 1651:e00492e1c0b1

include some of the handler tree optimization code, turned off Ignore-this: 4a965142bc4b194d7955fedc9ab41867
author Drew Perttula <drewp@bigasterisk.com>
date Sat, 10 Jun 2017 10:53:52 +0000
parents fb9e84646320
children c49e56822a98
files light9/web/graph.coffee light9/web/timeline/adjustable.coffee light9/web/timeline/timeline.coffee
diffstat 3 files changed, 24 insertions(+), 11 deletions(-) [+]
line wrap: on
line diff
--- a/light9/web/graph.coffee	Sat Jun 10 10:26:54 2017 +0000
+++ b/light9/web/graph.coffee	Sat Jun 10 10:53:52 2017 +0000
@@ -45,7 +45,7 @@
     console.time("handler #{label}")
     @_rerunHandler(h, null)
     console.timeEnd("handler #{label}")
-    @_logHandlerTree()
+    #@_logHandlerTree()
     
   _rerunHandler: (handler, patch) ->
     handler.patterns = []
@@ -99,13 +99,13 @@
   graphChanged: (patch) ->
     # SyncedGraph is telling us this patch just got applied to the graph.
 
-    allPatchSubjs = @_allPatchSubjs(patch)
+    #allPatchSubjs = @_allPatchSubjs(patch)
     
     rerunInners = (cur) =>
       toRun = cur.innerHandlers.slice()
       for child in toRun
-        match = @_handlerIsAffected(child, allPatchSubjs)
-        log('match', child.label, match)
+        #match = @_handlerIsAffected(child, allPatchSubjs)
+        #log('match', child.label, match)
         #child.innerHandlers = [] # let all children get called again
         
         @_rerunHandler(child, patch)
@@ -113,12 +113,15 @@
     rerunInners(@handlers)
 
   askedFor: (s, p, o, g) ->
+    return
     # SyncedGraph is telling us someone did a query that depended on
     # quads in the given pattern.
     current = @handlerStack[@handlerStack.length - 1]
     if current? and current != @handlers
       current.patterns.push([s, p, o, g])
       #log('push', s,p,o,g)
+    #else
+    #  console.trace('read outside runHandler')
 
 class window.SyncedGraph
   # Main graph object for a browser to use. Syncs both ways with
@@ -189,14 +192,17 @@
     if !Array.isArray(patch.addQuads) || !Array.isArray(patch.delQuads)
       throw new Error("corrupt patch: #{JSON.stringify(patch)}")
 
+    @_validatePatch(patch)
+
+    @_applyPatch(patch)
+    @_client.sendPatch(patch) if @_client
+    console.timeEnd('applyAndSendPatch')
+
+  _validatePatch: (patch) ->
     for qs in [patch.addQuads, patch.delQuads]
       for q in qs
         if not q.graph?
           throw new Error("corrupt patch: #{JSON.stringify(q)}")
-
-    @_applyPatch(patch)
-    @_client.sendPatch(patch) if @_client
-    console.timeEnd('applyAndSendPatch')
     
   _applyPatch: (patch) ->
     # In most cases you want applyAndSendPatch.
--- a/light9/web/timeline/adjustable.coffee	Sat Jun 10 10:26:54 2017 +0000
+++ b/light9/web/timeline/adjustable.coffee	Sat Jun 10 10:53:52 2017 +0000
@@ -104,6 +104,8 @@
     #   getValueForPos
 
     super(@config)
+    if not @config.ctx?
+      throw new Error("missing ctx")
     @config.graph.runHandler(@_syncValue.bind(@), "adj sync #{@config.subj}")
 
   _syncValue: () ->
--- a/light9/web/timeline/timeline.coffee	Sat Jun 10 10:26:54 2017 +0000
+++ b/light9/web/timeline/timeline.coffee	Sat Jun 10 10:53:52 2017 +0000
@@ -400,11 +400,16 @@
     selection: { type: Object, notify: true }
   observers: [
     'onGraph(graph, dia, setAdjuster, song, zoomInX)'
-    'update(song, rowIndex)'
+    'observedUpdate(song, rowIndex)'
     'onZoom(zoomInX)'
     ]
   onGraph: ->
     @graph.runHandler(@update.bind(@), "row notes #{@rowIndex}")
+
+  observedUpdate: (song, rowIndex) ->
+    @update() # old behavior
+    #@graph.runHandler(@update.bind(@), "row notes #{@rowIndex}")
+
   update: (patch) ->
     U = (x) => @graph.Uri(x)
 
@@ -552,9 +557,9 @@
     tMax = @graph.floatValue(worldPts[3].uri, @graph.Uri(':time'))
     tMax - tMin
     
-  _makeCurvePointAdjusters: (yForV, worldPts) ->
+  _makeCurvePointAdjusters: (yForV, worldPts, ctx) ->
     for pointNum in [0...worldPts.length]
-      @_makePointAdjuster(yForV, worldPts, pointNum)
+      @_makePointAdjuster(yForV, worldPts, pointNum, ctx)
 
   _makePointAdjuster: (yForV, worldPts, pointNum, ctx) ->
     U = (x) => @graph.Uri(x)