You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 54de849
Browse filesBrowse the repository at this point in the historyBrowse files
perf(image): reuse image renderings when only overlays change
Moving or resizing a shape, a marker, a cursor or an annotation over an image,
or drawing a new shape, rendered the image again for each mouse move, although
it did not change: e.g. 68 ms per mouse move for a 2048 x 2048 masked image with
the anti-aliasing interpolation, 175 ms with a 200% display scaling.
The interaction handlers now redraw the plot with the new
`BasePlot.replot_overlays` method, which does not increment the replot count
of the plot (`BasePlot.get_replot_count`), unlike `replot` and `invalidate`.
Image items record the offscreen images they draw (`_draw_offscreen`), and
draw them again instead of rendering the item when the key of the rendering
does not change: replot count, plot geometry, item position, LUT and
interpolation values, and data identity (weakly referenced). Only `draw_image`
methods decorated with `reusable_rendering` (which only draw offscreen images)
are concerned: those of `BaseImageItem`, `ImageItem`, `XYImageItem`, the
masked image items and `Histogram2DItem`, but not those of `TrImageItem`
(rotation point), `QuadGridItem` (offscreen image cleared after drawing),
filters and subclasses which override `draw_image`.
The mask overlay of masked images is now rendered in its own offscreen image,
so that the rendering of the image may be drawn again, and it is no longer
rendered when it is fully transparent (no masked pixel and transparent
unmasked area, the default): panning or zooming masked images without masked
pixels is up to 25% faster.
Each mouse move now takes about 4 ms (10 ms with a 200% display scaling),
whatever the interpolation: see the new image interaction benchmark
(plotpy/tests/benchmarks/test_image_interaction.py). Renderings drawn again
are identical to new renderings, and new renderings are unchanged.
Assisted-by: Claude Opus 5.5
0 commit comments