mln_engine/render/update_parameters.rs
1use std::sync::Arc;
2
3use mln_style::Style;
4use mln_style::collections::VecMap;
5use mln_style::subdivision_granularity::SubdivisionGranularitySetting;
6use mln_style::time::Instant;
7
8use crate::camera::{Elevation, View};
9use crate::map::{MapMode, TerrainOptions};
10use crate::text::glyph::FontFaces;
11use crate::tile_store::TileLodMode;
12
13/// Monotonic invalidation counters for host-dependent expression functions
14/// (`Dependency::HOST`), tracked globally (`all`) and per function name.
15#[derive(Clone, Debug, Default, PartialEq, Eq)]
16pub struct HostExpressionEpochs {
17 pub all: u64,
18 pub by_name: VecMap<String, u64>,
19}
20
21#[derive(Clone)]
22pub struct UpdateParameters {
23 pub style_loaded: bool,
24 pub mode: MapMode,
25 pub pixel_ratio: f32,
26 /// The frame's time; `None` in still modes, which have no clock and show
27 /// every transition and fade as ended.
28 pub time_point: Option<Instant>,
29 /// The view the frame shows.
30 pub view: View,
31 /// The map's zoom range, which the sources load tiles within.
32 pub min_zoom: f64,
33 pub max_zoom: f64,
34 /// Whether a gesture or an animation moves the camera, which the frame
35 /// draws for speed rather than crispness.
36 pub camera_moving: bool,
37
38 /// The version of the style to draw. A renderer compares it with the
39 /// version it drew last ([`mln_style::diff::StyleDiff`]).
40 pub style: Arc<Style>,
41 /// The faces that the style's text draws with: the style's own
42 /// `font-faces`, then the app's fallback faces
43 /// (`style_font_faces`).
44 pub font_faces: Option<Arc<FontFaces>>,
45 pub sprite_loaded: bool,
46 /// The map's feature state. Each render source takes its own, in place
47 /// of what it held.
48 pub feature_states: Arc<crate::source::source_state::FeatureStatesBySource>,
49
50 pub file_source: Option<Arc<dyn crate::storage::FileSource>>,
51 pub prefetch_zoom_delta: u8,
52
53 /// For still image requests, render requested.
54 pub still_image_request: bool,
55 /// Identifies the still image request: each new one retries the
56 /// resources that failed to load.
57 pub still_image_request_id: u64,
58 /// Identifies the update among its map's, which number them from 1 in
59 /// the order they're made. A frame's report names the update it drew
60 /// ([`RendererEvent::RenderFrameFinished`]).
61 ///
62 /// [`RendererEvent::RenderFrameFinished`]: crate::RendererEvent::RenderFrameFinished
63 pub update_id: u64,
64 pub cross_source_collisions: bool,
65 /// The map's [`fade_duration`](crate::map::MapOptions::fade_duration).
66 pub fade_duration: Option<std::time::Duration>,
67 /// Whether symbols and patterns fade: once the map went idle, so what
68 /// it shows first doesn't fade in.
69 pub fades: bool,
70 /// How the map draws its terrain.
71 pub terrain: TerrainOptions,
72 /// The terrain's ground that `view` stands on: the snapshot of it that
73 /// the renderer last reported ([`RendererEvent::TerrainElevation`]) and
74 /// the map applied, or `None`. A frame is complete only when this is the
75 /// renderer's current snapshot, the same `Arc`, or both are `None`. A
76 /// still image draws no other.
77 ///
78 /// [`RendererEvent::TerrainElevation`]: crate::RendererEvent::TerrainElevation
79 pub elevation: Option<Arc<dyn Elevation>>,
80
81 pub tile_lod_min_radius: f64,
82 pub tile_lod_scale: f64,
83 pub tile_lod_pitch_threshold: f64,
84 pub tile_lod_zoom_shift: f64,
85 pub tile_lod_mode: TileLodMode,
86
87 pub subdivision_granularity: SubdivisionGranularitySetting,
88 /// Invalidation epochs for `Dependency::HOST` expression functions.
89 pub host_expression_epochs: Arc<HostExpressionEpochs>,
90}
91
92// The map and a renderer on another thread share an update.
93const _: () = {
94 const fn assert_send_sync<T: Send + Sync>() {}
95 assert_send_sync::<UpdateParameters>();
96};