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 | |
michael@0 | 26 | <!DOCTYPE html> |
michael@0 | 27 | <html> |
michael@0 | 28 | <head> |
michael@0 | 29 | <meta charset="utf-8"> |
michael@0 | 30 | <title>Rendering Test</title> |
michael@0 | 31 | <link rel="stylesheet" href="../../resources/js-test-style.css"/> |
michael@0 | 32 | <script src="../../resources/js-test-pre.js"></script> |
michael@0 | 33 | <script src="../resources/webgl-test.js"> </script> |
michael@0 | 34 | </head> |
michael@0 | 35 | <body> |
michael@0 | 36 | <canvas id="example" width="50" height="50"> |
michael@0 | 37 | There is supposed to be an example drawing here, but it's not important. |
michael@0 | 38 | </canvas> |
michael@0 | 39 | <div id="description"></div> |
michael@0 | 40 | <div id="console"></div> |
michael@0 | 41 | <script id="vshader" type="x-shader/x-vertex"> |
michael@0 | 42 | attribute vec4 vPosition; |
michael@0 | 43 | void main() |
michael@0 | 44 | { |
michael@0 | 45 | gl_Position = vPosition; |
michael@0 | 46 | } |
michael@0 | 47 | </script> |
michael@0 | 48 | |
michael@0 | 49 | <script id="fshader" type="x-shader/x-fragment"> |
michael@0 | 50 | void main() |
michael@0 | 51 | { |
michael@0 | 52 | gl_FragColor = vec4(1.0,0.0,0.0,1.0); |
michael@0 | 53 | } |
michael@0 | 54 | </script> |
michael@0 | 55 | |
michael@0 | 56 | <script> |
michael@0 | 57 | function fail(x,y, buf, shouldBe) |
michael@0 | 58 | { |
michael@0 | 59 | var i = (y*50+x) * 4; |
michael@0 | 60 | var reason = "pixel at ("+x+","+y+") is ("+buf[i]+","+buf[i+1]+","+buf[i+2]+","+buf[i+3]+"), should be "+shouldBe; |
michael@0 | 61 | testFailed(reason); |
michael@0 | 62 | } |
michael@0 | 63 | |
michael@0 | 64 | function pass() |
michael@0 | 65 | { |
michael@0 | 66 | testPassed("drawing is correct"); |
michael@0 | 67 | } |
michael@0 | 68 | |
michael@0 | 69 | function init() |
michael@0 | 70 | { |
michael@0 | 71 | if (window.initNonKhronosFramework) { |
michael@0 | 72 | window.initNonKhronosFramework(false); |
michael@0 | 73 | } |
michael@0 | 74 | |
michael@0 | 75 | description(document.title); |
michael@0 | 76 | |
michael@0 | 77 | gl = initWebGL("example", "vshader", "fshader", [ "vPosition"], [ 0, 0, 0, 1 ], 1); |
michael@0 | 78 | |
michael@0 | 79 | var vertexObject = gl.createBuffer(); |
michael@0 | 80 | gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject); |
michael@0 | 81 | gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ 0,0.5,0, -0.5,-0.5,0, 0.5,-0.5,0 ]), gl.STATIC_DRAW); |
michael@0 | 82 | gl.enableVertexAttribArray(0); |
michael@0 | 83 | gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); |
michael@0 | 84 | |
michael@0 | 85 | gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT); |
michael@0 | 86 | gl.drawArrays(gl.TRIANGLES, 0, 3); |
michael@0 | 87 | |
michael@0 | 88 | var buf = new Uint8Array(50 * 50 * 4); |
michael@0 | 89 | gl.readPixels(0, 0, 50, 50, gl.RGBA, gl.UNSIGNED_BYTE, buf); |
michael@0 | 90 | |
michael@0 | 91 | // Test several locations |
michael@0 | 92 | // First line should be all black |
michael@0 | 93 | for (var i = 0; i < 50; ++i) |
michael@0 | 94 | if (buf[i*4] != 0 || buf[i*4+1] != 0 || buf[i*4+2] != 0 || buf[i*4+3] != 255) { |
michael@0 | 95 | fail(i, 0, buf, "(0,0,0,255)"); |
michael@0 | 96 | return; |
michael@0 | 97 | } |
michael@0 | 98 | |
michael@0 | 99 | // Line 15 should be red for at least 10 red pixels starting 20 pixels in |
michael@0 | 100 | var offset = (15*50+20) * 4; |
michael@0 | 101 | for (var i = 0; i < 10; ++i) |
michael@0 | 102 | if (buf[offset+i*4] != 255 || buf[offset+i*4+1] != 0 || buf[offset+i*4+2] != 0 || buf[offset+i*4+3] != 255) { |
michael@0 | 103 | fail(20 + i, 15, buf, "(255,0,0,255)"); |
michael@0 | 104 | return; |
michael@0 | 105 | } |
michael@0 | 106 | // Last line should be all black |
michael@0 | 107 | offset = (49*50) * 4; |
michael@0 | 108 | for (var i = 0; i < 50; ++i) |
michael@0 | 109 | if (buf[offset+i*4] != 0 || buf[offset+i*4+1] != 0 || buf[offset+i*4+2] != 0 || buf[offset+i*4+3] != 255) { |
michael@0 | 110 | fail(i, 49, buf, "(0,0,0,255)"); |
michael@0 | 111 | return; |
michael@0 | 112 | } |
michael@0 | 113 | |
michael@0 | 114 | pass(); |
michael@0 | 115 | } |
michael@0 | 116 | |
michael@0 | 117 | init(); |
michael@0 | 118 | successfullyParsed = true; |
michael@0 | 119 | </script> |
michael@0 | 120 | <script>finishTest();</script> |
michael@0 | 121 | |
michael@0 | 122 | </body> |
michael@0 | 123 | </html> |