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

Unified Diff: third_party/WebKit/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html

Issue 1601093008: Remove duplicated WebGL layout tests. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 11 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
Index: third_party/WebKit/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
diff --git a/third_party/WebKit/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html b/third_party/WebKit/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
deleted file mode 100644
index 1d97dfafffea6b47508cfeaad2040abd2bec4e4a..0000000000000000000000000000000000000000
--- a/third_party/WebKit/LayoutTests/fast/canvas/webgl/context-attributes-alpha-depth-stencil-antialias.html
+++ /dev/null
@@ -1,359 +0,0 @@
-
-<!DOCTYPE html>
-<html>
-<head>
-<meta charset="utf-8">
-<script src="../../../resources/js-test.js"></script>
-<script src="resources/webgl-test.js"></script>
-<script id="vshader" type="x-shader/x-vertex">
-attribute vec3 pos;
-attribute vec4 colorIn;
-varying vec4 color;
-
-void main()
-{
- color = colorIn;
- gl_Position = vec4(pos.xyz, 1.0);
-}
-</script>
-
-<script id="fshader" type="x-shader/x-fragment">
-precision mediump float;
-
-varying vec4 color;
-
-void main()
-{
- gl_FragColor = color;
-}
-</script>
-
-<script>
-var successfullyParsed = false;
-
-// These four declarations need to be global for "shouldBe" to see them
-var gl;
-var contextAttribs = null;
-var pixel = [0, 0, 0, 1];
-var correctColor = null;
-var framebuffer;
-var fbHasColor;
-var fbHasDepth;
-var fbHasStencil;
-
-function init()
-{
- if (window.initNonKhronosFramework) {
- window.initNonKhronosFramework(true);
- }
-
- if (window.internals)
- window.internals.settings.setWebGLErrorsToConsoleEnabled(false);
-
- description('Verify WebGLContextAttributes are working as specified, including alpha, depth, stencil, antialias, but not premultipliedAlpha');
-
- runTest();
-}
-
-function getWebGL(canvasWidth, canvasHeight, contextAttribs, clearColor, clearDepth, clearStencil)
-{
- var canvas = document.createElement("canvas");
- if (!canvas)
- return null;
- canvas.width = canvasWidth;
- canvas.height = canvasHeight;
-
- gl = create3DContext(canvas, contextAttribs);
- if (!gl)
- return null;
-
- var program = createProgram(gl, "vshader", "fshader", ["pos", "colorIn"]);
- if (!program)
- return null;
-
- gl.useProgram(program);
-
- gl.enable(gl.DEPTH_TEST);
- gl.enable(gl.STENCIL_TEST);
- gl.disable(gl.BLEND);
-
- gl.clearColor(clearColor[0], clearColor[1], clearColor[2], clearColor[3]);
- gl.clearDepth(clearDepth);
- gl.clearStencil(clearStencil);
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
-
- framebuffer = gl.createFramebuffer();
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
- var texture = gl.createTexture();
- gl.bindTexture(gl.TEXTURE_2D, texture);
- gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.canvas.width, gl.canvas.height, 0, gl.RGBA, gl.UNSIGNED_BYTE, null);
- gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
- fbHasStencil = false;
- fbHasDepth = false;
- fbHasColor = gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
- if (fbHasColor) {
- var depthStencil = gl.createRenderbuffer();
- gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencil);
- gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, gl.canvas.width, gl.canvas.height);
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencil);
- fbHasDepth = gl.checkFramebufferStatus(gl.FRAMEBUFFER) == gl.FRAMEBUFFER_COMPLETE;
- if (!fbHasDepth) {
- gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, null);
- shouldBe('gl.checkFramebufferStatus(gl.FRAMEBUFFER)', 'gl.FRAMEBUFFER_COMPLETE');
- } else {
- fbHasStencil = true;
- }
- }
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
- glErrorShouldBe(gl, gl.NO_ERROR, "should be no errors");
-
- return gl;
-}
-
-function drawAndReadPixel(gl, vertices, colors, x, y)
-{
- var colorOffset = vertices.byteLength;
-
- var vbo = gl.createBuffer();
- gl.bindBuffer(gl.ARRAY_BUFFER, vbo);
- gl.bufferData(gl.ARRAY_BUFFER, colorOffset + colors.byteLength, gl.STATIC_DRAW);
- gl.bufferSubData(gl.ARRAY_BUFFER, 0, vertices);
- gl.bufferSubData(gl.ARRAY_BUFFER, colorOffset, colors);
-
- gl.vertexAttribPointer(0, 3, gl.FLOAT, false, 0, 0);
- gl.enableVertexAttribArray(0);
- gl.vertexAttribPointer(1, 4, gl.UNSIGNED_BYTE, true, 0, colorOffset);
- gl.enableVertexAttribArray(1);
-
- gl.drawArrays(gl.TRIANGLES, 0, vertices.length / 3);
-
- var buf = new Uint8Array(1 * 1 * 4);
- gl.readPixels(x, y, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
- return buf;
-}
-
-function testDefault()
-{
- debug("Testing default attributes: { stencil:false }");
- shouldBeNonNull("gl = getWebGL(1, 1, null, [ 0, 0, 0, 0 ], 1, 0)");
- shouldBeFalse("gl.getContextAttributes().stencil");
- shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0");
-}
-
-function testAlpha(alpha)
-{
- debug("Testing alpha = " + alpha);
- if (alpha) {
- shouldBeNonNull("gl = getWebGL(1, 1, { alpha: true, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)");
- shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8");
- } else {
- shouldBeNonNull("gl = getWebGL(1, 1, { alpha: false, depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 0 ], 1, 0)");
- shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) == 0");
- }
- shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0");
- shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0");
-
- shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
- shouldBeTrue("contextAttribs.alpha == " + alpha);
-
- var buf = new Uint8Array(1 * 1 * 4);
- gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
- pixel[0] = buf[0];
- pixel[1] = buf[1];
- pixel[2] = buf[2];
- pixel[3] = buf[3];
- correctColor = (contextAttribs.alpha ? [0, 0, 0, 0] : [0, 0, 0, 255]);
- shouldBe("pixel", "correctColor");
-
- if (fbHasColor) {
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
- gl.clearColor(0.5, 0.5, 0.5, 0.5);
- gl.clear(gl.COLOR_BUFFER_BIT);
- gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, buf);
- pixel[0] = buf[0];
- pixel[1] = buf[1];
- pixel[2] = buf[2];
- pixel[3] = buf[3];
- shouldBeTrue("Math.abs(pixel[0] - 127) <= 1 && Math.abs(pixel[1] - 127) <= 1 && Math.abs(pixel[2] - 127) <= 1 && Math.abs(pixel[3] - 127) <= 1");
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
- }
-}
-
-function testDepth(depth)
-{
- debug("Testing depth = " + depth);
- if (depth) {
- shouldBeNonNull("gl = getWebGL(1, 1, { stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
- shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) >= 16");
- } else {
- shouldBeNonNull("gl = getWebGL(1, 1, { depth: false, stencil: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
- shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0");
- }
- shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8");
-
- shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
-
- gl.depthFunc(gl.NEVER);
-
- var vertices = new Float32Array([
- 1.0, 1.0, 0.0,
- -1.0, 1.0, 0.0,
- -1.0, -1.0, 0.0,
- 1.0, 1.0, 0.0,
- -1.0, -1.0, 0.0,
- 1.0, -1.0, 0.0]);
- var colors = new Uint8Array([
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255]);
-
- var buf = drawAndReadPixel(gl, vertices, colors, 0, 0);
- pixel[0] = buf[0];
- pixel[1] = buf[1];
- pixel[2] = buf[2];
- pixel[3] = buf[3];
- correctColor = (contextAttribs.depth ? [0, 0, 0, 255] : [255, 0, 0, 255]);
- shouldBe("pixel", "correctColor");
-
- if (fbHasDepth) {
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
- var buf = drawAndReadPixel(gl, vertices, colors, 0, 0);
- pixel[0] = buf[0];
- pixel[1] = buf[1];
- pixel[2] = buf[2];
- pixel[3] = buf[3];
- shouldBe("pixel", "[0, 0, 0, 255]");
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
- }
-}
-
-function testStencilAndDepth(stencil, depth)
-{
- debug("Testing stencil = " + stencil + ", depth = " + depth);
- var creationString =
- "gl = getWebGL(1, 1, { depth: " + depth + ", stencil: " + stencil + ", antialias: false }, [ 0, 0, 0, 1 ], 1, 0)";
- shouldBeNonNull(creationString);
-
- shouldBeTrue("gl.getParameter(gl.RED_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.GREEN_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.BLUE_BITS) >= 8");
- shouldBeTrue("gl.getParameter(gl.ALPHA_BITS) >= 8");
- if (depth)
- shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) >= 16");
- else
- shouldBeTrue("gl.getParameter(gl.DEPTH_BITS) == 0");
-
- if (stencil)
- shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) >= 8");
- else
- shouldBeTrue("gl.getParameter(gl.STENCIL_BITS) == 0");
-
- shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
- if (!depth && contextAttribs.depth) {
- testFailed("WebGL implementation provided a depth buffer when it should not have");
- }
- if (!contextAttribs.depth)
- depth = false;
- if (!stencil && contextAttribs.stencil) {
- testFailed("WebGL implementation provided a stencil buffer when it should not have");
- }
- if (!contextAttribs.stencil)
- stencil = false;
-
- gl.depthFunc(gl.ALWAYS);
-
- gl.stencilFunc(gl.NEVER, 1, 1);
- gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
-
- var vertices = new Float32Array([
- 1.0, 1.0, 0.0,
- -1.0, 1.0, 0.0,
- -1.0, -1.0, 0.0,
- 1.0, 1.0, 0.0,
- -1.0, -1.0, 0.0,
- 1.0, -1.0, 0.0]);
- var colors = new Uint8Array([
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255]);
-
- var buf = drawAndReadPixel(gl, vertices, colors, 0, 0);
- pixel[0] = buf[0];
- pixel[1] = buf[1];
- pixel[2] = buf[2];
- pixel[3] = buf[3];
- correctColor = (stencil ? [0, 0, 0, 255] : [255, 0, 0, 255]);
- shouldBe("pixel", "correctColor");
-
- if (fbHasStencil) {
- gl.bindFramebuffer(gl.FRAMEBUFFER, framebuffer);
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
- var buf = drawAndReadPixel(gl, vertices, colors, 0, 0);
- pixel[0] = buf[0];
- pixel[1] = buf[1];
- pixel[2] = buf[2];
- pixel[3] = buf[3];
- shouldBe("pixel", "[0, 0, 0, 255]");
- gl.bindFramebuffer(gl.FRAMEBUFFER, null);
- }
-}
-
-function testAntialias(antialias)
-{
- debug("Testing antialias = " + antialias);
- if (antialias)
- shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: true }, [ 0, 0, 0, 1 ], 1, 0)");
- else
- shouldBeNonNull("gl = getWebGL(2, 2, { depth: false, stencil: false, alpha: false, antialias: false }, [ 0, 0, 0, 1 ], 1, 0)");
- shouldBeNonNull("contextAttribs = gl.getContextAttributes()");
-
- var vertices = new Float32Array([
- 1.0, 1.0, 0.0,
- -1.0, 1.0, 0.0,
- -1.0, -1.0, 0.0]);
- var colors = new Uint8Array([
- 255, 0, 0, 255,
- 255, 0, 0, 255,
- 255, 0, 0, 255]);
- var buf = drawAndReadPixel(gl, vertices, colors, 0, 0);
- pixel[0] = buf[0];
- shouldBe("pixel[0] != 255 && pixel[0] != 0", "contextAttribs.antialias");
-}
-
-function runTest()
-{
- testDefault();
- testAlpha(true);
- testAlpha(false);
- testDepth(true);
- testDepth(false);
- testStencilAndDepth(true, false);
- testStencilAndDepth(false, false);
- testStencilAndDepth(true, true);
- testStencilAndDepth(false, true);
- testAntialias(true);
- testAntialias(false);
-
- finishTest();
-}
-
-</script>
-</head>
-<body onload="init()">
-<div id="description"></div>
-<div id="console"></div>
-</body>
-</html>

Powered by Google App Engine
This is Rietveld 408576698