Expand description
The layer contract: what a crate implements to add a layer type that the renderer draws.
A layer type has two halves, which
RegistryBuilder::add_layer_type::<L>()
registers together under the style half’s name:
- The style half, a marker type that implements
mln_style’sStyleLayerType: the type’s name, its kind of source and its properties. - The render half, a struct that implements
Layer, one value per style layer of the type, which names its style half (Layer::Style).
§What a layer type writes
- What it draws from, its
Layer::Input: a geometry source’s tiles, whose features aLayoutlays out into aBucketper tile on a tile worker (Features); a raster or image source’s tiles, each tile’s image (RasterTiles,RasterTile); a raster-dem source’s tiles, each tile’s elevations (DemTiles,DemContents); or nothing, for a layer without a source (NoTiles). The registration doesn’t compile for an input of another kind of source than the style half names. - Its tile values.
Layer::tilemakes what the layer keeps of a frame tile that has data for it, typically the meshes it draws the tile with. The engine keeps the value with the tile until the tile shows the layer something else, leaves the frame, or the layer’s draws drop for a restyle or a switch between Mercator and the globe; it then hands the nexttileof the tile the previous value, so that a layer carries over what it made of contents that are still the tile’s, such as a texture of its image. - Its draws.
Layer::preparepushes the frame’s draws of the layer’s meshes intoDraws, with the values of their programs’ blocks: the engine writes, orders, uploads and draws them in the frame’s passes, at the layer’s place in the layers’ order and depth, so a layer never sees a pass, a stencil or a uniform buffer. A layer may draw into targets of its own first (Draws::target), or ask for the backend’s own commands (Draws::lend,Layer::lend), and free what it makes with them once the GPU is done with it (AfterGpu).
Layer::evaluate says whether and how the layer draws with its freshly
evaluated values (Evaluation); Layer::update brings up to date
what the layer keeps for all its tiles in the frame’s update.
§Terrain
A type says how its layers meet terrain (Layer::TERRAIN,
OnTerrain). One that drapes draws flat into the textures of the
terrain’s tiles rather than onto the frame: the engine prepares the layer
again for each drape it draws, with the drape’s frame
(LayerFrame) and the tiles that overlap the
drape, which draw the same tile values as the map’s frame, so a tile’s
value holds nothing of the frame or the world copy it is first drawn in.
The engine draws a drape again only when what it shows changed. One that
stands on terrain draws the terrain variant of its programs, whose points
read the ground’s height, and one that hides behind the ground reads its
depth (draw::ground).
§Shared targets
An extension can route the draws of other layers, of any type, into
textures of the frame’s size that several layers share, and process them:
a [Router], which it registers
(RegistryBuilder::add_router),
declares the frames’ shared targets from the style, such as from its
extension members (mln_style::member), and routes layers into them,
and a layer reads one in its prepare for the map’s
frame (PrepareCx::read_target). The engine draws each target’s pass before
the frame’s, after the passes of the targets its layers read, and refuses
the routes that don’t fit, whose layers draw on the map.
§Queries
A rendered-feature query finds a tile’s features near its geometry in the
tile’s feature index, padded by the layer’s
query_radius, and keeps those the layer
hits. A layer that draws other than its tiles’
features, such as one without a source, answers from the last frame
(Layer::hit_frame, FrameQuery): its hits come with the tiled
layers’, in the layers’ order, and the query’s filter places them, for
within, in a tile that holds their geometry.
§Buckets
A bucket keeps its vertices and indexes in GeometryVecs and its
data-driven paint values in binders (binders, declared with
paint_property_binders!), which it names in its
upload: the engine moves them into the context’s
stores, where a layer’s tile value reads them
(bucket_vertices, bucket_indexes, paint_vertices), and
rewrites the binders’ values where feature state changes.
The layer and every hook but the layout’s run on the renderer’s thread;
the layout and the bucket are Send, and a bucket crosses to a tile
worker with memory of its own through the worker codec.
Re-exports§
Modules§
- binders
- The binders of a layer type’s data-driven paint values: what a bucket keeps of each feature’s values for its layers’ draws, which feature state rewrites, and the macro that declares a type’s binders.
- bucket
- Buckets: what a tile’s layout makes of a layer group’s features for the
layers’ draws, their vertices, indices and paint values. Workers build
buckets and send them to the render thread, which owns each one once, in
its tile’s contents, as a
Storedbucket behinddyn ErasedBucket. A layer type’sBucketnames its data to anUpload; the engine keeps the rest: the bucket’s identity, whether it uploaded, and the feature-state rewrites of its paint values.
Structs§
- Bucket
Changes - What of a bucket’s vertex data changed since a tile’s draws copied it.
- Bucket
Geometry - The geometry of a tile’s buckets in the context’s stores, by the key of the bucket’s vector it was made of. The tile keeps one per layout result, so it lives as long as the buckets it was made from.
- BuildCx
- What a layout reads and writes while it builds its bucket.
- DemContents
- A raster-dem tile’s DEM, which the tile backfills from its neighbours, and the parts of the tile it draws. The layers and the terrain that read it make their textures and quads of it.
- Evaluate
Cx - What a layer’s
Layer::evaluatereads and completes. - Evaluated
Layer - The values of a layer of the style half
Tfor a frame. - Evaluation
- What a layer’s evaluation says of how it draws with its values.
- Features
- The tiles of a geometry source, whose features the layout
Lturns into a bucket per tile. A tile’s data is itsLayerBucket. - Frame
Query - A rendered-feature query of a layer
L, for what it shows other than its tiles’ features, as of the last update (Layer::hit_frame). - Frame
Tile - A render tile of a frame, with what it holds for a layer of the type
Tand the world copy the layer draws it in. - Geometry
Vec - A bucket’s vertices or indices. The worker fills it through
get_mut; the render thread can move the data out (BucketGeometry), after whichlenstill counts it. - Image
Quad - Where the raster shader puts the unit square that a draw’s vertices span
(0 to
EXTENTon both axes), in its tile’s units: onto the quad of four corners, warped by anImageWarp. The shader evaluates the warp per vertex and interpolates the texture coordinates projectively, so a projective warp draws exactly on two triangles. - Layer
Bucket - A bucket of a layer of the type
Tin a tile’s layout, of the bucket typeB, with the layer’s values it was laid out with and the rest of what the layout’s contents hold for the tile’s draws. - Layer
Values - A layer’s values of its style half
T: its style, its paint values in transition, and their evaluation for the last frame. - Layout
Cx - What a layout reads of its tile while it selects features.
- Prepare
Cx - What a layer’s
Layer::preparereads and changes: its base and values, its values of the tiles it draws (TileMap), which the frame and its drapes share, by the tiles’ own ids (FrameTile::id), and the frame it makes its draws for, the map’s or a drape’s. - Query
Region - Where a query looks in a tile: its geometry in tile units, seen through the camera.
- Surface
Light - The shading that the surface adds to a stack’s drapes, which hold a hillshade’s slopes, as the hillshade’s own draws would shade them: so that a hillshade lit from the viewport keeps its drapes as the map turns, while its light stays where the viewport puts it.
- TileCx
- What a layer’s
Layer::tilereads to make a tile’s value. - Update
Cx - What a layer’s
Layer::updatereads, besides its tiles.
Enums§
- NoTiles
- No tiles, for a layer without a source, which picks what it draws itself.
- OnTerrain
- How a layer type meets terrain.
- Raster
Tile - What a raster tile, or a tile that an image source’s image draws in, holds for a layer: an image, and the parts of the tile it draws.
- Tile
Order - An order a layer draws its source’s tiles in.
Traits§
- Layer
- A layer type’s render half: what it makes of its values, its tiles’
data and the frame, whose hooks the engine calls on a render layer of the
type (
Hosted). The engine keeps the layer’s base, its values of the layer typeType, its value of each tile it draws, aTile, which the map’s frame and every drape the tile overlaps draw, and its draws (Draws) in the frame and in each drape it draws in. - Layout
- How a group of layers of the type
Tthat share their layout becomes a tile’s bucket, on a tile worker:newselects the tile’s features, and once the glyphs and images it asked for are resolved,buildmakes the bucket. - Tile
Input - What a layer of the style half
Tdraws from: a kind of tile and what such a tile holds for the layer, itsData.
Functions§
- bucket_
indexes - The indexes that a bucket’s upload moved
vec, one of its vectors, into, which its tile’sgeometrykeeps and its draws share. - bucket_
vertices - The vertices that a bucket’s upload moved
vec, one of its vectors, into, which its tile’sgeometrykeeps. - copied_
indexes - Indexes holding a copy of
indexes, which a draw owns. - copied_
vertices - Vertices of
context’s store holding a copy ofvertices, which the draws that bind them don’t change: draws replace such vertices instead. - derived_
vertices - The vertices that a bucket’s upload made of
vec, one of its vectors, withGeometryUpload::derive_vertices, which its tile’sgeometrykeeps. - layers_
by_ id - The group’s layers by id, the first of each id kept.
- paint_
vertices - The vertices of a layer’s data-driven paint values: those that a
bucket’s upload moved, which its tile’s
geometrykeeps, or a copy incontext’s store of the values that feature state rewrites, which stay in the bucket, and which the draws copy again each time they change.
Type Aliases§
- Tile
Data - What a frame’s tile holds for a layer of the type
L: itsLayer::Input’sData.