tkihira/Tombo.js — pull request #53 by mootoh (2013-12-16 08:17:42+00:00)
Title: Viewport Partitioning Optimization

Further optimization for viewport clipping.

### Why
Reduce the number of DisplayNode to consider in rendering. The bottleneck is this function (https://github.com/tkihira/Tombo.js/blob/feature/streaming/src/Eye/Layer.jsx#L288), which filters the DisplayNode to render. If we have a huge Layer and tons of DisplayNode in it, Renderer has to look at each node even though most of nodes are out of viewport.

### How
- Slices a Layer into sub layers (introduces SubLayer class) based on the world size (Layer size) and viewport size (Eye size).
- Only take a look at 9 sublayers surrounding the viewport.
- If a DisplayNode moves around, update its sublayer if necessary.

### Caveat
Depth sort between sublayers will not work correctly. I think it is an edge case though.