pub trait Layer: Sized + 'static {
type Style: StyleLayerType;
type Input: TileInput<Self::Style>;
type Tile: 'static;
const TILE_ORDER: TileOrder = TileOrder::ById;
const TERRAIN: OnTerrain = OnTerrain::Flat;
const VOLUME: bool = false;
const ROUTES: bool = _;
const PICKS_TILES: bool = false;
const RESTYLE_KEEPS_TILES: bool = false;
const CROSSFADES: bool = false;
const FADES_TILES: bool = false;
const PLACES: bool = false;
// Required method
fn new(values: &LayerValues<Self::Style>) -> Self;
// Provided methods
fn evaluate(&mut self, _cx: EvaluateCx<'_, Self>) -> Evaluation { ... }
fn surface_light(
&mut self,
_values: &LayerValues<Self::Style>,
_frame: &LayerFrame<'_>,
) -> Option<SurfaceLight> { ... }
fn update(
&mut self,
_cx: UpdateCx<'_, '_, Self>,
_tiles: &[FrameTile<'_, Self>],
) { ... }
fn keeps(
&self,
_values: &LayerValues<Self::Style>,
_tile: &Self::Tile,
) -> bool { ... }
fn tile(
&mut self,
_cx: &mut TileCx<'_, '_, Self>,
_tile: FrameTile<'_, Self>,
_data: TileData<'_, Self>,
_previous: Option<Self::Tile>,
) -> Option<Self::Tile> { ... }
fn prepare(
&mut self,
_cx: &mut PrepareCx<'_, '_, Self>,
_tiles: &[FrameTile<'_, Self>],
_out: &mut Draws,
) { ... }
fn lend(&mut self, _at: LendAt, _lent: Lent<'_>) { ... }
fn query_radius(
_data: TileData<'_, Self>,
_layer: &EvaluatedLayer<Self::Style>,
) -> f32 { ... }
fn hit(
&self,
_values: &LayerValues<Self::Style>,
_region: &QueryRegion<'_>,
_feature: &dyn GeometryTileFeature,
_geometry: &GeometryCollection,
_feature_state: &FeatureState,
) -> bool { ... }
fn hit_frame(&self, _query: &FrameQuery<'_, Self>, _hits: &mut Vec<Feature>) { ... }
}Expand description
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 type Type, its value of each tile it draws, a Tile, 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.
Provided Associated Constants§
Sourceconst TILE_ORDER: TileOrder = TileOrder::ById
const TILE_ORDER: TileOrder = TileOrder::ById
The order the layer draws its source’s tiles in.
Sourceconst VOLUME: bool = false
const VOLUME: bool = false
Whether the layer draws 3D geometry, whose depth it writes in the
range of PaintParameters::depth_mode_for_3d. The layers above the
lowest such layer that draws draw without a depth test, and on the
globe the planet’s depth hides its geometry behind the horizon.
Sourceconst ROUTES: bool = _
const ROUTES: bool = _
Whether the frame’s draws of the layer can draw into a shared target
instead of the map
(Router): not those of 3D geometry.
Sourceconst PICKS_TILES: bool = false
const PICKS_TILES: bool = false
Whether a layer of a type without a source draws tiles it picks in
its update (UpdateCx::pick_tiles), and in a drape the drape’s
tile (PrepareCx::picked); one that picks none draws nothing. One
that doesn’t pick draws without tiles.
Sourceconst RESTYLE_KEEPS_TILES: bool = false
const RESTYLE_KEEPS_TILES: bool = false
Whether the layer’s tile values hold nothing of its style’s values, so that they stay through a restyle.
Sourceconst CROSSFADES: bool = false
const CROSSFADES: bool = false
Whether the type has cross-faded properties, whose evaluation takes the frame’s cross-fade.
Sourceconst FADES_TILES: bool = false
const FADES_TILES: bool = false
Whether the type’s layers draw on the tiles that are fading out while a placement fades their marks out.
Sourceconst PLACES: bool = false
const PLACES: bool = false
Whether the type’s layers place their marks, with a participant in
placement (Placement) that registers
with the type
(add_placing_layer_type).
Required Associated Types§
Sourcetype Style: StyleLayerType
type Style: StyleLayerType
The type’s style half: its name, its kind of source and its properties.
Sourcetype Input: TileInput<Self::Style>
type Input: TileInput<Self::Style>
What the type’s layers draw from: the features of a geometry
source’s tiles, which a layout lays out into a bucket per tile
(Features), a raster or
raster-dem source’s tiles, or none, for a type without a source
(NoTiles). Of another kind of
source than the style half names, the registration doesn’t compile.
Required Methods§
Sourcefn new(values: &LayerValues<Self::Style>) -> Self
fn new(values: &LayerValues<Self::Style>) -> Self
The layer of the values values, before they transition.
Provided Methods§
Sourcefn evaluate(&mut self, _cx: EvaluateCx<'_, Self>) -> Evaluation
fn evaluate(&mut self, _cx: EvaluateCx<'_, Self>) -> Evaluation
Called once the layer’s paint values are evaluated for a frame,
before they become the layer’s: the layer derives the values of
cx.evaluated that its type derives from others, remakes what it
makes of them, such as a color ramp, and says how it draws with them.
Sourcefn surface_light(
&mut self,
_values: &LayerValues<Self::Style>,
_frame: &LayerFrame<'_>,
) -> Option<SurfaceLight>
fn surface_light( &mut self, _values: &LayerValues<Self::Style>, _frame: &LayerFrame<'_>, ) -> Option<SurfaceLight>
The light that the terrain’s surface can shade the layer’s drapes
with in frame, whose draws then put in them what it shades
(LayerFrame::drape_lit); None for a layer whose drapes hold its
colors.
Sourcefn update(
&mut self,
_cx: UpdateCx<'_, '_, Self>,
_tiles: &[FrameTile<'_, Self>],
)
fn update( &mut self, _cx: UpdateCx<'_, '_, Self>, _tiles: &[FrameTile<'_, Self>], )
Called in the frame’s update of the layer with tiles, the frame’s
tiles of its source in the order the layer draws them, each with
what it holds for the layer; none for a type without a source
(NoTiles). The layer collects
here what the update needs of its tiles’ data; a type that places
collects what it places in its participant instead
(Placement::collect). One
without a source that picks its tiles picks them here.
Sourcefn keeps(&self, _values: &LayerValues<Self::Style>, _tile: &Self::Tile) -> bool
fn keeps(&self, _values: &LayerValues<Self::Style>, _tile: &Self::Tile) -> bool
Whether tile, a tile’s value the layer made, still draws the tile
with the layer’s values of the frame. The engine retires a value
the layer doesn’t keep before the layer makes the frame’s draws.
Sourcefn tile(
&mut self,
_cx: &mut TileCx<'_, '_, Self>,
_tile: FrameTile<'_, Self>,
_data: TileData<'_, Self>,
_previous: Option<Self::Tile>,
) -> Option<Self::Tile>
fn tile( &mut self, _cx: &mut TileCx<'_, '_, Self>, _tile: FrameTile<'_, Self>, _data: TileData<'_, Self>, _previous: Option<Self::Tile>, ) -> Option<Self::Tile>
The value of tile, which holds data for the layer, for a tile
the engine keeps no value of: none where the tile shows nothing to
draw. The engine keeps it until the tile shows the layer something
else (another bucket, or contents of another generation), leaves the
frame, or the layer’s draws drop. The map’s frame and every drape
the tile overlaps, in any world copy, draw the same value, so it
holds nothing of the frame or the copy it is first drawn in.
previous is the tile’s value before, if the engine retired it
rather than dropped it: when the tile came to show other contents or
another generation of them, the layer stopped keeping it
(keeps), or its draws dropped for a restyle or the
frame’s projection. A layer takes from it what it made of contents
that are still the tile’s, such as a texture of the tile’s image,
rather than making them again.
Sourcefn prepare(
&mut self,
_cx: &mut PrepareCx<'_, '_, Self>,
_tiles: &[FrameTile<'_, Self>],
_out: &mut Draws,
)
fn prepare( &mut self, _cx: &mut PrepareCx<'_, '_, Self>, _tiles: &[FrameTile<'_, Self>], _out: &mut Draws, )
Makes the layer’s draws of the frame, the map’s or a drape’s, in the
frame’s encode, of a layer that draws in a pass and has tiles to draw,
once the engine made the values of the tiles that had none
(tile): from tiles, the frame’s tiles of the layer,
in the order the update gave them, each with what it holds for the
layer, or in a drape those that overlap the drape’s tile, each in the
world copy the drape draws it in (FrameTile::draw_id); none for a
type without a source, which draws the tiles it picked
(PrepareCx::picked). The layer pushes its draws, with the values
of their blocks, into out, which holds no draws yet, and copies
again into the tile values what changed of their buckets
(TileEntry::take_changes), which every frame that draws them
then draws. The engine then writes, uploads and draws them, and draws
the masks of the layer’s tiles where a draw clips.
Sourcefn lend(&mut self, _at: LendAt, _lent: Lent<'_>)
fn lend(&mut self, _at: LendAt, _lent: Lent<'_>)
Draws with the backend’s commands that the frame lends the layer
at its time in the frame, where its draws asked for them
(Draws::lend): lent, which the layer may use only until this
returns. A frame without commands to lend, such as one outside a
pass at LendAt::Pass, lends none.
What the layer makes with the commands, the engine doesn’t know of:
the layer frees it through work it queues for after the GPU
(Lent::after_gpu), at the latest as it drops, which is when it
leaves the renderer.
Sourcefn query_radius(
_data: TileData<'_, Self>,
_layer: &EvaluatedLayer<Self::Style>,
) -> f32
fn query_radius( _data: TileData<'_, Self>, _layer: &EvaluatedLayer<Self::Style>, ) -> f32
How far outside a feature of data, a tile’s bucket of the layer, a
query still hits it, from layer’s current values and the bucket’s
statistics of them. The engine asks only a type whose input lays
out.
Sourcefn hit(
&self,
_values: &LayerValues<Self::Style>,
_region: &QueryRegion<'_>,
_feature: &dyn GeometryTileFeature,
_geometry: &GeometryCollection,
_feature_state: &FeatureState,
) -> bool
fn hit( &self, _values: &LayerValues<Self::Style>, _region: &QueryRegion<'_>, _feature: &dyn GeometryTileFeature, _geometry: &GeometryCollection, _feature_state: &FeatureState, ) -> bool
Whether a query hits the feature feature with geometry, with
feature_state: whether it intersects region of its tile as the
layer of values draws it at the view’s zoom; false unless a layer
type overrides it.
Sourcefn hit_frame(&self, _query: &FrameQuery<'_, Self>, _hits: &mut Vec<Feature>)
fn hit_frame(&self, _query: &FrameQuery<'_, Self>, _hits: &mut Vec<Feature>)
Adds to hits the features that query‘s geometry hits of what the
layer shows other than its tiles’ features, such as a mark it places
itself, topmost first. As for tiles’ features, a query answers for
the last update: the engine asks a layer that the update would draw,
with its view and values, which may come before a frame draws them,
so a layer answers from query rather than from what it kept from
drawing. The engine names the features’ layer and source and keeps
those that the query’s filter takes.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".