Interface IPatternClipCache
Caches the result of the S-101 pattern-fill priority clip (MapsuiDisplayListRenderer's PatternPriorityClipper) so that re-renders which do not change the clip inputs — most importantly Day/Dusk/Night palette switches — skip the expensive NetTopologySuite overlay work.
public interface IPatternClipCache
Remarks
The clip subtracts higher-priority pattern areas and opaque land out of
each lower-priority semi-transparent raster pattern tile. On the densest
real S-101 cells (a ~64,000-vertex M_QUAL coverage polygon) this costs on
the order of seconds, dominated by a single Buffer(0) validity
repair, and every in-domain speed lever has been shown not to help — so the
per-build cost is treated as irreducible.
Crucially the clip runs once per layer build
(Render(IReadOnlyList<DrawingInstruction>, IFeatureGeometryProvider)), not per frame; pan/zoom
reuses the baked Mapsui features. Render re-fires on dataset load,
palette switch (the dominant trigger), and ECDIS display-setting changes.
Because the clipped boundary geometry is fully determined by the mariner +
ECDIS display state plus the fixed dataset geometry — and is independent of
the palette, which only recolours the pattern tiles applied after
clipping — keying this cache on the portrayal cache key lets a palette
switch reuse the previously computed geometry verbatim.
Both render arms consult this cache. The Mapsui feature ("A") arm wraps its own clip directly; the default TiledScene ("B") arm — which clips inside the shared VectorSceneBuilder when lowering the VectorScene IR — reaches it through a PatternClipMemoizer adapter (MapsuiDisplayListRenderer). Because both arms produce identical clip topology and share this key, the expensive overlay is computed at most once per build regardless of which arm is active.
The abstraction is intentionally minimal so that the single-slot in-memory implementation (InMemoryPatternClipCache) and the disk-backed (WKB sidecar) implementation (DiskPatternClipCache) — which also eliminates the cold first-load cost of previously-seen cells — both fit behind the same contract.
Properties
Hits
Number of GetOrCompute(string, Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>>) calls served from the cache (the expensive clip overlay was skipped). Exposed for diagnostics and tests.
long Hits { get; }
Property Value
Misses
Number of GetOrCompute(string, Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>>) calls that ran the factory (cache miss). Exposed for diagnostics and tests.
long Misses { get; }
Property Value
Methods
GetOrCompute(string, Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>>)
Returns the cached clipped pattern geometry for key,
invoking factory to compute and store it on a miss.
IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)> GetOrCompute(string key, Func<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>> factory)
Parameters
keystringAn opaque key that fully identifies the clip inputs (for S-101 this is the mariner + ECDIS display-state portrayal cache key). The same key must always map to the same clip result.
factoryFunc<IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>>Computes the clipped pattern geometry when the key is not cached. Only invoked on a miss.
Returns
- IReadOnlyList<(string PatternRef, int Priority, Geometry Geometry)>
The clipped pattern entries, each carrying its palette-independent pattern reference, drawing priority, and clipped geometry. On a hit the exact cached instances are returned.