Struct cros_libva::Picture
source · pub struct Picture<S: PictureState, T> { /* private fields */ }Expand description
A Surface that is being rendered into.
This struct abstracts the decoding flow using vaBeginPicture, vaRenderPicture,
vaEndPicture and vaSyncSurface in a type-safe way.
The surface will have valid picture data after all the stages of decoding are called.
The T generic parameter must be Borrow<Surface<_>>, i.e. it can be Surface directly or
some other type that contains one.
No constraint on T is specified in this declaration because specifying it here would force us
to add the generic argument of Surface to this type as well, turning it into a type with 3
generics, one of which is redundant. To avoid that we leave T unconstrained and instead
constrain the methods that require to act on it as a Surface.
Implementations§
source§impl<T> Picture<PictureNew, T>
impl<T> Picture<PictureNew, T>
sourcepub fn new<D: SurfaceMemoryDescriptor>(
timestamp: u64,
context: Rc<Context>,
surface: T,
) -> Self
pub fn new<D: SurfaceMemoryDescriptor>( timestamp: u64, context: Rc<Context>, surface: T, ) -> Self
Creates a new Picture with a given timestamp. surface is the underlying surface that
libva will render to.
sourcepub fn new_from_same_surface<S: PictureState>(
timestamp: u64,
picture: &Picture<S, T>,
) -> Self
pub fn new_from_same_surface<S: PictureState>( timestamp: u64, picture: &Picture<S, T>, ) -> Self
Creates a new Picture with a given timestamp to identify it,
reusing the Surface from picture. This is useful for interlaced
decoding as one can render both fields to the same underlying surface.
sourcepub fn add_buffer(&mut self, buffer: Buffer)
pub fn add_buffer(&mut self, buffer: Buffer)
Add buffer to the picture.
sourcepub fn begin<D: SurfaceMemoryDescriptor>(
self,
) -> Result<Picture<PictureBegin, T>, VaError>
pub fn begin<D: SurfaceMemoryDescriptor>( self, ) -> Result<Picture<PictureBegin, T>, VaError>
Wrapper around vaBeginPicture.
source§impl<T> Picture<PictureBegin, T>
impl<T> Picture<PictureBegin, T>
source§impl<T> Picture<PictureRender, T>
impl<T> Picture<PictureRender, T>
source§impl<T> Picture<PictureEnd, T>
impl<T> Picture<PictureEnd, T>
sourcepub fn sync<D: SurfaceMemoryDescriptor>(
self,
) -> Result<Picture<PictureSync, T>, (VaError, Self)>
pub fn sync<D: SurfaceMemoryDescriptor>( self, ) -> Result<Picture<PictureSync, T>, (VaError, Self)>
Syncs the picture, ensuring that all pending operations are complete when this call returns.
source§impl<S: PictureState, T> Picture<S, T>
impl<S: PictureState, T> Picture<S, T>
sourcepub fn surface<D: SurfaceMemoryDescriptor>(&self) -> &Surface<D>
pub fn surface<D: SurfaceMemoryDescriptor>(&self) -> &Surface<D>
Returns a reference to the underlying Surface.
If you are interested in obtaining the container of the Surface, use as_ref() instead.
This is a convenience method to avoid having to call borrow() every time the surface is
needed.
source§impl<S: PictureReclaimableSurface, T> Picture<S, T>
impl<S: PictureReclaimableSurface, T> Picture<S, T>
sourcepub fn take_surface(self) -> Result<T, Self>
pub fn take_surface(self) -> Result<T, Self>
Reclaim ownership of the Surface this picture has been created from, consuming the picture in the process. Useful if the Surface is part of a pool.
This will fail and return the passed object if there are more than one reference to the underlying surface.
sourcepub fn derive_image<'a, D: SurfaceMemoryDescriptor + 'a>(
&'a self,
visible_rect: (u32, u32),
) -> Result<Image<'_>, VaError>
pub fn derive_image<'a, D: SurfaceMemoryDescriptor + 'a>( &'a self, visible_rect: (u32, u32), ) -> Result<Image<'_>, VaError>
Create a new derived image from this Picture using vaDeriveImage.
Derived images are a direct view (i.e. without any copy) on the buffer content of the
Picture. On the other hand, not all Pictures can be derived.
sourcepub fn create_image<'a, D: SurfaceMemoryDescriptor + 'a>(
&'a self,
format: VAImageFormat,
coded_resolution: (u32, u32),
visible_rect: (u32, u32),
) -> Result<Image<'_>, VaError>
pub fn create_image<'a, D: SurfaceMemoryDescriptor + 'a>( &'a self, format: VAImageFormat, coded_resolution: (u32, u32), visible_rect: (u32, u32), ) -> Result<Image<'_>, VaError>
Create new image from the Picture using vaCreateImage and vaGetImage.
The image will contain a copy of the Picture in the desired format and coded_resolution.