pub struct ImageMut<'a> { /* private fields */ }Expand description
Pixels to write into a surface, borrowing it mutably until put
copies them in.
Dropped without put, the image is discarded and the surface left as it was.
No other image of the surface, read or write, can exist alongside it:
ⓘ
fn alias(surface: &mut kodecs_vaapi::Surface<()>, format: kodecs_vaapi::VAImageFormat) {
let read = kodecs_vaapi::Image::create_from(surface, format, surface.size(), surface.size()).unwrap();
let write = kodecs_vaapi::ImageMut::create_uninitialized(surface, format).unwrap();
drop((read, write));
}Nor can a derived image share its surface with anything that writes it, a
GPU operation through &Surface included:
ⓘ
fn alias(surface: &mut kodecs_vaapi::Surface<()>) {
let size = surface.size();
let view = kodecs_vaapi::Image::derive_from(surface, size).unwrap();
let shared: &kodecs_vaapi::Surface<()> = surface;
drop((view, shared));
}An image unmaps and destroys itself only before its surface is destroyed:
ⓘ
fn destroy_first(mut surface: kodecs_vaapi::Surface<()>) {
let size = surface.size();
let _view = kodecs_vaapi::Image::derive_from(&mut surface, size).unwrap();
drop(surface);
}ⓘ
fn destroy_first(mut surface: kodecs_vaapi::Surface<()>, format: kodecs_vaapi::VAImageFormat) {
let _write = kodecs_vaapi::ImageMut::create_uninitialized(&mut surface, format).unwrap();
drop(surface);
}ⓘ
fn alias(surface: &mut kodecs_vaapi::Surface<()>, format: kodecs_vaapi::VAImageFormat) {
let first = kodecs_vaapi::ImageMut::create_uninitialized(surface, format).unwrap();
let second = kodecs_vaapi::ImageMut::create_uninitialized(surface, format).unwrap();
drop((first, second));
}Implementations§
Source§impl<'a> ImageMut<'a>
impl<'a> ImageMut<'a>
Sourcepub fn create_uninitialized<D: SurfaceMemoryDescriptor>(
surface: &'a mut Surface<D>,
format: VAImageFormat,
) -> Result<Self, VaError>
pub fn create_uninitialized<D: SurfaceMemoryDescriptor>( surface: &'a mut Surface<D>, format: VAImageFormat, ) -> Result<Self, VaError>
Creates an image in format at surface’s size without reading the
surface back first, so every byte starts unspecified.
Write every pixel put should not leave unspecified: it
copies the image’s top-left area, the surface’s size, into the surface.
Trait Implementations§
Auto Trait Implementations§
impl<'a> !UnwindSafe for ImageMut<'a>
impl<'a> Forget for ImageMut<'a>
impl<'a> Freeze for ImageMut<'a>
impl<'a> Move for ImageMut<'a>
impl<'a> RefUnwindSafe for ImageMut<'a>
impl<'a> Send for ImageMut<'a>where
Mapping: Send,
impl<'a> Sync for ImageMut<'a>where
Mapping: Sync,
impl<'a> Unpin for ImageMut<'a>
impl<'a> UnsafeUnpin for ImageMut<'a>where
*const ArcInner<Display> is !null: UnsafeUnpin,
PhantomData<ArcInner<Display>>: UnsafeUnpin,
*mut u8: UnsafeUnpin,
PhantomData<&'a mut ()>: UnsafeUnpin,
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