pub struct GpuCanvasContext<'a, 'b> { /* private fields */ }Expand description
A slice of Window — the only place raw GPU import is reachable.
Handed to a gpu_canvas callback. A plain &mut Window or an App cannot composite a foreign
surface; a canvas narrows the window to exactly the operations that can. Bounded by the canvas,
so paint_surface/paint_texture composite into its bounds.
Implementations§
Source§impl GpuCanvasContext<'_, '_>
impl GpuCanvasContext<'_, '_>
Sourcepub fn paint_surface(&mut self, source: impl Into<SurfaceSource>)
pub fn paint_surface(&mut self, source: impl Into<SurfaceSource>)
Composite source (a dma-buf, a Direct3D texture/view, or a CoreVideo buffer) into the
canvas’s bounds for this frame.
Sourcepub fn paint_texture(
&mut self,
handle: ImportedTextureHandle,
corner_radii: Corners<Pixels>,
opacity: f32,
flip_v: bool,
)
pub fn paint_texture( &mut self, handle: ImportedTextureHandle, corner_radii: Corners<Pixels>, opacity: f32, flip_v: bool, )
Composite a texture produced on the window renderer’s own device into the canvas’s bounds.
Sourcepub fn device<R: GpuRenderer>(&mut self) -> R::Device
pub fn device<R: GpuRenderer>(&mut self) -> R::Device
The window renderer’s device, downcast to R.
This is the same-device producer’s door: it hands back an owned handle (ID3D11Device, a
metal::Device, a wgpu device and queue) that the caller may keep, because a borrow of the
renderer’s device cannot outlive the call. Naming R is the assertion that the window draws
through that backend — a #[cfg]-selected producer already knows — so a mismatch panics; use
try_device to handle it instead.
Sourcepub fn try_device<R: GpuRenderer>(&mut self) -> Option<R::Device>
pub fn try_device<R: GpuRenderer>(&mut self) -> Option<R::Device>
The window renderer’s device, downcast to R, or None when the renderer is not R or has
no device to lend right now.
The fallible form of device, for a producer that degrades — paints a
dma-buf instead of a same-device texture, or skips the frame — rather than asserting the
backend it is running under.
Auto Trait Implementations§
impl<'a, 'b> !RefUnwindSafe for GpuCanvasContext<'a, 'b>
impl<'a, 'b> !Send for GpuCanvasContext<'a, 'b>
impl<'a, 'b> !Sync for GpuCanvasContext<'a, 'b>
impl<'a, 'b> !UnwindSafe for GpuCanvasContext<'a, 'b>
impl<'a, 'b> Freeze for GpuCanvasContext<'a, 'b>
impl<'a, 'b> Unpin for GpuCanvasContext<'a, 'b>
impl<'a, 'b> UnsafeUnpin for GpuCanvasContext<'a, 'b>
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> 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