Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / webgl / tex-sub-image-2d.html
blob318e71e09fd2771c9083e1bba3f32c9127929fbd
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="resources/webgl-test.js"></script>
5 <script src="resources/webgl-test-utils.js"></script>
6 <script id="fshader" type="x-shader/x-fragment">
7 #ifdef GL_ES
8 precision highp float;
9 #endif
10 uniform sampler2D tex;
11 varying vec2 texCoord;
13 void main()
15 float intensity = texture2D(tex, texCoord).a;
16 gl_FragColor = vec4(intensity, intensity, intensity, 1.0);
18 </script>
20 </head>
21 <body>
22 <canvas id="example" width="256px" height="1px"></canvas>
23 <div id="description"></div>
24 <div id="console"></div>
25 <script>
26 description('Tests texSubImage2D upload path from Uint8Array');
28 var wtu = WebGLTestUtils;
29 var canvas = document.getElementById("example");
30 var gl = wtu.create3DContext(canvas);
31 var program = wtu.setupProgram(
32 gl,
33 [wtu.setupSimpleTextureVertexShader(gl),
34 wtu.loadShaderFromScript(gl, "fshader")],
35 ['vPosition', 'texCoord0']);
36 wtu.setupUnitQuad(gl);
37 var textureWidth = 256;
38 var textureHeight = 1;
40 textureLoc = gl.getUniformLocation(program, "tex");
42 var texture = gl.createTexture();
43 gl.bindTexture(gl.TEXTURE_2D, texture);
44 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
45 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
46 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
47 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
48 // Allocate the texture object
49 gl.texImage2D(gl.TEXTURE_2D, 0, gl.ALPHA, textureWidth, textureHeight, 0, gl.ALPHA, gl.UNSIGNED_BYTE, null);
50 // Prepare the image data
51 var array = new Uint8Array(textureWidth);
52 for (var i = 0; i < textureWidth; i++)
53 array[i] = i;
54 // Fill the texture object with data -- this is actually the code path being tested
55 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, textureWidth, textureHeight, gl.ALPHA, gl.UNSIGNED_BYTE, array);
57 // Clear and set up
58 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
59 gl.bindTexture(gl.TEXTURE_2D, texture);
60 gl.useProgram(program);
61 gl.uniform1i(textureLoc, 0);
62 // Draw the texture to the frame buffer
63 gl.drawArrays(gl.TRIANGLES, 0, 6);
65 // Read back the frame buffer
66 var buf = new Uint8Array(textureWidth * textureHeight * 4);
67 gl.readPixels(0, 0, textureWidth, textureHeight, gl.RGBA, gl.UNSIGNED_BYTE, buf);
69 // Verify the frame buffer's contents
70 var passed = true;
71 for (var i = 0; i < textureWidth; i++) {
72 var val = i;
73 if (buf[4 * i + 0] != val ||
74 buf[4 * i + 1] != val ||
75 buf[4 * i + 2] != val) {
76 testFailed("pixel at (" + i + ", 0) was (" +
77 buf[4 * i + 0] + ", " +
78 buf[4 * i + 1] + ", " +
79 buf[4 * i + 2] + "), should be (" +
80 val + ", " + val + ", " + val + ")");
81 passed = false;
82 break;
86 if (passed)
87 testPassed("");
88 </script>
89 </body>
90 </html>