Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / canvas / webgl / css-webkit-canvas.html
blob5d61c90cef398a00362cda6c26e12f49c1edd45a
1 <html>
2 <head>
3 <style>
4 #target {
5 width:200px;
6 height:200px;
7 border:2px solid black;
8 content: -webkit-canvas(triangle);
10 </style>
12 <script id="vertexShader" type="x-shader/x-vertex">
13 attribute vec4 vPosition;
15 void main() {
16 gl_Position = vPosition;
18 </script>
20 <script id="fragmentShader" type="x-shader/x-fragment">
21 void main() {
22 gl_FragColor = vec4(0.8, 0.7, 0, 1.0);
24 </script>
26 <script type="application/x-javascript">
27 function getFragmentShader()
29 var shaderNode = document.getElementById("fragmentShader"); // fragmentShader has been defined at the top
30 var shaderSource = getShaderSource(shaderNode);
32 var shader = gl.createShader(gl.FRAGMENT_SHADER);
33 gl.shaderSource(shader, shaderSource);
34 gl.compileShader(shader);
36 return shader;
39 function getShaderSource(shaderNode)
41 var shaderSource = "";
42 var node = shaderNode.firstChild;
43 while (node) {
44 if (node.nodeType == 3) // Node.TEXT_NODE
45 shaderSource += node.textContent;
46 node = node.nextSibling;
49 return shaderSource;
52 function getVertexShader()
54 var shaderNode = document.getElementById("vertexShader");
55 var shaderSource = getShaderSource(shaderNode);
57 var shader = gl.createShader(gl.VERTEX_SHADER);
58 gl.shaderSource(shader, shaderSource);
59 gl.compileShader(shader);
61 return shader;
64 function initialize()
66 gl = document.getCSSCanvasContext("webgl", "triangle", 200, 200);
68 var vertexShader = getVertexShader();
69 var fragmentShader = getFragmentShader();
71 var shaderProgram = gl.createProgram();
72 gl.attachShader(shaderProgram, vertexShader);
73 gl.attachShader(shaderProgram, fragmentShader);
74 gl.bindAttribLocation(shaderProgram, 0, "vPosition"); // vPosition has been defined at the top
75 gl.linkProgram(shaderProgram);
77 gl.useProgram(shaderProgram);
79 var buffer = gl.createBuffer();
80 gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
83 function draw(r, g, b)
85 var vertices = [ 0.0, 0.8, 0.0,
86 -0.8, -0.8, 0.0,
87 0.8, -0.8, 0.0 ];
88 gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertices), gl.STATIC_DRAW);
90 gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0); // Load the vertex data
91 gl.enableVertexAttribArray(0);
92 gl.clearColor(r, g, b, 1);
93 gl.clear(gl.COLOR_BUFFER_BIT);
94 gl.drawArrays(gl.TRIANGLES, 0, 3);
97 if (window.testRunner)
98 testRunner.overridePreference("WebKitWebGLEnabled", "1");
100 initialize();
101 draw(0, 0.5, 0);
102 </script>
103 </head>
104 <body>
105 <div id="target"></div>
106 <div id="console"></div>
107 </body>
108 <script>
109 function log(str) {
110 var li = document.createElement("li");
111 li.appendChild(document.createTextNode(str));
112 var console = document.getElementById("console");
113 console.appendChild(li);
115 function assert(bool, text) {
116 if (!bool)
117 log(text + "Failure");
119 window.onload = function() {
120 if (window.testRunner && window.internals) {
121 window.testRunner.layoutAndPaintAsyncThen(function() {
122 assert(window.internals.isUseCounted(document, 753), "has -webkit-canvas UseCounter: "); // 753 == UseCounter::Feature::WebkitCanvas
123 testRunner.notifyDone();
127 testRunner.waitUntilDone();
128 </script>
129 </html>