Skip to content

Commit 5deaef3

Browse files
authored
Add VideoFrame to ExternalImageSource enum (#6170)
1 parent 690a3fb commit 5deaef3

File tree

4 files changed

+42
-0
lines changed

4 files changed

+42
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,7 @@ By @teoxoy [#6134](https://github.com/gfx-rs/wgpu/pull/6134).
9090
- Deduplicate bind group layouts that are created from pipelines with "auto" layouts. By @teoxoy [#6049](https://github.com/gfx-rs/wgpu/pull/6049)
9191
- Fix crash when dropping the surface after the device. By @wumpf in [#6052](https://github.com/gfx-rs/wgpu/pull/6052)
9292
- Fix error message that is thrown in create_render_pass to no longer say `compute_pass`. By @matthew-wong1 [#6041](https://github.com/gfx-rs/wgpu/pull/6041)
93+
- Add `VideoFrame` to `ExternalImageSource` enum. By @jprochazk in [#6170](https://github.com/gfx-rs/wgpu/pull/6170)
9394

9495
#### GLES / OpenGL
9596

wgpu-hal/src/gles/queue.rs

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -502,6 +502,22 @@ impl super::Queue {
502502
v,
503503
);
504504
},
505+
#[cfg(web_sys_unstable_apis)]
506+
wgt::ExternalImageSource::VideoFrame(ref v) => unsafe {
507+
gl.tex_sub_image_3d_with_video_frame(
508+
dst_target,
509+
copy.dst_base.mip_level as i32,
510+
copy.dst_base.origin.x as i32,
511+
copy.dst_base.origin.y as i32,
512+
z_offset as i32,
513+
copy.size.width as i32,
514+
copy.size.height as i32,
515+
copy.size.depth as i32,
516+
format_desc.external,
517+
format_desc.data_type,
518+
v,
519+
)
520+
},
505521
wgt::ExternalImageSource::ImageData(ref i) => unsafe {
506522
gl.tex_sub_image_3d_with_image_data(
507523
dst_target,
@@ -577,6 +593,20 @@ impl super::Queue {
577593
v,
578594
)
579595
},
596+
#[cfg(web_sys_unstable_apis)]
597+
wgt::ExternalImageSource::VideoFrame(ref v) => unsafe {
598+
gl.tex_sub_image_2d_with_video_frame_and_width_and_height(
599+
dst_target,
600+
copy.dst_base.mip_level as i32,
601+
copy.dst_base.origin.x as i32,
602+
copy.dst_base.origin.y as i32,
603+
copy.size.width as i32,
604+
copy.size.height as i32,
605+
format_desc.external,
606+
format_desc.data_type,
607+
v,
608+
)
609+
},
580610
wgt::ExternalImageSource::ImageData(ref i) => unsafe {
581611
gl.tex_sub_image_2d_with_image_data_and_width_and_height(
582612
dst_target,

wgpu-types/Cargo.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ js-sys.workspace = true
4343
web-sys = { workspace = true, features = [
4444
"ImageBitmap",
4545
"ImageData",
46+
"HtmlImageElement",
4647
"HtmlVideoElement",
4748
"HtmlCanvasElement",
4849
"OffscreenCanvas",
50+
"VideoFrame",
4951
] }
5052

5153
[dev-dependencies]

wgpu-types/src/lib.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6871,6 +6871,9 @@ pub enum ExternalImageSource {
68716871
///
68726872
/// Requires [`DownlevelFlags::UNRESTRICTED_EXTERNAL_TEXTURE_COPIES`]
68736873
OffscreenCanvas(web_sys::OffscreenCanvas),
6874+
/// Copy from a video frame.
6875+
#[cfg(web_sys_unstable_apis)]
6876+
VideoFrame(web_sys::VideoFrame),
68746877
}
68756878

68766879
#[cfg(target_arch = "wasm32")]
@@ -6884,6 +6887,8 @@ impl ExternalImageSource {
68846887
ExternalImageSource::ImageData(i) => i.width(),
68856888
ExternalImageSource::HTMLCanvasElement(c) => c.width(),
68866889
ExternalImageSource::OffscreenCanvas(c) => c.width(),
6890+
#[cfg(web_sys_unstable_apis)]
6891+
ExternalImageSource::VideoFrame(v) => v.display_width(),
68876892
}
68886893
}
68896894

@@ -6896,6 +6901,8 @@ impl ExternalImageSource {
68966901
ExternalImageSource::ImageData(i) => i.height(),
68976902
ExternalImageSource::HTMLCanvasElement(c) => c.height(),
68986903
ExternalImageSource::OffscreenCanvas(c) => c.height(),
6904+
#[cfg(web_sys_unstable_apis)]
6905+
ExternalImageSource::VideoFrame(v) => v.display_height(),
68996906
}
69006907
}
69016908
}
@@ -6912,6 +6919,8 @@ impl std::ops::Deref for ExternalImageSource {
69126919
Self::ImageData(i) => i,
69136920
Self::HTMLCanvasElement(c) => c,
69146921
Self::OffscreenCanvas(c) => c,
6922+
#[cfg(web_sys_unstable_apis)]
6923+
Self::VideoFrame(v) => v,
69156924
}
69166925
}
69176926
}

0 commit comments

Comments
 (0)