use crate::{Error, Event, Result, Texture, VideoFrame};
use super::{VideoColorInfo, VideoFrameTiming};
pub fn from_texture(
texture: &Texture,
timing: VideoFrameTiming,
color: VideoColorInfo,
) -> Result<VideoFrame> {
if texture.is_render_target() {
return Err(Error::invalid_argument(
"render-target-backed video frame requires a producer Event",
));
}
Ok(VideoFrame::from_texture(
texture.clone(),
timing,
color,
None,
))
}
pub fn from_texture_with_ready(
texture: &Texture,
timing: VideoFrameTiming,
color: VideoColorInfo,
ready: &Event,
) -> Result<VideoFrame> {
if !texture.engine_handle().owns_event(ready) {
return Err(Error::invalid_argument(
"video frame producer event belongs to another Engine",
));
}
Ok(VideoFrame::from_texture(
texture.clone(),
timing,
color,
Some(ready.clone()),
))
}