Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / webgl / index-validation-with-resized-buffer.html
blob7026222eea5f45929968ecb9dbd64fbb580af919
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="resources/webgl-test.js"></script>
5 </head>
6 <body>
7 <canvas id="example" width="1px" height="1px"></canvas>
8 <div id="description"></div>
9 <div id="console"></div>
11 <script id="vs" type="x-shader/x-vertex">
12 attribute vec4 vPosition;
13 attribute vec4 vColor;
14 varying vec4 color;
15 void main() {
16 gl_Position = vPosition;
17 color = vColor;
19 </script>
20 <script id="fs" type="x-shader/x-fragment">
21 #if defined(GL_ES)
22 precision mediump float;
23 #endif
24 varying vec4 color;
25 void main() {
26 gl_FragColor = color;
28 </script>
29 <script>
30 description('Test that updating the size of a vertex buffer is properly noticed by the WebGL implementation.')
32 var gl = initWebGL("example", "vs", "fs", ["vPosition", "vColor"], [0, 0, 0, 1], 1);
33 glErrorShouldBe(gl, gl.NO_ERROR, "after initialization");
35 gl.useProgram(gl.program);
36 var vertexObject = gl.createBuffer();
37 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
38 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
39 [-1,1,0, 1,1,0, -1,-1,0,
40 -1,-1,0, 1,1,0, 1,-1,0]), gl.STATIC_DRAW);
41 gl.enableVertexAttribArray(0);
42 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
43 glErrorShouldBe(gl, gl.NO_ERROR, "after vertex setup");
45 var texCoordObject = gl.createBuffer();
46 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
47 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(
48 [0,0, 1,0, 0,1,
49 0,1, 1,0, 1,1]), gl.STATIC_DRAW);
50 gl.enableVertexAttribArray(1);
51 gl.vertexAttribPointer(1, 2, gl.FLOAT, false, 0, 0);
52 glErrorShouldBe(gl, gl.NO_ERROR, "after texture coord setup");
54 // Now resize these buffers because we want to change what we're drawing.
55 gl.bindBuffer(gl.ARRAY_BUFFER, vertexObject);
56 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([
57 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0,
58 -1,1,0, 1,1,0, -1,-1,0, 1,-1,0]), gl.STATIC_DRAW);
59 glErrorShouldBe(gl, gl.NO_ERROR, "after vertex redefinition");
60 gl.bindBuffer(gl.ARRAY_BUFFER, texCoordObject);
61 gl.bufferData(gl.ARRAY_BUFFER, new Uint8Array([
62 255, 0, 0, 255,
63 255, 0, 0, 255,
64 255, 0, 0, 255,
65 255, 0, 0, 255,
66 0, 255, 0, 255,
67 0, 255, 0, 255,
68 0, 255, 0, 255,
69 0, 255, 0, 255]), gl.STATIC_DRAW);
70 gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, false, 0, 0);
71 glErrorShouldBe(gl, gl.NO_ERROR, "after texture coordinate / color redefinition");
73 var numQuads = 2;
74 var indices = new Uint8Array(numQuads * 6);
75 for (var ii = 0; ii < numQuads; ++ii) {
76 var offset = ii * 6;
77 var quad = (ii == (numQuads - 1)) ? 4 : 0;
78 indices[offset + 0] = quad + 0;
79 indices[offset + 1] = quad + 1;
80 indices[offset + 2] = quad + 2;
81 indices[offset + 3] = quad + 2;
82 indices[offset + 4] = quad + 1;
83 indices[offset + 5] = quad + 3;
85 var indexObject = gl.createBuffer();
86 gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, indexObject);
87 gl.bufferData(gl.ELEMENT_ARRAY_BUFFER, indices, gl.STATIC_DRAW);
88 glErrorShouldBe(gl, gl.NO_ERROR, "after setting up indices");
89 gl.drawElements(gl.TRIANGLES, numQuads * 6, gl.UNSIGNED_BYTE, 0);
90 glErrorShouldBe(gl, gl.NO_ERROR, "after drawing");
92 debug("")
93 </script>
95 </body>
96 </html>