annotorious / annotorious-openseadragon

An OpenSeadragon plugin for annotating high-res zoomable images
https://annotorious.github.io
BSD 3-Clause "New" or "Revised" License
121 stars 42 forks source link

Transform-free rendering #69

Closed rsimon closed 3 years ago

rsimon commented 3 years ago

Unfortunately, SVG had issues with very small and very large numbers (coordinates or scaling factors). Current rendering is based on a single global transform that translates the SVG coordinate space (=native pixel coordinate space of the source image) to screen coords.

This leads to rendering problems in very large images: https://twitter.com/aboutgeo/status/1410859041069355009

There's probably no way around eliminating the transform - and instead live-manipulating all coordinates of all SVG shapes on the screen directly...

Preliminary tests seem to suggest that this does work with reasonable performance. (I tried 2k shapes.) An added benefit of doing the number crunching in code is that other optimizations could be added: e.g. don't render shapes smaller than 3px, or larger than the viewport.

rsimon commented 3 years ago

When dealing with 1k+ shapes, the current bottleneck is actually the sorting that happens to prevent larger shapes from obstructing access to smaller ones underneath. Optimizing this, and adding a spatial index to determine the shapes that need updating should significantly boost the number shapes that Annotorious can handle.