Groups should not always have to recompute bounds if the child node's bounds change. Currently if any child in a group changes bounds, then the entire group's bounds become invalid. For extremely small cases this is not a problem, but for all others (say, 20+ nodes, some demos I've seen with as many as 2500 nodes) this is extremely problematic. We could use the following reasoning:
- If node was on edge, and now is further out, bounds have changed
(and can use shorter code path to construct the bounds)
- If node was on edge and now is further in, bounds may have changed and
we have to take the long code path of union'ing all the rects
- If node was not on edge and is still not on edge, then bounds have not changed
so use dirty sub region
This can also dramatically improve painting time in some cases since you can have a much smaller dirty region in many cases.
Note that if we didn't have to deal with transformed bounds, this gets even easier since recomputing bounds is faster than recomputing transformed bounds. In the current situation however we should probably do something such as detect if the number of nodes in the group is > 20 and then create the transformed bounds in that case and use this optimization, but otherwise do it the long way. If we get past using tx bounds, then maybe we can change it to be if the group is > 3 then recompute the bounds.
- If node was on edge, and now is further out, bounds have changed
(and can use shorter code path to construct the bounds)
- If node was on edge and now is further in, bounds may have changed and
we have to take the long code path of union'ing all the rects
- If node was not on edge and is still not on edge, then bounds have not changed
so use dirty sub region
This can also dramatically improve painting time in some cases since you can have a much smaller dirty region in many cases.
Note that if we didn't have to deal with transformed bounds, this gets even easier since recomputing bounds is faster than recomputing transformed bounds. In the current situation however we should probably do something such as detect if the number of nodes in the group is > 20 and then create the transformed bounds in that case and use this optimization, but otherwise do it the long way. If we get past using tx bounds, then maybe we can change it to be if the group is > 3 then recompute the bounds.