Incular logoIncular
API ReferenceLayout Widgets

SnapshotWidget

Retained raster snapshot boundary for expensive subtrees.

SnapshotWidget renders its child into a retained raster snapshot (RepaintBoundary lowering), so repainting parents never re-rasterizes it.

use incular::prelude::*;

fn main() -> Result<(), Box<dyn std::error::Error>> {
    let app = Application::new(|_cx| {
        Container::builder()
            .padding(EdgeInsets::all(24.0))
            .alignment(Alignment::CENTER)
            .child(SnapshotWidget::new(Text::new("Snapshotted")))
            .build()
            .into()
    })?;
    incular::run(app)?;
    Ok(())
}

PerformanceOverlay is the inert mount point the runtime updates in place when the performance overlay is installed (see install_performance_overlay).

use incular::prelude::*;

fn main() {
    let _overlay = PerformanceOverlay::new();
    println!("overlay created");
    let app = Application::new(|_cx| {
        SnapshotWidget::new(Text::new("Hi")).into()
    })
    .expect("valid application");
    incular::run(app).expect("run application");
}

Related: Opacity, Application.