content/canvas/test/webgl-mochitest/test_depth_readpixels.html

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 <!DOCTYPE HTML>
michael@0 2 <html>
michael@0 3 <head>
michael@0 4 <title>WebGL test: Check for error on ReadPixels from a depth-only FB.</title>
michael@0 5 <script src="/tests/SimpleTest/SimpleTest.js"></script>
michael@0 6 <link rel="stylesheet" href="/tests/SimpleTest/test.css">
michael@0 7 <script src="webgl-util.js"></script>
michael@0 8 <script src="driver-info.js"></script>
michael@0 9 </head>
michael@0 10 <body>
michael@0 11 <canvas id="c"></canvas>
michael@0 12 <script>
michael@0 13 "use strict";
michael@0 14
michael@0 15 (function() {
michael@0 16 var gl = WebGLUtil.getWebGL('c');
michael@0 17 if (!gl) {
michael@0 18 todo(gl, 'Get GL working here first.');
michael@0 19 return;
michael@0 20 }
michael@0 21
michael@0 22 var rb = gl.createRenderbuffer();
michael@0 23 gl.bindRenderbuffer(gl.RENDERBUFFER, rb);
michael@0 24 gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, 4, 4);
michael@0 25
michael@0 26 var fb = gl.createFramebuffer();
michael@0 27 gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
michael@0 28 gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT,
michael@0 29 gl.RENDERBUFFER, rb);
michael@0 30
michael@0 31 if (gl.checkFramebufferStatus(gl.FRAMEBUFFER) != gl.FRAMEBUFFER_COMPLETE) {
michael@0 32 todo(false, 'Depth-only FB incomplete. This is valid.');
michael@0 33 return;
michael@0 34 }
michael@0 35
michael@0 36 ok(!gl.getError(), 'Should have no errors after constructing FB.');
michael@0 37
michael@0 38 var pixels = new Uint8Array([1, 2, 3, 4]);
michael@0 39 gl.readPixels(0, 0, // x,y
michael@0 40 1, 1, // w,h
michael@0 41 gl.RGBA, gl.UNSIGNED_BYTE, pixels);
michael@0 42
michael@0 43 ok(gl.getError() == gl.INVALID_OPERATION,
michael@0 44 '1x1 color read from a depth FB should generated INVALID_OP.');
michael@0 45 console.log('Data after 1x1 color-from-depth readpixels:');
michael@0 46 console.log(pixels);
michael@0 47
michael@0 48 gl.readPixels(0, 0, // x,y
michael@0 49 0, 0, // w,h
michael@0 50 gl.RGBA, gl.UNSIGNED_BYTE, pixels);
michael@0 51
michael@0 52 ok(gl.getError() == gl.INVALID_OPERATION,
michael@0 53 '0x0 color read from a depth FB should generated INVALID_OP.');
michael@0 54 })();
michael@0 55
michael@0 56 ok(true, 'Test complete.');
michael@0 57
michael@0 58 </script>
michael@0 59 </body>
michael@0 60 </html>

mercurial