| OLD | NEW |
| 1 <html> | 1 <html> |
| 2 <head> | 2 <head> |
| 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> | 3 <script type="text/javascript" src="webrtc_test_utilities.js"></script> |
| 4 <script type="text/javascript" src="depth_stream_test_utilities.js"></script> | 4 <script type="text/javascript" src="depth_stream_test_utilities.js"></script> |
| 5 <script type="text/javascript"> | 5 <script type="text/javascript"> |
| 6 | 6 |
| 7 function cubemapFaces(gl) { | 7 function cubemapFaces(gl) { |
| 8 return [gl.TEXTURE_CUBE_MAP_POSITIVE_X, | 8 return [gl.TEXTURE_CUBE_MAP_POSITIVE_X, |
| 9 gl.TEXTURE_CUBE_MAP_NEGATIVE_X, | 9 gl.TEXTURE_CUBE_MAP_NEGATIVE_X, |
| 10 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, | 10 gl.TEXTURE_CUBE_MAP_POSITIVE_Y, |
| (...skipping 22 matching lines...) Expand all Loading... |
| 33 }, failedCallback); | 33 }, failedCallback); |
| 34 }); | 34 }); |
| 35 }, | 35 }, |
| 36 failedCallback); | 36 failedCallback); |
| 37 } | 37 } |
| 38 | 38 |
| 39 function depthStreamToRGBAUint8Texture() { | 39 function depthStreamToRGBAUint8Texture() { |
| 40 console.log('Calling depthStreamToRGBAUint8Texture'); | 40 console.log('Calling depthStreamToRGBAUint8Texture'); |
| 41 getFake16bitStream().then(function(stream) { | 41 getFake16bitStream().then(function(stream) { |
| 42 detectVideoInLocalView1(stream, function() { | 42 detectVideoInLocalView1(stream, function() { |
| 43 testVideoToRGBA8Texture('local-view-1', function(skip_info) { | 43 testVideoToRGBA8Texture('local-view-1', function() { |
| 44 if (skip_info) { | |
| 45 console.log("SKIP depthStreamToRGBAUint8Texture: " + | |
| 46 skip_info); | |
| 47 } | |
| 48 stream.getVideoTracks()[0].stop(); | 44 stream.getVideoTracks()[0].stop(); |
| 49 waitForVideoToStop('local-view-1'); | 45 waitForVideoToStop('local-view-1'); |
| 50 }, failedCallback); | 46 }, failedCallback); |
| 51 }); | 47 }); |
| 52 }, | 48 }, |
| 53 failedCallback); | 49 failedCallback); |
| 54 } | 50 } |
| 55 | 51 |
| 56 function depthStreamToRGBAFloatTexture() { | 52 function depthStreamToRGBAFloatTexture() { |
| 57 console.log('Calling depthStreamToRGBAFloatTexture'); | 53 console.log('Calling depthStreamToRGBAFloatTexture'); |
| 58 getFake16bitStream().then(function(stream) { | 54 getFake16bitStream().then(function(stream) { |
| 59 detectVideoInLocalView1(stream, function() { | 55 detectVideoInLocalView1(stream, function() { |
| 60 testVideoToRGBA32FTexture('local-view-1', function(skip_info) { | 56 testVideoToRGBA32FTexture('local-view-1', function() { |
| 61 if (skip_info) { | |
| 62 console.log("SKIP depthStreamToRGBAFloatTexture: " + | |
| 63 skip_info); | |
| 64 } | |
| 65 stream.getVideoTracks()[0].stop(); | 57 stream.getVideoTracks()[0].stop(); |
| 66 waitForVideoToStop('local-view-1'); | 58 waitForVideoToStop('local-view-1'); |
| 67 }, failedCallback); | 59 }, failedCallback); |
| 60 }); |
| 61 }, |
| 62 failedCallback); |
| 63 } |
| 64 |
| 65 function depthStreamToR32FloatTexture() { |
| 66 console.log('Calling depthStreamToR32FloatTexture'); |
| 67 getFake16bitStream().then(function(stream) { |
| 68 detectVideoInLocalView1(stream, function() { |
| 69 testVideoToR32FTexture('local-view-1', function() { |
| 70 stream.getVideoTracks()[0].stop(); |
| 71 waitForVideoToStop('local-view-1'); |
| 72 }, failedCallback); |
| 68 }); | 73 }); |
| 69 }, | 74 }, |
| 70 failedCallback); | 75 failedCallback); |
| 71 } | 76 } |
| 72 | 77 |
| 73 function failedCallback(error) { | 78 function failedCallback(error) { |
| 74 failTest('GetUserMedia call failed with error name ' + error.name); | 79 failTest('GetUserMedia call failed with error name ' + error.name); |
| 75 } | 80 } |
| 76 | 81 |
| 77 function attachMediaStream(stream, videoElement) { | 82 function attachMediaStream(stream, videoElement) { |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 152 var canvas = document.createElement('canvas'); | 157 var canvas = document.createElement('canvas'); |
| 153 canvas.width = 96; | 158 canvas.width = 96; |
| 154 canvas.height = 96; | 159 canvas.height = 96; |
| 155 var gl = canvas.getContext('webgl'); | 160 var gl = canvas.getContext('webgl'); |
| 156 if(!gl) | 161 if(!gl) |
| 157 return error({name:"WebGL is not available."}); | 162 return error({name:"WebGL is not available."}); |
| 158 return testVideoToTexture(gl, video, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, | 163 return testVideoToTexture(gl, video, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, |
| 159 readAndVerifyRGBA8, success, error); | 164 readAndVerifyRGBA8, success, error); |
| 160 } | 165 } |
| 161 | 166 |
| 167 function testVideoToR32FTexture(videoElementName, success, error) { |
| 168 var video = $(videoElementName); |
| 169 var canvas = document.createElement('canvas'); |
| 170 canvas.width = 96; |
| 171 canvas.height = 96; |
| 172 var gl = canvas.getContext('webgl2'); |
| 173 if(!gl) |
| 174 return error({name:"WebGL2 is not available."}); |
| 175 var color_buffer_float_ext = gl.getExtension('EXT_color_buffer_float'); |
| 176 return testVideoToTexture(gl, video, gl.R32F, gl.RED, gl.FLOAT, |
| 177 readAndVerifyR32F, success, error); |
| 178 } |
| 179 |
| 162 function testVideoToTexture(gl, video, internalformat, format, type, | 180 function testVideoToTexture(gl, video, internalformat, format, type, |
| 163 readAndVerifyFunction, success, error) { | 181 readAndVerifyFunction, success, error) { |
| 164 // Create framebuffer that we will use for reading back the texture. | 182 // Create framebuffer that we will use for reading back the texture. |
| 165 var fb = gl.createFramebuffer(); | 183 var fb = gl.createFramebuffer(); |
| 166 gl.bindFramebuffer(gl.FRAMEBUFFER, fb); | 184 gl.bindFramebuffer(gl.FRAMEBUFFER, fb); |
| 167 var tests = []; | 185 var tests = []; |
| 168 // Premultiply alpha is ignored but we just test both values. | 186 // Premultiply alpha is ignored but we just test both values. |
| 169 var cases = [ | 187 var cases = [ |
| 170 {flip_y: false, premultiply_alpha: true}, | 188 {flip_y: false, premultiply_alpha: true}, |
| 171 {flip_y: true, premultiply_alpha: false} | 189 {flip_y: true, premultiply_alpha: false} |
| (...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 283 | 301 |
| 284 function readAndVerifyRGBA32F(gl, width, height, flip_y, test_name) { | 302 function readAndVerifyRGBA32F(gl, width, height, flip_y, test_name) { |
| 285 var arr = new Float32Array(width * height * 4); | 303 var arr = new Float32Array(width * height * 4); |
| 286 gl.readPixels(0, 0, width, height, gl.RGBA, gl.FLOAT, arr); | 304 gl.readPixels(0, 0, width, height, gl.RGBA, gl.FLOAT, arr); |
| 287 var color_step = 1.0 / (width + height); | 305 var color_step = 1.0 / (width + height); |
| 288 return verifyPixels(arr, width, height, flip_y, color_step, | 306 return verifyPixels(arr, width, height, flip_y, color_step, |
| 289 1.0 /*wrap_around*/, 1.5/65535 /*tolerance*/, | 307 1.0 /*wrap_around*/, 1.5/65535 /*tolerance*/, |
| 290 test_name); | 308 test_name); |
| 291 } | 309 } |
| 292 | 310 |
| 311 function readAndVerifyR32F(gl, width, height, flip_y, test_name) { |
| 312 var arr = new Float32Array(width * height * 4); |
| 313 gl.readPixels(0, 0, width, height, gl.RGBA, gl.FLOAT, arr); |
| 314 var color_step = 1.0 / (width + height); |
| 315 return verifyPixelsRed(arr, width, height, flip_y, color_step, |
| 316 1.0 /*wrap_around*/, 1.5 / 65535 /*tolerance*/, |
| 317 test_name); |
| 318 } |
| 319 |
| 293 function onLoad() { | 320 function onLoad() { |
| 294 var query = /query=(.*)/.exec(window.location.href); | 321 var query = /query=(.*)/.exec(window.location.href); |
| 295 if (!query) | 322 if (!query) |
| 296 return; | 323 return; |
| 297 if (query[1] == "RGBAUint8") | 324 if (query[1] == "RGBAUint8") |
| 298 depthStreamToRGBAUint8Texture(); | 325 depthStreamToRGBAUint8Texture(); |
| 299 else if (query[1] == "RGBAFloat") | 326 else if (query[1] == "RGBAFloat") |
| 300 depthStreamToRGBAFloatTexture(); | 327 depthStreamToRGBAFloatTexture(); |
| 328 else if (query[1] == "R32Float") |
| 329 depthStreamToR32FloatTexture(); |
| 301 } | 330 } |
| 302 </script> | 331 </script> |
| 303 </head> | 332 </head> |
| 304 <body onload="onLoad()"> | 333 <body onload="onLoad()"> |
| 305 <table border="0"> | 334 <table border="0"> |
| 306 <tr> | 335 <tr> |
| 307 <td><video id="local-view-1" width="96" height="96" autoplay | 336 <td><video id="local-view-1" width="96" height="96" autoplay |
| 308 style="display:none"></video></td> | 337 style="display:none"></video></td> |
| 309 <!-- The canvas is used to detect when video starts and stops. --> | 338 <!-- The canvas is used to detect when video starts and stops. --> |
| 310 <td><canvas id="local-view-1-canvas" width="96" height="96" | 339 <td><canvas id="local-view-1-canvas" width="96" height="96" |
| 311 style="display:none"></canvas></td> | 340 style="display:none"></canvas></td> |
| 312 </tr> | 341 </tr> |
| 313 </table> | 342 </table> |
| 314 </body> | 343 </body> |
| 315 </html> | 344 </html> |
| OLD | NEW |