Thu, 15 Jan 2015 21:03:48 +0100
Integrate friendly tips from Tor colleagues to make (or not) 4.5 alpha 3;
This includes removal of overloaded (but unused) methods, and addition of
a overlooked call to DataStruct::SetData(nsISupports, uint32_t, bool.)
michael@0 | 1 | <!-- |
michael@0 | 2 | Copyright (C) 2011 Apple Computer, Inc. All rights reserved. |
michael@0 | 3 | |
michael@0 | 4 | Redistribution and use in source and binary forms, with or without |
michael@0 | 5 | modification, are permitted provided that the following conditions |
michael@0 | 6 | are met: |
michael@0 | 7 | 1. Redistributions of source code must retain the above copyright |
michael@0 | 8 | notice, this list of conditions and the following disclaimer. |
michael@0 | 9 | 2. Redistributions in binary form must reproduce the above copyright |
michael@0 | 10 | notice, this list of conditions and the following disclaimer in the |
michael@0 | 11 | documentation and/or other materials provided with the distribution. |
michael@0 | 12 | |
michael@0 | 13 | THIS SOFTWARE IS PROVIDED BY APPLE COMPUTER, INC. ``AS IS'' AND ANY |
michael@0 | 14 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
michael@0 | 15 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR |
michael@0 | 16 | PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE COMPUTER, INC. OR |
michael@0 | 17 | CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, |
michael@0 | 18 | EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, |
michael@0 | 19 | PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR |
michael@0 | 20 | PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY |
michael@0 | 21 | OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
michael@0 | 22 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
michael@0 | 23 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
michael@0 | 24 | --> |
michael@0 | 25 | <!DOCTYPE html> |
michael@0 | 26 | <html> |
michael@0 | 27 | <head> |
michael@0 | 28 | <meta charset="utf-8"> |
michael@0 | 29 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 30 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 31 | <script src="../resources/webgl-test.js"></script> |
michael@0 | 32 | </head> |
michael@0 | 33 | <body> |
michael@0 | 34 | <div id="description"></div> |
michael@0 | 35 | <div id="console"></div> |
michael@0 | 36 | |
michael@0 | 37 | <script> |
michael@0 | 38 | description("Test of drawArrays with out-of-bounds parameters"); |
michael@0 | 39 | |
michael@0 | 40 | var context = create3DContext(); |
michael@0 | 41 | var program = loadStandardProgram(context); |
michael@0 | 42 | |
michael@0 | 43 | context.useProgram(program); |
michael@0 | 44 | var vertexObject = context.createBuffer(); |
michael@0 | 45 | context.bindBuffer(context.ARRAY_BUFFER, vertexObject); |
michael@0 | 46 | context.enableVertexAttribArray(0); |
michael@0 | 47 | |
michael@0 | 48 | debug("Test empty buffer") |
michael@0 | 49 | context.bufferData(context.ARRAY_BUFFER, new Float32Array([ ]), context.STATIC_DRAW); |
michael@0 | 50 | context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0); |
michael@0 | 51 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 1)"); |
michael@0 | 52 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000)"); |
michael@0 | 53 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000000000000)"); |
michael@0 | 54 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, -1)"); |
michael@0 | 55 | shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 1, 0)"); |
michael@0 | 56 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 0)"); |
michael@0 | 57 | shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 0)"); |
michael@0 | 58 | shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 100, 0)"); |
michael@0 | 59 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 1, -1)"); |
michael@0 | 60 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 1)"); |
michael@0 | 61 | |
michael@0 | 62 | debug("") |
michael@0 | 63 | debug("Test buffer with 3 float vectors") |
michael@0 | 64 | context.bufferData(context.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), context.STATIC_DRAW); |
michael@0 | 65 | context.vertexAttribPointer(0, 3, context.FLOAT, false, 0, 0); |
michael@0 | 66 | shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 3)"); |
michael@0 | 67 | shouldGenerateGLError(context, context.INVALID_ENUM, "context.drawArrays(0x0009, 0, 3)"); // GL_POLYGON |
michael@0 | 68 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 3, 2)"); |
michael@0 | 69 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000)"); |
michael@0 | 70 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 10000000000000)"); |
michael@0 | 71 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, -1)"); |
michael@0 | 72 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 0)"); |
michael@0 | 73 | shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 0)"); |
michael@0 | 74 | shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 100, 0)"); |
michael@0 | 75 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 1, -1)"); |
michael@0 | 76 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -1, 1)"); |
michael@0 | 77 | |
michael@0 | 78 | debug("") |
michael@0 | 79 | debug("Test buffer with interleaved (3+2) float vectors") |
michael@0 | 80 | |
michael@0 | 81 | var program2 = createProgram(context, |
michael@0 | 82 | "attribute vec3 aOne;" + |
michael@0 | 83 | "attribute vec2 aTwo;" + |
michael@0 | 84 | "void main() { gl_Position = vec4(aOne, 1.0) + vec4(aTwo, 0.0, 1.0); }", |
michael@0 | 85 | "void main() { gl_FragColor = vec4(1.0, 0.0, 0.0, 1.0); }", |
michael@0 | 86 | [ "aOne", "aTwo" ]); |
michael@0 | 87 | if (!program2) { |
michael@0 | 88 | testFailed("failed to create test program"); |
michael@0 | 89 | } |
michael@0 | 90 | |
michael@0 | 91 | context.useProgram(program2); |
michael@0 | 92 | |
michael@0 | 93 | var vbo = context.createBuffer(); |
michael@0 | 94 | context.bindBuffer(context.ARRAY_BUFFER, vbo); |
michael@0 | 95 | // enough for 9 vertices, so 3 triangles |
michael@0 | 96 | context.bufferData(context.ARRAY_BUFFER, new Float32Array(9*5), context.STATIC_DRAW); |
michael@0 | 97 | |
michael@0 | 98 | // bind first 3 elements, with a stride of 5 float elements |
michael@0 | 99 | context.vertexAttribPointer(0, 3, context.FLOAT, false, 5*4, 0); |
michael@0 | 100 | // bind 2 elements, starting after the first 3; same stride of 5 float elements |
michael@0 | 101 | context.vertexAttribPointer(1, 2, context.FLOAT, false, 5*4, 3*4); |
michael@0 | 102 | |
michael@0 | 103 | context.enableVertexAttribArray(0); |
michael@0 | 104 | context.enableVertexAttribArray(1); |
michael@0 | 105 | |
michael@0 | 106 | shouldGenerateGLError(context, context.NO_ERROR, "context.drawArrays(context.TRIANGLES, 0, 9)"); |
michael@0 | 107 | |
michael@0 | 108 | // negative values must generate INVALID_VALUE; they can never be valid |
michael@0 | 109 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, -500)"); |
michael@0 | 110 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -200, 1)"); |
michael@0 | 111 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, -200, -500)"); |
michael@0 | 112 | |
michael@0 | 113 | // 0xffffffff needs to convert to a 'long' IDL argument as -1, as per |
michael@0 | 114 | // WebIDL 4.1.7. JS ToInt32(0xffffffff) == -1, which is the first step |
michael@0 | 115 | // of the conversion. Thus INVALID_VALUE. |
michael@0 | 116 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0, 0xffffffff)"); |
michael@0 | 117 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0xffffffff, 1)"); |
michael@0 | 118 | shouldGenerateGLError(context, context.INVALID_VALUE, "context.drawArrays(context.TRIANGLES, 0xffffffff, 0xffffffff)"); |
michael@0 | 119 | |
michael@0 | 120 | // values that could otherwise be valid but aren't due to bindings generate |
michael@0 | 121 | // INVALID_OPERATION |
michael@0 | 122 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 200)"); |
michael@0 | 123 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0, 0x7fffffff)"); |
michael@0 | 124 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0x7fffffff, 1)"); |
michael@0 | 125 | shouldGenerateGLError(context, context.INVALID_OPERATION, "context.drawArrays(context.TRIANGLES, 0x7fffffff, 0x7fffffff)"); |
michael@0 | 126 | |
michael@0 | 127 | debug("") |
michael@0 | 128 | successfullyParsed = true; |
michael@0 | 129 | </script> |
michael@0 | 130 | |
michael@0 | 131 | <script>finishTest();</script> |
michael@0 | 132 | </body> |
michael@0 | 133 | </html> |