- Collapse the tile cache dependency generation into the visibility pass.
This reduces the number of primitive passes required. There is still a lot of duplicated work in update_prim_dependencies, that we can remove, now that we build the clip chain instance at the same time.
- Move local clip rects from being in the primitive template to the primitive instance.
Gecko provides primitives with different local clip rects, as you scroll through the scene, clipped to the display port. This was resulting in primitives being interned and invalidating even though the content was the same. Make the local clip rect an instance property, so that the interned ids remain constant. This is an overall simplification and optimization anyway.
- Add a concept of correlating and estimating the offset between two display lists.
When a new display list is sent by Gecko, the new scroll offsets are baked into the local positions, and the clip-scroll node transforms are modified. Unfortunately, sometimes the display list has also been scrolled some amount between those display lists arriving. This change attempts to work out what that offset is, so that the tile grid can be correctly aligned in order to be used on the new display list. This is a really sub-optimal solution - it seems to work, but is not elegant at all. We should revisit this in the future to find a better long term solution. If the correlation fails, it doesn't cause any correctness issue - just a performance issue in that the tiles will be invalidated and not reused for that frame.
- Remove the global transforms array in the tile cache.
This is redundant, unused code.
- Store the local clip rect as a dependency of the primitive descriptor.
Now that the local clip rect is a per-instance property, it needs to be handled as a dependency. As an additional optimization, include any other local clip rects in this field, to avoid storing clip transform dependencies.
- Store clip vertices as tile-relative.
Since the local positions of clip nodes can change when Gecko supplies a new display list with baked offsets, we need to ensure a tile-relative value is stored for clip vertices.
- Fix transform dependency inaccuracies.
Between display lists, the relative transform determination code can result in small discrepancies in the transforms produced, which was causing unnecessary invalidations. Since small values in transforms can sometimes result in very large differences, just quantizing the values in the transform is not straightforward. Instead, transform a fixed vertex position by the transform, and compare those rounded output positions to see if the relative transform has changed.