Prepare the renderer for a new frame given the viewport and current plot state. This sets format/viewport/scale, ensures pipelines and grid, and syncs buffers.
(
&mut self,
device: &Device,
queue: &Queue,
viewport: &Viewport,
bounds: &Rectangle,
state: &PlotState,
)
| 542 | // Selection is rebuilt whenever it's active. |
| 543 | self.rebuild_selection(device, queue, state); |
| 544 | |
| 545 | // Hover/pick highlight mask boxes are baked in clip space, so they must be rebuilt |
| 546 | // whenever the camera or viewport changes (zoom/pan/resize), not only when the |
| 547 | // highlighted points change. |
| 548 | if state.highlight_version != self.versions.highlight || offset_changed { |
| 549 | self.rebuild_highlight(device, queue, state); |
| 550 | self.versions.highlight = state.highlight_version; |
| 551 | } |
| 552 | |
| 553 | // Crosshairs are rebuilt every frame when enabled. |
| 554 | self.rebuild_crosshairs(device, queue, state); |
| 555 | } |
| 556 | |
| 557 | /// Prepare the renderer for a new frame given the viewport and current plot state. |
| 558 | /// This sets format/viewport/scale, ensures pipelines and grid, and syncs buffers. |
| 559 | pub(crate) fn prepare_frame( |
| 560 | &mut self, |
| 561 | device: &Device, |
| 562 | queue: &Queue, |
| 563 | viewport: &Viewport, |
| 564 | bounds: &Rectangle, |
| 565 | state: &PlotState, |
| 566 | ) { |
| 567 | self.bounds = *bounds; |
| 568 | let scale_factor = viewport.scale_factor(); |
| 569 | let bounds_width = (bounds.width * scale_factor) as u32; |
| 570 | let bounds_height = (bounds.height * scale_factor) as u32; |
| 571 | let viewport_size = viewport.physical_size(); |
| 572 | |
| 573 | self.set_bounds(bounds_width, bounds_height); |
| 574 | self.set_scale_factor(scale_factor); |
| 575 | // In-pass path (MSAA=1, Android) never runs `encode`, so the offscreen |
| 576 | // MSAA/resolve textures would only waste memory; `encode` self-guards |
| 577 | // by early-returning when `msaa_targets` is `None`. |
no test coverage detected