pub struct CallbackImageSource<Fa, Fp>where
Fa: FnMut() -> OpenXrHostResult<OpenXrImageFrame<FrameToken>> + Send,
Fp: FnMut(FrameToken) -> OpenXrHostResult<()> + Send,{ /* private fields */ }Expand description
Convenience source helper for custom runtime glue.
Both callbacks are serialized independently. Callback failures are returned to the target; a poisoned callback mutex is converted to the matching host error variant.
§Examples
use ailloli_ui_openxr::{CallbackImageSource, OpenXrHostResult, OpenXrImageFrame};
use ailloli_ui_render::render_target::PhysicalExtent;
let _source = CallbackImageSource::new(
PhysicalExtent::new(1024, 1024),
wgpu::TextureFormat::Rgba8Unorm,
|| -> OpenXrHostResult<OpenXrImageFrame<u64>> { panic!("provided by host") },
|_token| Ok(()),
);Implementations§
Source§impl<Fa, Fp> CallbackImageSource<Fa, Fp>where
Fa: FnMut() -> OpenXrHostResult<OpenXrImageFrame<FrameToken>> + Send,
Fp: FnMut(FrameToken) -> OpenXrHostResult<()> + Send,
impl<Fa, Fp> CallbackImageSource<Fa, Fp>where
Fa: FnMut() -> OpenXrHostResult<OpenXrImageFrame<FrameToken>> + Send,
Fp: FnMut(FrameToken) -> OpenXrHostResult<()> + Send,
Sourcepub fn new(
size: PhysicalExtent,
format: TextureFormat,
acquire: Fa,
present: Fp,
) -> Self
pub fn new( size: PhysicalExtent, format: TextureFormat, acquire: Fa, present: Fp, ) -> Self
Creates a callback source with fixed physical size and texture format.
The callbacks are not invoked by this constructor. acquire must return
a texture matching size and format; present receives its token.
§Examples
use ailloli_ui_openxr::{CallbackImageSource, OpenXrHostResult, OpenXrImageFrame};
use ailloli_ui_render::render_target::PhysicalExtent;
let source = CallbackImageSource::new(
PhysicalExtent::new(800, 600),
wgpu::TextureFormat::Bgra8Unorm,
|| -> OpenXrHostResult<OpenXrImageFrame<u64>> { panic!() },
|_token| Ok(()),
);
assert_eq!(ailloli_ui_openxr::OpenXrImageSource::size(&source).width, 800);Trait Implementations§
Source§impl<Fa, Fp> OpenXrImageSource for CallbackImageSource<Fa, Fp>where
Fa: FnMut() -> OpenXrHostResult<OpenXrImageFrame<FrameToken>> + Send,
Fp: FnMut(FrameToken) -> OpenXrHostResult<()> + Send,
impl<Fa, Fp> OpenXrImageSource for CallbackImageSource<Fa, Fp>where
Fa: FnMut() -> OpenXrHostResult<OpenXrImageFrame<FrameToken>> + Send,
Fp: FnMut(FrameToken) -> OpenXrHostResult<()> + Send,
Source§type FrameToken = u64
type FrameToken = u64
Token that identifies an acquired image until presentation. Read more
Source§type TextureFormat = TextureFormat
type TextureFormat = TextureFormat
Backend texture-format value returned by
Self::format. Read moreSource§fn size(&self) -> PhysicalExtent
fn size(&self) -> PhysicalExtent
Returns the physical pixel extent of future acquired textures. Read more
Source§fn acquire(&self) -> OpenXrHostResult<OpenXrImageFrame<Self::FrameToken>>
fn acquire(&self) -> OpenXrHostResult<OpenXrImageFrame<Self::FrameToken>>
Acquires one writable texture and its presentation token. Read more
Source§fn present(&self, token: Self::FrameToken) -> OpenXrHostResult<()>
fn present(&self, token: Self::FrameToken) -> OpenXrHostResult<()>
Presents or releases the image identified by
token. Read moreSource§fn pre_present_notify(&self)
fn pre_present_notify(&self)
Notifies the source immediately before renderer presentation work. Read more
Auto Trait Implementations§
impl<Fa, Fp> Freeze for CallbackImageSource<Fa, Fp>
impl<Fa, Fp> RefUnwindSafe for CallbackImageSource<Fa, Fp>
impl<Fa, Fp> Send for CallbackImageSource<Fa, Fp>
impl<Fa, Fp> Sync for CallbackImageSource<Fa, Fp>
impl<Fa, Fp> Unpin for CallbackImageSource<Fa, Fp>
impl<Fa, Fp> UnwindSafe for CallbackImageSource<Fa, Fp>
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
Mutably borrows from an owned value. Read more
§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>
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>
Converts
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>
Converts
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