Expand description
Where the pixels come from: a TileSource the application
implements, asynchronous and live.
Experimental: may change in any release
(docs/stability.md).
- The viewport asks for tiles (
TileSource::request): square tiles ofTileRequest::sizepixels at a scale of the image, first a proxy of the whole image at a coarse scale, then the exact tiles of what is visible at the view’s own scale. A call never blocks: the source works elsewhere (a thread, an engine, a server). - The source delivers through a
TileSink(fromViewportState::sink), from any thread; the sink wakes the interface. - Cancellation: a request the view no longer needs (the user
panned on) has its
CancelTokenset; the source may check it and drop the work. A late tile is dropped by the viewport anyway. - Live content: when the image changes (a parameter moved), the
source says which region with
TileSink::changed; the tiles there stay on screen until their replacements arrive. - Pixels come either display-ready (
Pixels::Display, the source applied its own display transform on the CPU) or scene-referred (Pixels::Scene, linear floats the viewport passes through the display transform, on the GPU when it can). - Device tiles (feature
wgpu): a source rendering on the GPU hands over a texture or a storage buffer that lives on the render device (TileSink::deliver_device, see thedevicemodule); nothing is copied, and the display transform runs in the shader as for scene pixels. - Where the pixels are converted: by default the sink converts
each tile on the thread that delivers it (the display transform on
the CPU path, the half-float texels on the GPU path), so tiles
arrive ready to upload and the interface thread only hands them to
the GPU, within an upload budget per frame. With
ViewportState::set_prepare_on_worker(false), the interface thread converts each tile when it takes it in.
Structs§
- Cancel
Token - Set when the viewport no longer needs a request.
- Readout
- The values under a pixel, from the source.
- Request
Id - A request’s id, unique per viewport state.
- Scale
- A scale of the image (scaled pixels per image pixel, at most 1), hashable.
- Stats
- What a source does with the sink, counted;
Stats::snapshotfor the debug bridge and the tests. - Tile
- A tile delivered.
- TileKey
- A tile: column
xand rowyof the grid ofsize-pixel squares covering the image scaled byscale. - Tile
Request - One tile wanted.
- Tile
Sink - Where a source delivers; cheap to clone, usable from any thread.
Enums§
- Pixels
- A tile’s pixels, row by row,
size[0] × size[1]. - Quality
- A tile’s quality.
- Side
- Which image a tile belongs to: the one edited, or the “before” of a comparison.
Constants§
- NOTICES
- How many changes and readouts wait at most for the viewport to take them in. Tiles and failures answer requests, which the viewport makes only when drawn; changes and readouts come when the source says, so a viewport no longer drawn (a tab behind another) would keep them all. Past this many, a change becomes one change of the whole image, kept as a flag, and a readout is dropped (the next one replaces it).
Traits§
- Tile
Source - The application’s pixels. Every method returns at once; work happens
elsewhere and comes back through the
TileSink.