On 03.09.2010 00:48, Alexandre Bergel wrote:
This is partially the case in Mondrian. Objects located outside the window are not rendered. Ehm, my memory was a bit hazy. No problem :-)
In the version I used, MONode>displayOn: did do culling, no such luck for MOEdge though. MOEdge does not do the culling since an edge can be visible without having its two extremity visible. Edges are indeed a problem. Having very non-embedded and very long edges costs a lot. Unless edges can be curved, a simple rect-rect intersection would be quite sufficient for eliminating lots of edges, at least in the zoomed in scenario.
Since MOGraphElement>>elementsToDisplay created a cache of ALL the subnodes and subedges of an element (as part of MONode>displayOn:), well, when the top element was told to displayOn:, it saw itself as visible, then displayOn:'ed all the objects and edges in the model (from the z-order sorted elementsToDisplayCache), leading to culling of offscreen objects, but drawing all edges in the entire model. yes, edges are drawn. Eh, that was maybe a bit cryptic. What I meant was, even if you do culling at the object level, you're still iterating over the entire model deciding what should be rendered every displayOn: call (if only just to perform an isVisible: check).
What you really need (in _addition_ to the current graph-model, which works great for reporting damage rects etc when manipulating the model), is f.ex. a quad-tree structure based on the physical location of the objects, which can be used for culling during the rendering phase.
One way to improve the rendering speed up, is to first display the nodes visible, then continuing the layout in 2 threads, one vertically and another one horizontally (to follow the two scrollbar of the window, since those are likely to be used first when the window appear). But this would imply a major change in the way layout are computed.
Alexandre The simple way to get better performance is by profiling, and doing less. Doing culling properly is a good and (relatively to what you describe) simple first step.
That, and, I just realized, drawing each visible object once. ;) If I'm not wrong (haven't tested it) the elementsToDisplay is created using allSubNodes/EdgesDo: , so what happens in the cases where displayOn: is called to one of the visible subnodes, which also has visible subnodes? Cheers, Henry