Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(743)

Unified Diff: content/test/data/gpu/pixel_webgl_util.js

Issue 1805673003: Re-enable IOSurface Canvas2D. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@temp94_texture_size
Patch Set: Comments from kbr. Created 4 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « content/test/data/gpu/pixel_webgl.html ('k') | content/test/gpu/gpu_tests/pixel_expectations.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/test/data/gpu/pixel_webgl_util.js
diff --git a/content/test/data/gpu/pixel_webgl_util.js b/content/test/data/gpu/pixel_webgl_util.js
new file mode 100644
index 0000000000000000000000000000000000000000..b87e176b2f1dd47a88cb323c879707c3db26361a
--- /dev/null
+++ b/content/test/data/gpu/pixel_webgl_util.js
@@ -0,0 +1,95 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+//
+// READ BEFORE UPDATING:
+// If this file is updated, make sure to increment the "revision" value of any
+// tests that use this file in content/test/gpu/page_sets/pixel_tests.py. This
+// will ensure that the baseline images are regenerated on the next run.
+
+var vertexShader = [
+ "attribute vec3 pos;",
+ "void main(void)",
+ "{",
+ " gl_Position = vec4(pos, 1.0);",
+ "}"
+].join("\n");
+
+var fragmentShader = [
+ "precision mediump float;",
+ "void main(void)",
+ "{",
+ " gl_FragColor = vec4(0.0, 1.0, 0.0, 1.0);",
+ "}"
+].join("\n");
+
+function initGL(canvas)
+{
+ var gl = null;
+ try {
+ gl = canvas.getContext("experimental-webgl");
+ } catch (e) {}
+ if (!gl) {
+ try {
+ gl = canvas.getContext("webgl");
+ } catch (e) { }
+ }
+ return gl;
+}
+
+function setupShader(gl, source, type) {
+ var shader = gl.createShader(type);
+ gl.shaderSource(shader, source);
+ gl.compileShader(shader);
+ if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS))
+ return null;
+ return shader;
+}
+
+function setupProgram(gl, vs_id, fs_id) {
+ var vs = setupShader(gl, vertexShader, gl.VERTEX_SHADER);
+ var fs = setupShader(gl, fragmentShader, gl.FRAGMENT_SHADER);
+ if (!vs || !fs)
+ return null;
+ var program = gl.createProgram();
+ gl.attachShader(program, vs);
+ gl.attachShader(program, fs);
+ gl.linkProgram(program);
+ if (!gl.getProgramParameter(program, gl.LINK_STATUS))
+ return null;
+ gl.useProgram(program);
+ return program;
+}
+
+function setupBuffer(gl) {
+ var buffer = gl.createBuffer();
+ gl.bindBuffer(gl.ARRAY_BUFFER, buffer);
+ var vertexData = [
+ 0.0, 0.6, 0.0, // Vertex 1 position
+ -0.6, -0.6, 0.0, // Vertex 2 position
+ 0.6, -0.6, 0.0, // Vertex 3 position
+ ];
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array(vertexData), gl.STATIC_DRAW);
+}
+
+function setup(gl) {
+ var program = setupProgram(gl, "shader-vs", "shader-fs");
+ if (!program)
+ return false;
+ var posAttr = gl.getAttribLocation(program, "pos");
+ gl.enableVertexAttribArray(posAttr);
+ setupBuffer(gl);
+ var stride = 3 * Float32Array.BYTES_PER_ELEMENT;
+ gl.vertexAttribPointer(posAttr, 3, gl.FLOAT, false, stride, 0);
+ gl.clearColor(0.0, 0.0, 0.0, 0.0);
+ gl.viewport(0, 0, 200, 200);
+ gl.disable(gl.DEPTH_TEST);
+ if (gl.getError() != gl.NO_ERROR)
+ return false;
+ return true;
+}
+
+function drawTriangle(gl) {
+ gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+ gl.drawArrays(gl.TRIANGLES, 0, 3);
+}
« no previous file with comments | « content/test/data/gpu/pixel_webgl.html ('k') | content/test/gpu/gpu_tests/pixel_expectations.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698