diff --git a/extensions/proposals/WEBGL_webcodecs_video_frame/extension.xml b/extensions/proposals/WEBGL_webcodecs_video_frame/extension.xml index f8dc823fbb..23cbc02e62 100644 --- a/extensions/proposals/WEBGL_webcodecs_video_frame/extension.xml +++ b/extensions/proposals/WEBGL_webcodecs_video_frame/extension.xml @@ -37,10 +37,10 @@ importVideoFrame imports a VideoFrame from WebCodecs, and returns - a WebGLWebCodecsVideoFrameHandle. If the VideoFrame is not backed - by GPU, a TypeError exception will be raised. The VideoFrame keeps being locked - until releaseVideoFrame is called. While being locked, WebCodecs must NOT - manipulate the VideoFrame anymore. + a WebGLWebCodecsVideoFrameHandle. If the VideoFrame can't be + imported, a TypeError exception will be raised. The VideoFrame may keep being + locked until releaseVideoFrame is called. While being locked, WebCodecs must + NOT manipulate the VideoFrame anymore. @@ -94,7 +94,7 @@ dictionary WebGLWebCodecsVideoFrameHandle {

Next we can assemble the GLSL fragment shader to access the video frame textures.

-    // Note: there could many textures for 1 VideoFrame. To be simple the sample here assumes only
+    // Note: there could be many textures for 1 VideoFrame. To be simple the sample here assumes only
     // 1 texture.
     let texInfo0 = videoFrameHandle.textureInfoArray[0];
     let fSource =
@@ -127,6 +127,7 @@ dictionary WebGLWebCodecsVideoFrameHandle {
     gl.clearColor(0.0, 0.0, 0.0, 0.0);
     gl.clear(gl.COLOR_BUFFER_BIT);
     gl.drawArrays(gl.TRIANGLES, 0, 6);
+    gl.bindTexture(texInfo0.target, null);
     ext.releaseVideoFrame(webcodecsVideoFrame);
     
@@ -146,5 +147,9 @@ dictionary WebGLWebCodecsVideoFrameHandle { Initial revision. + + Lift the hardware video frame restriction. + + diff --git a/extensions/proposals/WEBGL_webcodecs_video_frame/webgl_webcodecs_video_frame.js b/extensions/proposals/WEBGL_webcodecs_video_frame/webgl_webcodecs_video_frame.js index 6ba92cc593..4bc977f94a 100644 --- a/extensions/proposals/WEBGL_webcodecs_video_frame/webgl_webcodecs_video_frame.js +++ b/extensions/proposals/WEBGL_webcodecs_video_frame/webgl_webcodecs_video_frame.js @@ -172,6 +172,14 @@ function requestWebGLVideoFrameHandler(canvas) { } } + function unbindVideoFrame(gl, videoFrameHandle, texUnit) { + const infoArray = videoFrameHandle.textureInfoArray; + for (let i = 0; i < infoArray.length; ++i) { + gl.activeTexture(texUnit + i); + gl.bindTexture(infoArray[i].target, null); + } + } + function initVertexBuffers(gl, program, videoFrame, posAttrib, coordAttrib) { const vertices = new Float32Array([ -1.0, -1.0, 1.0, -1.0, 1.0, 1.0, @@ -298,6 +306,7 @@ function requestWebGLVideoFrameHandler(canvas) { gl.clearColor(0.0, 0.0, 0.0, 0.0); gl.clear(gl.COLOR_BUFFER_BIT); gl.drawArrays(gl.TRIANGLES, 0, 6); + unbindVideoFrame(gl, videoFrameHandle, gl.TEXTURE0); // Immediately schedule rendering of the next frame setTimeout(renderFrame, 0); @@ -314,4 +323,4 @@ function requestWebGLVideoFrameHandler(canvas) { } return handleFrame; -} \ No newline at end of file +}