euv_core/platform/viewport/struct.rs
1use super::*;
2
3/// Authoritative lossless viewport metrics separating exact logical CSS/point bounds from exact physical backing pixels and DPI scale.
4#[derive(Clone, Copy, Debug, Getter, PartialEq)]
5pub struct ViewportMetrics {
6 /// Exact logical viewport width in CSS/point coordinates without integer truncation.
7 #[get(type(copy))]
8 pub(crate) logical_width: f64,
9 /// Exact logical viewport height in CSS/point coordinates without integer truncation.
10 #[get(type(copy))]
11 pub(crate) logical_height: f64,
12 /// Authoritative physical backing surface width in device pixels.
13 #[get(type(copy))]
14 pub(crate) physical_width: u32,
15 /// Authoritative physical backing surface height in device pixels.
16 #[get(type(copy))]
17 pub(crate) physical_height: u32,
18 /// Active display DPI scale multiplier clamped strictly to `[VIEWPORT_SCALE_MIN, VIEWPORT_SCALE_MAX]`.
19 #[get(type(copy))]
20 pub(crate) scale_factor: f32,
21}
22
23/// Hardware or browser single-surface dimension and pixel-area limits driving lossless tile partitioning.
24#[derive(Clone, Copy, Debug, Eq, Getter, PartialEq)]
25pub struct SurfaceTileLimit {
26 /// Maximum supported texture or drawing-buffer extent along a single axis in physical pixels.
27 #[get(type(copy))]
28 pub(crate) max_texture_dim: u32,
29 /// Maximum supported single drawing-buffer pixel area (`width * height`) in physical pixels.
30 #[get(type(copy))]
31 pub(crate) max_surface_area: u64,
32}
33
34/// Single 1:1 physical surface tile mapped to its exact logical CSS/point bounds with zero resampling.
35#[derive(Clone, Copy, Debug, Getter, PartialEq)]
36pub struct SurfaceTileRect {
37 /// Zero-based horizontal tile column index.
38 #[get(type(copy))]
39 pub(crate) tile_col: u32,
40 /// Zero-based vertical tile row index.
41 #[get(type(copy))]
42 pub(crate) tile_row: u32,
43 /// Inclusive starting physical X coordinate in device pixels.
44 #[get(type(copy))]
45 pub(crate) physical_x: u32,
46 /// Inclusive starting physical Y coordinate in device pixels.
47 #[get(type(copy))]
48 pub(crate) physical_y: u32,
49 /// Exact tile width in physical device pixels (`1:1` with backing pixels).
50 #[get(type(copy))]
51 pub(crate) physical_width: u32,
52 /// Exact tile height in physical device pixels (`1:1` with backing pixels).
53 #[get(type(copy))]
54 pub(crate) physical_height: u32,
55 /// Exact logical X origin in CSS/point coordinates.
56 #[get(type(copy))]
57 pub(crate) logical_x: f64,
58 /// Exact logical Y origin in CSS/point coordinates.
59 #[get(type(copy))]
60 pub(crate) logical_y: f64,
61 /// Exact logical width in CSS/point coordinates.
62 #[get(type(copy))]
63 pub(crate) logical_width: f64,
64 /// Exact logical height in CSS/point coordinates.
65 #[get(type(copy))]
66 pub(crate) logical_height: f64,
67}
68
69/// Complete lossless surface partitioning plan covering 100% of a viewport at full 1:1 physical DPI without dropping scale.
70#[derive(Clone, Debug, Getter, PartialEq)]
71pub struct TiledSurfacePlan {
72 /// Authoritative source viewport metrics covered by this plan.
73 #[get(type(copy))]
74 pub(crate) viewport: ViewportMetrics,
75 /// Hardware single-surface limits enforced on every generated tile.
76 #[get(type(copy))]
77 pub(crate) limits: SurfaceTileLimit,
78 /// Number of horizontal tile columns (`1` when untiled).
79 #[get(type(copy))]
80 pub(crate) columns: u32,
81 /// Number of vertical tile rows (`1` when untiled).
82 #[get(type(copy))]
83 pub(crate) rows: u32,
84 /// Whether the viewport exceeded hardware single-surface limits and required multi-tile partitioning.
85 #[get(type(copy))]
86 pub(crate) tiled: bool,
87 /// Row-major ordered list of non-overlapping tiles whose union equals the exact physical viewport.
88 pub(crate) tiles: Vec<SurfaceTileRect>,
89}
90
91/// Pointer hit-test resolution mapping a logical viewport coordinate onto an exact owning surface tile and physical pixel position.
92#[derive(Clone, Copy, Debug, Getter, PartialEq)]
93pub struct TileHitResult {
94 /// Row-major index into `TiledSurfacePlan::tiles`.
95 #[get(type(copy))]
96 pub(crate) tile_index: usize,
97 /// Zero-based horizontal column index of the hit tile.
98 #[get(type(copy))]
99 pub(crate) tile_col: u32,
100 /// Zero-based vertical row index of the hit tile.
101 #[get(type(copy))]
102 pub(crate) tile_row: u32,
103 /// Tile-local physical X coordinate in device pixels.
104 #[get(type(copy))]
105 pub(crate) local_physical_x: f64,
106 /// Tile-local physical Y coordinate in device pixels.
107 #[get(type(copy))]
108 pub(crate) local_physical_y: f64,
109 /// Global viewport physical X coordinate in device pixels.
110 #[get(type(copy))]
111 pub(crate) global_physical_x: f64,
112 /// Global viewport physical Y coordinate in device pixels.
113 #[get(type(copy))]
114 pub(crate) global_physical_y: f64,
115}