Modified: branches/safari-610-branch/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/canvas/render-after-resize-test.html (269315 => 269316)
--- branches/safari-610-branch/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/canvas/render-after-resize-test.html 2020-11-03 18:45:58 UTC (rev 269315)
+++ branches/safari-610-branch/LayoutTests/webgl/2.0.0/resources/webgl_test_files/conformance/canvas/render-after-resize-test.html 2020-11-03 19:14:05 UTC (rev 269316)
@@ -1,28 +1,7 @@
<!--
-
-/*
-** Copyright (c) 2017 The Khronos Group Inc.
-**
-** Permission is hereby granted, free of charge, to any person obtaining a
-** copy of this software and/or associated documentation files (the
-** "Materials"), to deal in the Materials without restriction, including
-** without limitation the rights to use, copy, modify, merge, publish,
-** distribute, sublicense, and/or sell copies of the Materials, and to
-** permit persons to whom the Materials are furnished to do so, subject to
-** the following conditions:
-**
-** The above copyright notice and this permission notice shall be included
-** in all copies or substantial portions of the Materials.
-**
-** THE MATERIALS ARE PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
-** EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-** MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-** IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-** CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-** TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-** MATERIALS OR THE USE OR OTHER DEALINGS IN THE MATERIALS.
-*/
-
+Copyright (c) 2020 The Khronos Group Inc.
+Use of this source code is governed by an MIT-style license that can be
+found in the LICENSE.txt file.
-->
<!DOCTYPE html>
<html>
@@ -35,59 +14,126 @@
</head>
<body>
<div id="description"></div>
-<canvas style="width: 100px, height: 100px; border: 1px solid blue;" id="c"></canvas>
+<canvas style="width: 100px; height: 100px; border: 1px solid black;" id="c"></canvas>
<div id="console"></div>
<script>
description("This test ensures WebGL implementations can render correctly after resizing the canvas.");
debug("");
-var wtu = WebGLTestUtils;
-var gl = wtu.create3DContext("c");
+const wtu = WebGLTestUtils;
+const gl = wtu.create3DContext("c", {depth: true, stencil: true});
shouldBeTrue("gl != null");
-var positionLocation = 0;
-var texcoordLocation = 1;
-var program = wtu.setupColorQuad(gl, positionLocation);
-var colorLocation = gl.getUniformLocation(program, 'u_color');
-gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+gl.clearColor(1,0,0,1);
-const smallWidth = 300;
-const smallHeight = 150;
+const positionLocation = 0;
+const program = wtu.setupColorQuad(gl, positionLocation);
+const colorLocation = gl.getUniformLocation(program, 'u_color');
+gl.useProgram(program);
+
+const SMALL = 2;
// Changing this size to something smaller produces
// different results. Sometimes wrong, sometimes correct.
-const largeWidth = 1200;
-const largeHeight = 672;
+const LARGE = 1200;
-function render() {
- gl.viewport(0, 0, gl.drawingBufferWidth, gl.drawingBufferHeight);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
- gl.enable(gl.DEPTH_TEST);
- gl.clearColor(1,0,0,1);
- gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
+// -
- gl.useProgram(program);
- wtu.drawUnitQuad(gl);
-}
+debug('\nResize then render.');
+gl.canvas.width = gl.canvas.height = SMALL;
+gl.viewport(0, 0, SMALL, SMALL);
-function checkForQuad(ctx) {
- let w = ctx.drawingBufferWidth;
- let h = ctx.drawingBufferHeight;
+gl.clear(gl.COLOR_BUFFER_BIT);
+wtu.drawUnitQuad(gl);
- wtu.checkCanvasRect(gl, 0, 0, w, h, [ 0, 255, 0, 255 ]);
-}
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
-gl.canvas.width = smallWidth;
-gl.canvas.height = smallHeight;
-render();
-checkForQuad(gl); // passes
+// -
-gl.canvas.width = largeWidth;
-gl.canvas.height = largeHeight;
-gl.canvas.width = smallWidth;
-gl.canvas.height = smallHeight;
-render();
-checkForQuad(gl); // fails (almost all the time)
+debug('\nResize twice then render.');
+gl.canvas.width = gl.canvas.height = LARGE;
+gl.canvas.width = gl.canvas.height = SMALL;
+gl.clear(gl.COLOR_BUFFER_BIT);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+
+debug('\nCause a GL error, then resize and render.');
+gl.depthFunc(0); // Causes INVALID_ENUM
+gl.canvas.width = gl.canvas.height = LARGE;
+gl.clear(gl.COLOR_BUFFER_BIT);
+gl.canvas.width = gl.canvas.height = SMALL;
+
+gl.clear(gl.COLOR_BUFFER_BIT);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+wtu.glErrorShouldBe(gl, gl.INVALID_ENUM);
+wtu.glErrorShouldBe(gl, gl.NO_ERROR);
+
+// -
+
+debug('\nRender, no-op resize, then depth-fail render.');
+
+gl.enable(gl.DEPTH_TEST);
+gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+gl.canvas.width = gl.canvas.width;
+gl.uniform4fv(colorLocation, [0.0, 0.0, 1.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+
+// Reset
+gl.disable(gl.DEPTH_TEST);
+
+// -
+
+debug('\nRender, no-op resize, then stencil-fail render.');
+
+gl.enable(gl.STENCIL_TEST);
+gl.stencilOp(gl.KEEP, gl.KEEP, gl.INCR);
+gl.stencilFunc(gl.EQUAL, 0, 0xff);
+gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT | gl.STENCIL_BUFFER_BIT);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+gl.canvas.width = gl.canvas.width;
+gl.uniform4fv(colorLocation, [0.0, 0.0, 1.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 255, 0, 255 ]);
+
+// Reset
+gl.disable(gl.STENCIL_TEST);
+gl.stencilOp(gl.KEEP, gl.KEEP, gl.KEEP);
+gl.stencilFunc(gl.ALWAYS, 0, 0xff);
+
+// -
+
+debug('\nRender, no-op resize, then scissor render.');
+
+gl.enable(gl.SCISSOR_TEST);
+gl.clear(gl.COLOR_BUFFER_BIT);
+gl.uniform4fv(colorLocation, [0.0, 1.0, 0.0, 1.0]);
+wtu.drawUnitQuad(gl);
+
+gl.canvas.width = gl.canvas.width;
+gl.enable(gl.SCISSOR_TEST);
+gl.scissor(0, 0, 1, 1);
+gl.uniform4fv(colorLocation, [0.0, 0.0, 1.0, 1.0]);
+wtu.drawUnitQuad(gl);
+gl.disable(gl.SCISSOR_TEST);
+
+wtu.checkCanvasRect(gl, 1, 0, 1, 1, [ 0, 255, 0, 255 ]);
+wtu.checkCanvasRect(gl, 0, 0, 1, 1, [ 0, 0, 255, 255 ]);
+
+// -
+
finishTest();
var successfullyParsed = true;