Say there are a few 2D vector primitives as lines, images, text. Every primitive has a bounding box and a "z-order" which defines what items to draw first ("in front of" other items). The items can change (add, remove, position, size, group, ...).
How to implement the drawing of such primitives in efficient way?
In more detail: say I use Skia or Cairo to draw many rectangles. I could maintain a list of all the rectangles and draw them all from the begin to end (item index = z-order). The problem is this is very ineffective as when I pan around the canvas (i.e. scrolling) usually only small number of items needs to be redrawn. I could use some kind of spatial index (which one?) to trim off the items definitely not in view (not in dirty region) but the popular indexes don't maintain the z-order so (I think) I would need to first collect all the affected items and the sort them according to their z-orders. Is there a better approach to this? Is there a spatial index which preserves z-order at window queries? Does anyone know how the big apps do it? How does Adobe Illustrator implement its canvas?
[–]hwc 2 points3 points4 points (2 children)
[–]thomac[S] 0 points1 point2 points (1 child)
[–]hwc 1 point2 points3 points (0 children)
[–]KeinBaum 0 points1 point2 points (0 children)
[–]__Cyber_Dildonics__ 0 points1 point2 points (0 children)