perf(ui-visuals): keep seeking and panning free of redundant work

The filmstrip moves one cached current-frame marker instead of building a
geometry per seek; panning the preview no longer re-applies the wipe clip
or re-sets an unchanged zoom.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 10:29:45 +00:00
1 parent 75508395c3
commit a12ec6b493
3 files changed
+19 -6

No files matched your search

+16 -4
View File
@@ -39,6 +39,9 @@ public sealed class Filmstrip : DrawingElement
private static readonly MarkerKind[] Kinds = Enum.GetValues<MarkerKind>();
/// <summary>The current-frame ▼ at x = 0; moved by <see cref="_markerShift"/> so seeking allocates no geometry.</summary>
private static readonly Geometry CurrentMarker = CreateCurrentMarker();
private LruCache<int, CachedFrame> _cache = new(256);
private readonly HashSet<int> _pending = [];
private CancellationTokenSource _loads = new();
@@ -46,6 +49,7 @@ public sealed class Filmstrip : DrawingElement
private Rect _cells;
private bool _dragging;
private int _wheelDelta;
private readonly TranslateTransform _markerShift = new();
static Filmstrip()
{
@@ -120,10 +124,10 @@ public sealed class Filmstrip : DrawingElement
var outline = new Rect(left + 1, _cells.Top + 1, Math.Max(0, right - left - 2), Math.Max(0, _cells.Height - 2));
dc.DrawRectangle(null, GetPen("Brush.Accent", 2), outline);
var marker = new StreamGeometry();
using (var ctx = marker.Open()) AddTriangleDown(ctx, _strip.XForFrame(frame), 1, 9);
marker.Freeze();
dc.DrawGeometry(GetBrush("Brush.Accent"), null, marker);
_markerShift.X = _strip.XForFrame(frame);
dc.PushTransform(_markerShift);
dc.DrawGeometry(GetBrush("Brush.Accent"), null, CurrentMarker);
dc.Pop();
}
protected override void OnMouseLeftButtonDown(MouseButtonEventArgs e)
@@ -219,6 +223,14 @@ public sealed class Filmstrip : DrawingElement
private static void OnCacheCapacityChanged(DependencyObject d, DependencyPropertyChangedEventArgs e) =>
((Filmstrip)d)._cache.Capacity = (int)e.NewValue;
private static StreamGeometry CreateCurrentMarker()
{
var geometry = new StreamGeometry();
using (var ctx = geometry.Open()) AddTriangleDown(ctx, 0, 1, 9);
geometry.Freeze();
return geometry;
}
/// <summary>Draws <paramref name="image"/> scaled to cover <paramref name="cell"/>, centred and cropped.</summary>
private static void DrawCover(DrawingContext dc, ImageSource image, Rect cell)
{
-1
View File
@@ -76,7 +76,6 @@ public sealed class PreviewSurface : DrawingElement
RenderOptions.SetBitmapScalingMode(_original, mode);
}
if (view.Scale != _overlayScale) RefreshOverlay();
UpdateWipeClip();
}
/// <summary>Rebuilds the overlays (crop mask, region boundary, motion vectors) in image coordinates.</summary>
+3 -1
View File
@@ -363,10 +363,12 @@ public class PreviewViewport : Control
if (ZoomMode == PreviewZoomMode.Actual) view = ViewportMath.SnapOffset(view, dpi);
_view = view;
_surface?.SetView(view, view.Scale * dpi);
var zoom = view.Scale * dpi;
if (zoom == Zoom) return;
_syncingZoom = true;
try
{
SetCurrentValue(ZoomProperty, view.Scale * dpi);
SetCurrentValue(ZoomProperty, zoom);
}
finally
{