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 The Chromium Authors. All rights reserved. |
michael@0 | 3 | Use of this source code is governed by a BSD-style license that can be |
michael@0 | 4 | found in the LICENSE file. |
michael@0 | 5 | --> |
michael@0 | 6 | <!DOCTYPE html> |
michael@0 | 7 | <html> |
michael@0 | 8 | <head> |
michael@0 | 9 | <meta charset="utf-8"> |
michael@0 | 10 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 11 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 12 | <script src="../resources/webgl-test.js"></script> |
michael@0 | 13 | <script src="../resources/webgl-test-utils.js"></script> |
michael@0 | 14 | </head> |
michael@0 | 15 | <body> |
michael@0 | 16 | <div id="description"></div> |
michael@0 | 17 | <div id="console"></div> |
michael@0 | 18 | |
michael@0 | 19 | <script> |
michael@0 | 20 | var wtu = WebGLTestUtils; |
michael@0 | 21 | var gl = null; |
michael@0 | 22 | var tex = null; |
michael@0 | 23 | var error = 0; |
michael@0 | 24 | |
michael@0 | 25 | function enumToString(value) { |
michael@0 | 26 | return wtu.glEnumToString(gl, value); |
michael@0 | 27 | } |
michael@0 | 28 | |
michael@0 | 29 | function testTexImage2D(testCase) |
michael@0 | 30 | { |
michael@0 | 31 | var level = 0; |
michael@0 | 32 | var width = 16; |
michael@0 | 33 | var height = 16; |
michael@0 | 34 | var msg = "" + |
michael@0 | 35 | " internalFormat: " + enumToString(testCase.internalFormat) + |
michael@0 | 36 | " target: " + enumToString(testCase.target) + |
michael@0 | 37 | " format: " + enumToString(testCase.format) + |
michael@0 | 38 | " type: " + enumToString(testCase.type) + |
michael@0 | 39 | " border: " + testCase.border; |
michael@0 | 40 | |
michael@0 | 41 | gl.texImage2D(testCase.target, level, testCase.internalFormat, width, height, testCase.border, testCase.format, testCase.type, null); |
michael@0 | 42 | error = testCase.expectedError; |
michael@0 | 43 | glErrorShouldBe(gl, error, msg); |
michael@0 | 44 | } |
michael@0 | 45 | |
michael@0 | 46 | function testTexSubImage2D(testCase) |
michael@0 | 47 | { |
michael@0 | 48 | var level = 0; |
michael@0 | 49 | var xoffset = 0; |
michael@0 | 50 | var yoffset = 0; |
michael@0 | 51 | var width = 16; |
michael@0 | 52 | var height = 16; |
michael@0 | 53 | var msg = ""+ |
michael@0 | 54 | " format: " + enumToString(testCase.format) + |
michael@0 | 55 | " type: " + enumToString(testCase.type); |
michael@0 | 56 | var array = new Uint8Array(width * height * 4); |
michael@0 | 57 | gl.texSubImage2D(testCase.target, level, xoffset, yoffset, width, height, testCase.format, testCase.type, array); |
michael@0 | 58 | error = testCase.expectedError; |
michael@0 | 59 | glErrorShouldBe(gl, error, msg); |
michael@0 | 60 | } |
michael@0 | 61 | |
michael@0 | 62 | function testTexParameter(testCase) |
michael@0 | 63 | { |
michael@0 | 64 | var msg = "paramName: " + enumToString(testCase.pname); |
michael@0 | 65 | error = testCase.expectedError; |
michael@0 | 66 | gl.texParameteri(testCase.target, testCase.pname, testCase.param); |
michael@0 | 67 | glErrorShouldBe(gl, error, msg); |
michael@0 | 68 | gl.texParameterf(testCase.target, testCase.pname, testCase.param); |
michael@0 | 69 | glErrorShouldBe(gl, error, msg); |
michael@0 | 70 | } |
michael@0 | 71 | |
michael@0 | 72 | function testGetTexParameter(testCase) |
michael@0 | 73 | { |
michael@0 | 74 | var msg = "paramName: " + enumToString(testCase.pname); |
michael@0 | 75 | error = testCase.expectedError; |
michael@0 | 76 | gl.getTexParameter(testCase.target, testCase.pname); |
michael@0 | 77 | glErrorShouldBe(gl, error, msg); |
michael@0 | 78 | } |
michael@0 | 79 | |
michael@0 | 80 | function testCopyTexImage2D(testCase) |
michael@0 | 81 | { |
michael@0 | 82 | var level = 0; |
michael@0 | 83 | var x = 0; |
michael@0 | 84 | var y = 0; |
michael@0 | 85 | var width = 16; |
michael@0 | 86 | var height = 16; |
michael@0 | 87 | |
michael@0 | 88 | var msg = "" + |
michael@0 | 89 | " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) + |
michael@0 | 90 | " internalFormat: " + enumToString(testCase.internalFormat) + |
michael@0 | 91 | " target: " + enumToString(testCase.target) + |
michael@0 | 92 | " border: " + testCase.border; |
michael@0 | 93 | |
michael@0 | 94 | gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, height); |
michael@0 | 95 | glErrorShouldBe(gl, gl.NO_ERROR); |
michael@0 | 96 | shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE"); |
michael@0 | 97 | |
michael@0 | 98 | gl.copyTexImage2D(testCase.target, level, testCase.internalFormat, x, y, width, height, testCase.border); |
michael@0 | 99 | error = testCase.expectedError; |
michael@0 | 100 | glErrorShouldBe(gl, error, msg); |
michael@0 | 101 | } |
michael@0 | 102 | |
michael@0 | 103 | function testCopyTexSubImage2D(testCase) |
michael@0 | 104 | { |
michael@0 | 105 | var level = 0; |
michael@0 | 106 | var x = 0; |
michael@0 | 107 | var y = 0; |
michael@0 | 108 | var width = 16; |
michael@0 | 109 | var height = 16; |
michael@0 | 110 | var xoffset = 0; |
michael@0 | 111 | var yoffset = 0; |
michael@0 | 112 | var border = 0; |
michael@0 | 113 | var type = gl.UNSIGNED_BYTE; |
michael@0 | 114 | var msg = "" + |
michael@0 | 115 | " colorBufferFormat: " + enumToString(testCase.colorBufferFormat) + |
michael@0 | 116 | " internalFormat: " + enumToString(testCase.internalFormat) + |
michael@0 | 117 | " target: " + enumToString(testCase.target); |
michael@0 | 118 | |
michael@0 | 119 | gl.renderbufferStorage(gl.RENDERBUFFER, testCase.colorBufferFormat, width, height); |
michael@0 | 120 | glErrorShouldBe(gl, gl.NO_ERROR); |
michael@0 | 121 | shouldBe("gl.checkFramebufferStatus(gl.FRAMEBUFFER)", "gl.FRAMEBUFFER_COMPLETE"); |
michael@0 | 122 | |
michael@0 | 123 | gl.texImage2D(testCase.target, level, testCase.internalFormat, xoffset + width, yoffset + height, border, testCase.internalFormat, type, null); |
michael@0 | 124 | glErrorShouldBe(gl, gl.NO_ERROR); |
michael@0 | 125 | |
michael@0 | 126 | gl.copyTexSubImage2D(testCase.target, level, xoffset, yoffset, x, y, width, height); |
michael@0 | 127 | error = testCase.expectedError; |
michael@0 | 128 | glErrorShouldBe(gl, error, msg); |
michael@0 | 129 | } |
michael@0 | 130 | |
michael@0 | 131 | function testCopyFromInternalFBO(testCase) |
michael@0 | 132 | { |
michael@0 | 133 | var target = gl.TEXTURE_2D; |
michael@0 | 134 | var level = 0; |
michael@0 | 135 | var x = 0; |
michael@0 | 136 | var y = 0; |
michael@0 | 137 | var width = 16; |
michael@0 | 138 | var height = 16; |
michael@0 | 139 | var xoffset = 0; |
michael@0 | 140 | var yoffset = 0; |
michael@0 | 141 | var border = 0; |
michael@0 | 142 | var type = gl.UNSIGNED_BYTE; |
michael@0 | 143 | var msg = "" + |
michael@0 | 144 | " colorBufferFormat: " + enumToString(testCase.contextAlpha ? gl.RGBA : gl.RGB) + |
michael@0 | 145 | " internalFormat: " + enumToString(testCase.internalFormat); |
michael@0 | 146 | |
michael@0 | 147 | if (testCase.contextAlpha) |
michael@0 | 148 | gl = create3DContext(null, { alpha: true }); |
michael@0 | 149 | else |
michael@0 | 150 | gl = create3DContext(null, { alpha: false }); |
michael@0 | 151 | shouldBeNonNull("gl"); |
michael@0 | 152 | shouldBeNonNull("tex = gl.createTexture()"); |
michael@0 | 153 | gl.bindTexture(target, tex); |
michael@0 | 154 | if (testCase.subImage) { |
michael@0 | 155 | gl.texImage2D(target, level, testCase.internalFormat, xoffset + width, yoffset + height, border, testCase.internalFormat, type, null); |
michael@0 | 156 | glErrorShouldBe(gl, gl.NO_ERROR); |
michael@0 | 157 | gl.copyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height); |
michael@0 | 158 | } else { |
michael@0 | 159 | glErrorShouldBe(gl, gl.NO_ERROR); |
michael@0 | 160 | gl.copyTexImage2D(target, level, testCase.internalFormat, x, y, width, height, border); |
michael@0 | 161 | } |
michael@0 | 162 | error = testCase.expectedError; |
michael@0 | 163 | glErrorShouldBe(gl, error, msg); |
michael@0 | 164 | } |
michael@0 | 165 | |
michael@0 | 166 | description("Validate tex functions input parameters"); |
michael@0 | 167 | |
michael@0 | 168 | shouldBeNonNull("gl = create3DContext()"); |
michael@0 | 169 | shouldBeNonNull("tex = gl.createTexture()"); |
michael@0 | 170 | gl.bindTexture(gl.TEXTURE_2D, tex); |
michael@0 | 171 | glErrorShouldBe(gl, gl.NO_ERROR); |
michael@0 | 172 | |
michael@0 | 173 | debug(""); |
michael@0 | 174 | debug("Checking TexImage2D: a set of inputs that are valid in GL but invalid in GLES2"); |
michael@0 | 175 | |
michael@0 | 176 | var testCases = |
michael@0 | 177 | [ {target: 0x8064, // GL_PROXY_TEXTURE_2D |
michael@0 | 178 | internalFormat: gl.RGBA, |
michael@0 | 179 | border: 0, |
michael@0 | 180 | format: gl.RGBA, |
michael@0 | 181 | type: gl.UNSIGNED_BYTE, |
michael@0 | 182 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 183 | {target: gl.TEXTURE_2D, |
michael@0 | 184 | internalFormat: 0x1903, // GL_RED |
michael@0 | 185 | border: 0, |
michael@0 | 186 | format: 0x1903, // GL_RED |
michael@0 | 187 | type: gl.UNSIGNED_BYTE, |
michael@0 | 188 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 189 | {target: gl.TEXTURE_2D, |
michael@0 | 190 | internalFormat: gl.RGBA, |
michael@0 | 191 | border: 1, |
michael@0 | 192 | format: gl.RGBA, |
michael@0 | 193 | type: gl.UNSIGNED_BYTE, |
michael@0 | 194 | expectedError: gl.INVALID_VALUE}, |
michael@0 | 195 | {target: gl.TEXTURE_2D, |
michael@0 | 196 | internalFormat: gl.RGBA, |
michael@0 | 197 | border: 0, |
michael@0 | 198 | format: gl.RGB, |
michael@0 | 199 | type: gl.UNSIGNED_BYTE, |
michael@0 | 200 | expectedError: gl.INVALID_OPERATION}, |
michael@0 | 201 | {target: gl.TEXTURE_2D, |
michael@0 | 202 | internalFormat: gl.RGBA, |
michael@0 | 203 | border: 0, |
michael@0 | 204 | format: gl.RGBA, |
michael@0 | 205 | type: gl.BYTE, |
michael@0 | 206 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 207 | {target: gl.TEXTURE_2D, |
michael@0 | 208 | internalFormat: gl.RGBA, |
michael@0 | 209 | border: 0, |
michael@0 | 210 | format: gl.RGBA, |
michael@0 | 211 | type: gl.UNSIGNED_BYTE, |
michael@0 | 212 | expectedError: gl.NO_ERROR} ]; |
michael@0 | 213 | |
michael@0 | 214 | for (var ii = 0; ii < testCases.length; ++ii) |
michael@0 | 215 | testTexImage2D(testCases[ii]); |
michael@0 | 216 | |
michael@0 | 217 | debug(""); |
michael@0 | 218 | debug("Checking TexSubImage2D: a set of inputs that are valid in GL but invalid in GLES2"); |
michael@0 | 219 | |
michael@0 | 220 | testCases = |
michael@0 | 221 | [ {target: gl.TEXTURE_2D, |
michael@0 | 222 | format: 0x1903, // GL_RED |
michael@0 | 223 | type: gl.UNSIGNED_BYTE, |
michael@0 | 224 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 225 | {target: gl.TEXTURE_2D, |
michael@0 | 226 | format: gl.RGBA, |
michael@0 | 227 | type: gl.BYTE, |
michael@0 | 228 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 229 | {target: gl.TEXTURE_2D, |
michael@0 | 230 | format: gl.RGBA, |
michael@0 | 231 | type: gl.UNSIGNED_BYTE, |
michael@0 | 232 | expectedError: gl.NO_ERROR} ]; |
michael@0 | 233 | |
michael@0 | 234 | for (var ii = 0; ii < testCases.length; ++ii) |
michael@0 | 235 | testTexSubImage2D(testCases[ii]); |
michael@0 | 236 | |
michael@0 | 237 | debug(""); |
michael@0 | 238 | debug("Checking TexParameter: a set of inputs that are valid in GL but invalid in GLES2"); |
michael@0 | 239 | |
michael@0 | 240 | testCases = |
michael@0 | 241 | [ {target: 0x0DE0, // GL_TEXTURE_1D |
michael@0 | 242 | pname: gl.TEXTURE_WRAP_T, |
michael@0 | 243 | param: gl.REPEAT, |
michael@0 | 244 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 245 | {target: gl.TEXTURE_2D, |
michael@0 | 246 | pname: 0x813A, // GL_TEXTURE_MIN_LOD |
michael@0 | 247 | param: 0, |
michael@0 | 248 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 249 | {target: gl.TEXTURE_2D, |
michael@0 | 250 | pname: gl.TEXTURE_WRAP_T, |
michael@0 | 251 | param: 0x2900, // GL_CLAMP |
michael@0 | 252 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 253 | {target: gl.TEXTURE_2D, |
michael@0 | 254 | pname: gl.TEXTURE_WRAP_T, |
michael@0 | 255 | param: gl.REPEAT, |
michael@0 | 256 | expectedError: gl.NO_ERROR} ]; |
michael@0 | 257 | |
michael@0 | 258 | for (var ii = 0; ii < testCases.length; ++ii) |
michael@0 | 259 | testTexParameter(testCases[ii]); |
michael@0 | 260 | |
michael@0 | 261 | debug(""); |
michael@0 | 262 | debug("Checking GetTexParameter: a set of inputs that are valid in GL but invalid in GLES2"); |
michael@0 | 263 | |
michael@0 | 264 | testCases = |
michael@0 | 265 | [ {target: 0x0DE0, // GL_TEXTURE_1D |
michael@0 | 266 | pname: gl.TEXTURE_WRAP_T, |
michael@0 | 267 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 268 | {target: gl.TEXTURE_2D, |
michael@0 | 269 | pname: 0x813A, // GL_TEXTURE_MIN_LOD |
michael@0 | 270 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 271 | {target: gl.TEXTURE_2D, |
michael@0 | 272 | pname: gl.TEXTURE_WRAP_T, |
michael@0 | 273 | expectedError: gl.NO_ERROR} ]; |
michael@0 | 274 | |
michael@0 | 275 | for (var ii = 0; ii < testCases.length; ++ii) |
michael@0 | 276 | testGetTexParameter(testCases[ii]); |
michael@0 | 277 | |
michael@0 | 278 | debug(""); |
michael@0 | 279 | debug("Checking CopyTexImage2D: a set of inputs that are valid in GL but invalid in GLES2"); |
michael@0 | 280 | |
michael@0 | 281 | var colorBuffer = null; |
michael@0 | 282 | var fbo = null; |
michael@0 | 283 | |
michael@0 | 284 | shouldBeNonNull("fbo = gl.createFramebuffer()"); |
michael@0 | 285 | gl.bindFramebuffer(gl.FRAMEBUFFER, fbo); |
michael@0 | 286 | shouldBeNonNull("colorBuffer = gl.createRenderbuffer()"); |
michael@0 | 287 | gl.bindRenderbuffer(gl.RENDERBUFFER, colorBuffer); |
michael@0 | 288 | gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorBuffer); |
michael@0 | 289 | glErrorShouldBe(gl, gl.NO_ERROR); |
michael@0 | 290 | |
michael@0 | 291 | testCases = |
michael@0 | 292 | [ {target: gl.TEXTURE_2D, |
michael@0 | 293 | colorBufferFormat: gl.RGB565, |
michael@0 | 294 | internalFormat: 0x8054, // GL_RGB16 |
michael@0 | 295 | border: 0, |
michael@0 | 296 | expectedError: gl.INVALID_ENUM}, |
michael@0 | 297 | {target: gl.TEXTURE_2D, |
michael@0 | 298 | colorBufferFormat: gl.RGB565, |
michael@0 | 299 | internalFormat: gl.RGBA, |
michael@0 | 300 | border: 1, |
michael@0 | 301 | expectedError: gl.INVALID_VALUE}, |
michael@0 | 302 | {target: gl.TEXTURE_2D, |
michael@0 | 303 | colorBufferFormat: gl.RGB565, |
michael@0 | 304 | internalFormat: gl.RGBA, |
michael@0 | 305 | border: 0, |
michael@0 | 306 | expectedError: gl.INVALID_OPERATION}, |
michael@0 | 307 | {target: gl.TEXTURE_2D, |
michael@0 | 308 | colorBufferFormat: gl.RGB565, |
michael@0 | 309 | internalFormat: gl.RGB, |
michael@0 | 310 | border: 0, |
michael@0 | 311 | expectedError: gl.NO_ERROR} ]; |
michael@0 | 312 | |
michael@0 | 313 | for (var ii = 0; ii < testCases.length; ++ii) |
michael@0 | 314 | testCopyTexImage2D(testCases[ii]); |
michael@0 | 315 | |
michael@0 | 316 | debug(""); |
michael@0 | 317 | debug("Checking CopyTexSubImage2D: a set of inputs that are valid in GL but invalid in GLES2"); |
michael@0 | 318 | |
michael@0 | 319 | testCases = |
michael@0 | 320 | [ {target: gl.TEXTURE_2D, |
michael@0 | 321 | colorBufferFormat: gl.RGB5_A1, |
michael@0 | 322 | internalFormat: gl.RGBA, |
michael@0 | 323 | expectedError: gl.NO_ERROR}, |
michael@0 | 324 | {target: gl.TEXTURE_2D, |
michael@0 | 325 | colorBufferFormat: gl.RGB565, |
michael@0 | 326 | internalFormat: gl.RGBA, |
michael@0 | 327 | expectedError: gl.INVALID_OPERATION} ]; |
michael@0 | 328 | |
michael@0 | 329 | for (var ii = 0; ii < testCases.length; ++ii) |
michael@0 | 330 | testCopyTexSubImage2D(testCases[ii]); |
michael@0 | 331 | |
michael@0 | 332 | debug(""); |
michael@0 | 333 | debug("Checking CopyTex{Sub}Image2D: copy from WebGL internal framebuffer"); |
michael@0 | 334 | |
michael@0 | 335 | testCases = |
michael@0 | 336 | [ {contextAlpha: true, |
michael@0 | 337 | internalFormat: gl.RGBA, |
michael@0 | 338 | subImage: false, |
michael@0 | 339 | expectedError: gl.NO_ERROR}, |
michael@0 | 340 | {contextAlpha: false, |
michael@0 | 341 | internalFormat: gl.RGBA, |
michael@0 | 342 | subImage: false, |
michael@0 | 343 | expectedError: gl.INVALID_OPERATION}, |
michael@0 | 344 | {contextAlpha: true, |
michael@0 | 345 | internalFormat: gl.RGBA, |
michael@0 | 346 | subImage: true, |
michael@0 | 347 | expectedError: gl.NO_ERROR}, |
michael@0 | 348 | {contextAlpha: false, |
michael@0 | 349 | internalFormat: gl.RGBA, |
michael@0 | 350 | subImage: true, |
michael@0 | 351 | expectedError: gl.INVALID_OPERATION} ]; |
michael@0 | 352 | |
michael@0 | 353 | for (var ii = 0; ii < testCases.length; ++ii) |
michael@0 | 354 | testCopyFromInternalFBO(testCases[ii]); |
michael@0 | 355 | |
michael@0 | 356 | successfullyParsed = true; |
michael@0 | 357 | </script> |
michael@0 | 358 | |
michael@0 | 359 | <script>finishTest();</script> |
michael@0 | 360 | </body> |
michael@0 | 361 | </html> |