I'm working on gui and I have next realization of base UI component:
So when I want to get absolute component position I need to sum all parent positions with component position.
Also if I want to skip rendering of component, in case if it out of bounds in one of parent components, I need to go through all parents and check this.
This approach is not very fast in case if there are too much components (about 10.000) so my ups decreased from 2600 to 400 updates per second.
Also till rendering I need to calculate scissoring rectangle by intersecting all parent rectangles with current rectangle.
IMO it is also little bit heavy operation in case a big tree of components.
Is there any way to increase it?
Or some fast way to select only visible components without checking every component in list?
Maybe there should be some another component structure?
null
parent. Those are your roots. Now work down from the roots and don't process a branch if its bounding box is not in view. \$\endgroup\$childList
gets replaced by likenextSibling
, a pointer which is null when you're at the end of the list. That'll make it so you don't have to allocate memory dynamically with every single component that has children. \$\endgroup\$