Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 42 additions & 5 deletions spec/index.bs
Original file line number Diff line number Diff line change
Expand Up @@ -3372,12 +3372,49 @@ dictionary GPUExternalTextureDescriptor : GPUObjectDescriptorBase {
</div>

<div class="example">
Creating an external texture from a video element:
Rendering using an video element external texture at the page animation frame rate:

<pre highlight="js">
const videoElement = document.querySelector('video');
const externalTexture = gpuDevice.importExternalTexture({
source: videoElement
});
const videoElement = document.createElement('video');
// ... set up videoElement, wait for it to be ready...

let externalTexture;

function frame() {
requestAnimationFrame(frame);

// Re-import only if necessary
if (!externalTexture || externalTexture.expired) {
externalTexture = gpuDevice.importExternalTexture({
source: videoElement
});
}

// ... render using externalTexture...
}
requestAnimationFrame(frame);
</pre>
</div>

<div class="example">
Rendering using an video element external texture at the video's frame rate, if
`requestVideoFrameCallback` is available:

<pre highlight="js">
const videoElement = document.createElement('video');
// ... set up videoElement...

function frame() {
videoElement.requestVideoFrameCallback(frame);

// Always re-import, because we know the video frame has advanced
const externalTexture = gpuDevice.importExternalTexture({
source: videoElement
});

// ... render using externalTexture...
}
videoElement.requestVideoFrameCallback(frame);
</pre>
</div>

Expand Down