pub struct FrameCaptureHook { /* private fields */ }Expand description
Thread-safe hook to request a one-shot capture on the next redraw.
Recommendation: for apps built with ailloli_ui::App, prefer CaptureHandle and
AppBuilder::capture(...) (per logical window or view key, structured results).
This hook suits low-level integrations that already own a
ailloli_ui_render_wgpu::Renderer and call
FrameCaptureHook::capture_if_requested from their own
RedrawRequested loop.
Intended usage:
- keep a clone of this hook in tooling/tests/agent integration
- call
FrameCaptureHook::request_frame_capture_once - in your redraw path, call
FrameCaptureHook::capture_if_requested
Multiple requests made before consumption coalesce into one capture. The release/acquire atomic flag is safe to share across threads.
§Examples
let hook = ailloli_ui_winit::FrameCaptureHook::default();
assert!(!hook.is_requested());
hook.request_frame_capture_once();
assert!(hook.is_requested());Implementations§
Source§impl FrameCaptureHook
Request-latch observation and capture consumption.
impl FrameCaptureHook
Request-latch observation and capture consumption.
Sourcepub fn request_frame_capture_once(&self)
pub fn request_frame_capture_once(&self)
Latches a capture request for the next redraw.
Repeated calls before capture coalesce and do not count separately.
§Examples
let hook = ailloli_ui_winit::FrameCaptureHook::default();
hook.request_frame_capture_once();
hook.request_frame_capture_once();
assert!(hook.is_requested());Sourcepub fn is_requested(&self) -> bool
pub fn is_requested(&self) -> bool
Observes the request latch without consuming it.
§Examples
let hook = ailloli_ui_winit::FrameCaptureHook::default();
assert!(!hook.is_requested());Sourcepub fn capture_if_requested(
&self,
renderer: &mut Renderer,
clear: Color,
layers: &[LayerPass<'_>],
params: CaptureParams,
) -> Result<Option<FrameCaptureResult>, RendererError>
pub fn capture_if_requested( &self, renderer: &mut Renderer, clear: Color, layers: &[LayerPass<'_>], params: CaptureParams, ) -> Result<Option<FrameCaptureResult>, RendererError>
If a capture was requested, consumes the request and captures the frame.
Returns Ok(None) without touching the renderer when no request is
pending. The latch is cleared before rendering, so a render failure is
still a consumed request and a concurrent new request remains pending.
§Errors
Propagates the renderer capture failure.
§Examples
use ailloli_ui_core::Color;
use ailloli_ui_render_wgpu::{CaptureParams, LayerPass, Renderer};
fn capture(hook: &ailloli_ui_winit::FrameCaptureHook, renderer: &mut Renderer) {
let layers: [LayerPass<'_>; 0] = [];
let result: Option<ailloli_ui_winit::FrameCaptureResult> = hook
.capture_if_requested(renderer, Color::BLACK, &layers, CaptureParams::default())
.unwrap();
let _ = result;
}Sourcepub fn capture_single_layer_if_requested(
&self,
renderer: &mut Renderer,
clear: Color,
cmds: &[DrawCmd],
params: CaptureParams,
) -> Result<Option<FrameCaptureResult>, RendererError>
pub fn capture_single_layer_if_requested( &self, renderer: &mut Renderer, clear: Color, cmds: &[DrawCmd], params: CaptureParams, ) -> Result<Option<FrameCaptureResult>, RendererError>
Convenience helper for the common single-layer path (no clipping).
It wraps cmds in one [LayerPass] and otherwise has the same latch,
error, and consumption semantics as Self::capture_if_requested.
§Errors
Propagates the renderer capture failure.
§Examples
use ailloli_ui_core::Color;
use ailloli_ui_render_wgpu::{CaptureParams, Renderer};
fn capture(hook: &ailloli_ui_winit::FrameCaptureHook, renderer: &mut Renderer) {
let result = hook.capture_single_layer_if_requested(
renderer, Color::BLACK, &[], CaptureParams::default()).unwrap();
let _: Option<ailloli_ui_winit::FrameCaptureResult> = result;
}Trait Implementations§
Source§impl Clone for FrameCaptureHook
impl Clone for FrameCaptureHook
Source§fn clone(&self) -> FrameCaptureHook
fn clone(&self) -> FrameCaptureHook
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for FrameCaptureHook
impl Debug for FrameCaptureHook
Auto Trait Implementations§
impl Freeze for FrameCaptureHook
impl RefUnwindSafe for FrameCaptureHook
impl Send for FrameCaptureHook
impl Sync for FrameCaptureHook
impl Unpin for FrameCaptureHook
impl UnwindSafe for FrameCaptureHook
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> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
§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.§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.§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.§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.§impl<T> DowncastSync for T
impl<T> DowncastSync for T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
§impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
impl<A> IntoClickAction<A> for Awhere
A: Clone + 'static,
§fn into_click_action(self) -> ClickAction<A>
fn into_click_action(self) -> ClickAction<A>
Implements the into_click_action helper used by this module.
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§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().