1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! What a frame's update hands its encode.
use mln_style::collections::VecMap;
use mln_style::color::Color;
use mln_style::time::Instant;
use crate::camera::View;
use crate::render::light::EvaluatedLight;
use crate::render::paint_parameters::TransformParameters;
use crate::render::sky::EvaluatedSky;
/// A layer the frame draws.
#[derive(Clone)]
pub(crate) struct FrameLayer {
/// The id of the layer's render source, `None` for a layer without one.
pub(crate) source: Option<String>,
}
/// A frame, as its update leaves it for its encode: the camera, the values
/// that the whole frame draws with, and the layers it draws.
pub(crate) struct Frame {
pub(crate) transform: TransformParameters,
/// Whether a gesture or an animation moves the camera.
pub(crate) camera_moving: bool,
pub(crate) light: EvaluatedLight,
pub(crate) sky: Option<EvaluatedSky>,
/// Whether the frame draws terrain, which the layers that drape over it
/// don't draw onto, and under which the other 2D layers draw without
/// depth.
pub(crate) terrain: bool,
/// What the frame clears to: transparent black unless the style's
/// bottom layer is a solid background.
pub(crate) background_color: Color,
pub(crate) symbol_fade_change: f32,
/// Whether a transition or a fade still runs, which the next frame
/// continues.
pub(crate) needs_repaint: bool,
/// When, without `needs_repaint`, the map changes next on its own: a
/// symbol placement that isn't due yet.
pub(crate) repaint_at: Option<Instant>,
/// Whether every source, image and tile the frame needs had loaded.
pub(crate) loaded: bool,
pub(crate) placement_changed: bool,
/// The layers the frame draws, by their index in the drawing order.
pub(crate) layers: VecMap<u32, FrameLayer>,
/// When the frame's update started.
pub(crate) started: Instant,
/// When the frame's update started placing symbols.
pub(crate) symbols_started: Instant,
}
impl Frame {
/// A frame of `state` that draws no layers, started now.
pub(crate) fn new(state: &View, camera_moving: bool) -> Self {
let started = Instant::now();
Frame {
transform: TransformParameters::new(state),
camera_moving,
light: EvaluatedLight::default(),
sky: None,
terrain: false,
background_color: Color::new_unchecked(0.0, 0.0, 0.0, 0.0),
symbol_fade_change: 0.0,
needs_repaint: false,
repaint_at: None,
loaded: false,
placement_changed: false,
layers: VecMap::new(),
started,
symbols_started: started,
}
}
}