pub struct GpuStreamingChart { /* private fields */ }Expand description
GPU-accelerated streaming chart for high-performance live data visualization.
Combines StreamingChart functionality with GPU-accelerated renderers for
efficient rendering of large datasets. The GPU path is automatically used
when series exceed GPU_RENDER_THRESHOLD points.
Supports all chart types:
- Line: GPU-instanced line segments via
GpuChartLineRenderer - Scatter: GPU-instanced points via
GpuChartScatterRenderer - Bar: GPU-instanced quads via
GpuChartBarRenderer - Area: GPU-instanced fill + lines via
GpuChartAreaRenderer
§Performance Characteristics
| Operation | CPU Path | GPU Path |
|---|---|---|
| Data append | O(n) tessellation | O(n) buffer upload (once) |
| Pan/zoom | O(n) tessellation | O(1) uniform update |
| Render | O(n) triangles | O(n) instances |
§Text Rendering (with chart-text feature)
When the chart-text feature is enabled, use with_text() to add text rendering:
let font_system = FontSystem::with_system_fonts();
let gpu_chart = GpuStreamingChart::new(chart, context.clone(), surface_format)
.with_text(context.clone(), font_system);§Example
use astrelis_geometry::chart::*;
use astrelis_render::GraphicsContext;
use std::sync::Arc;
let context: Arc<GraphicsContext> = /* ... */;
let surface_format = window.surface_format();
let chart = ChartBuilder::line()
.add_series("Sensor", &[])
.interactive(true)
.build();
let mut gpu_chart = GpuStreamingChart::new(chart, context, surface_format);
// In update loop:
gpu_chart.push_time_point(0, time, value);
gpu_chart.auto_scroll(AxisId::X_PRIMARY, 60.0);
// Before rendering:
let bounds = Rect::new(0.0, 0.0, 800.0, 600.0);
gpu_chart.prepare_render(&bounds);
// In render pass:
gpu_chart.render(&mut pass, viewport, &bounds);Implementations§
Source§impl GpuStreamingChart
impl GpuStreamingChart
Sourcepub fn new(
chart: Chart,
context: Arc<GraphicsContext>,
target_format: TextureFormat,
) -> Self
pub fn new( chart: Chart, context: Arc<GraphicsContext>, target_format: TextureFormat, ) -> Self
Create a new GPU-accelerated streaming chart.
The target_format must match the render target this chart will draw into.
Sourcepub fn from_streaming(
streaming: StreamingChart,
context: Arc<GraphicsContext>,
target_format: TextureFormat,
) -> Self
pub fn from_streaming( streaming: StreamingChart, context: Arc<GraphicsContext>, target_format: TextureFormat, ) -> Self
Create from an existing streaming chart.
The target_format must match the render target this chart will draw into.
Sourcepub fn force_gpu_rendering(self, force: bool) -> Self
pub fn force_gpu_rendering(self, force: bool) -> Self
Force GPU rendering regardless of data size.
Useful for testing or when you know data will grow large.
Sourcepub fn streaming(&self) -> &StreamingChart
pub fn streaming(&self) -> &StreamingChart
Get a reference to the underlying streaming chart.
Sourcepub fn streaming_mut(&mut self) -> &mut StreamingChart
pub fn streaming_mut(&mut self) -> &mut StreamingChart
Get a mutable reference to the underlying streaming chart.
Sourcepub fn line_renderer(&self) -> &GpuChartLineRenderer
pub fn line_renderer(&self) -> &GpuChartLineRenderer
Get a reference to the GPU line renderer.
Sourcepub fn line_renderer_mut(&mut self) -> &mut GpuChartLineRenderer
pub fn line_renderer_mut(&mut self) -> &mut GpuChartLineRenderer
Get a mutable reference to the GPU line renderer.
Sourcepub fn scatter_renderer(&self) -> &GpuChartScatterRenderer
pub fn scatter_renderer(&self) -> &GpuChartScatterRenderer
Get a reference to the GPU scatter renderer.
Sourcepub fn bar_renderer(&self) -> &GpuChartBarRenderer
pub fn bar_renderer(&self) -> &GpuChartBarRenderer
Get a reference to the GPU bar renderer.
Sourcepub fn area_renderer(&self) -> &GpuChartAreaRenderer
pub fn area_renderer(&self) -> &GpuChartAreaRenderer
Get a reference to the GPU area renderer.
Sourcepub fn is_gpu_enabled(&self) -> bool
pub fn is_gpu_enabled(&self) -> bool
Check if GPU rendering is currently enabled.
Sourcepub fn append_data(&mut self, series_idx: usize, points: &[DataPoint])
pub fn append_data(&mut self, series_idx: usize, points: &[DataPoint])
Append data points to a series.
Sourcepub fn push_point(
&mut self,
series_idx: usize,
point: DataPoint,
max_points: Option<usize>,
)
pub fn push_point( &mut self, series_idx: usize, point: DataPoint, max_points: Option<usize>, )
Push a single point with optional sliding window.
Sourcepub fn set_data(&mut self, series_idx: usize, data: Vec<DataPoint>)
pub fn set_data(&mut self, series_idx: usize, data: Vec<DataPoint>)
Replace all data in a series.
Sourcepub fn clear_data(&mut self, series_idx: usize)
pub fn clear_data(&mut self, series_idx: usize)
Clear all data from a series.
Sourcepub fn push_time_point(&mut self, series_idx: usize, time: f64, value: f64)
pub fn push_time_point(&mut self, series_idx: usize, time: f64, value: f64)
Push a time/value point to a series.
Sourcepub fn push_time_point_windowed(
&mut self,
series_idx: usize,
time: f64,
value: f64,
max_points: usize,
)
pub fn push_time_point_windowed( &mut self, series_idx: usize, time: f64, value: f64, max_points: usize, )
Push a time/value point with sliding window.
Sourcepub fn auto_scroll(&mut self, axis_id: AxisId, window_size: f64)
pub fn auto_scroll(&mut self, axis_id: AxisId, window_size: f64)
Configure auto-scrolling for an axis.
Sourcepub fn disable_auto_scroll(&mut self, axis_id: AxisId)
pub fn disable_auto_scroll(&mut self, axis_id: AxisId)
Disable auto-scrolling for an axis.
Sourcepub fn mark_view_changed(&mut self)
pub fn mark_view_changed(&mut self)
Notify that the view has changed (pan/zoom).
Sourcepub fn mark_style_changed(&mut self)
pub fn mark_style_changed(&mut self)
Notify that style has changed.
Sourcepub fn mark_bounds_changed(&mut self)
pub fn mark_bounds_changed(&mut self)
Notify that bounds have changed (widget resized).
Sourcepub fn dirty_flags(&self) -> ChartDirtyFlags
pub fn dirty_flags(&self) -> ChartDirtyFlags
Get the current dirty flags.
Sourcepub fn prepare_render(&mut self, bounds: &Rect)
pub fn prepare_render(&mut self, bounds: &Rect)
Prepare the chart for rendering.
This prepares both the coordinate cache and GPU buffers as needed. Call this once per frame before rendering.
Sourcepub fn prepare_render_with_result(&mut self, bounds: &Rect) -> PrepareResult
pub fn prepare_render_with_result(&mut self, bounds: &Rect) -> PrepareResult
Prepare with detailed result information.
Sourcepub fn render(
&self,
pass: &mut RenderPass<'_>,
viewport: Viewport,
geometry_renderer: &mut GeometryRenderer,
bounds: &Rect,
)
pub fn render( &self, pass: &mut RenderPass<'_>, viewport: Viewport, geometry_renderer: &mut GeometryRenderer, bounds: &Rect, )
Render the chart to a render pass.
This uses GPU-accelerated rendering for large datasets and falls back to tessellation for small datasets.
§Arguments
pass- The render pass to draw intoviewport- The viewport for renderinggeometry_renderer- The geometry renderer for non-GPU elementsbounds- The chart bounds
Sourcepub fn statistics(&self) -> GpuStreamingStatistics
pub fn statistics(&self) -> GpuStreamingStatistics
Get statistics about the streaming data.
Methods from Deref<Target = Chart>§
Sourcepub fn series_len(&self, series_idx: usize) -> usize
pub fn series_len(&self, series_idx: usize) -> usize
Get the number of data points in a series.
Sourcepub fn total_points(&self) -> usize
pub fn total_points(&self) -> usize
Get the total number of data points across all series.
Sourcepub fn data_bounds_for_axis(&self, axis_id: AxisId) -> Option<(f64, f64)>
pub fn data_bounds_for_axis(&self, axis_id: AxisId) -> Option<(f64, f64)>
Get the combined bounds of all series for a specific axis.
Sourcepub fn data_bounds(&self) -> Option<(DataPoint, DataPoint)>
pub fn data_bounds(&self) -> Option<(DataPoint, DataPoint)>
Get the combined bounds of all series.
Sourcepub fn axis_range(&self, axis_id: AxisId) -> (f64, f64)
pub fn axis_range(&self, axis_id: AxisId) -> (f64, f64)
Get the effective range for an axis.
Trait Implementations§
Source§impl Debug for GpuStreamingChart
impl Debug for GpuStreamingChart
Source§impl Deref for GpuStreamingChart
impl Deref for GpuStreamingChart
Source§impl From<(Chart, Arc<GraphicsContext>, TextureFormat)> for GpuStreamingChart
impl From<(Chart, Arc<GraphicsContext>, TextureFormat)> for GpuStreamingChart
Source§fn from(
(chart, context, target_format): (Chart, Arc<GraphicsContext>, TextureFormat),
) -> Self
fn from( (chart, context, target_format): (Chart, Arc<GraphicsContext>, TextureFormat), ) -> Self
Auto Trait Implementations§
impl Freeze for GpuStreamingChart
impl !RefUnwindSafe for GpuStreamingChart
impl Send for GpuStreamingChart
impl Sync for GpuStreamingChart
impl Unpin for GpuStreamingChart
impl UnsafeUnpin for GpuStreamingChart
impl !UnwindSafe for GpuStreamingChart
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can
then be further downcast into Box<ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be
further downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more