summaryrefslogtreecommitdiffstats
path: root/third_party/WebKit/LayoutTests/fast/canvas/webgl/webgl-texture-binding-preserved.html
blob: 7baad575d7a9701d68873cab0a3a52532b6e037d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script src="resources/webgl-test.js"></script>
<script src="resources/webgl-test-utils.js"> </script>
</head>
<body>
<div id="description"></div>
<div id="console"></div>
<script>
description("Checks that painting WebGL contents doesn't pollute the context state.");

var wtu = WebGLTestUtils;

if (window.testRunner) {
    testRunner.dumpAsText();
    testRunner.waitUntilDone();
}

if (window.internals)
    window.internals.settings.setWebGLErrorsToConsoleEnabled(false);

var canvas;
var context;

function draw() {
  // Draw a blue quad to the screen.  The compositor should have executed
  // before reaching this point.  If the texture state was corrupted, then
  // a red quad will be drawn.  See crbug.com/105045.
  wtu.drawQuad(context);

  wtu.checkCanvasRect(context, 0, 0, 1, 1, [0, 0, 255, 255], "Should have rendered blue.", 1);
  if (window.testRunner)
    testRunner.notifyDone();
}

window.onload = function()
{
  if (window.initNonKhronosFramework) {
    window.initNonKhronosFramework(false);
  }

  canvas = document.getElementById("webgl-canvas");
  context = create3DContext(canvas);

  var program = wtu.setupTexturedQuad(context);
  var bufferObjects = wtu.setupUnitQuad(context);
  var texture = wtu.createColoredTexture(context, 1, 1, [0, 0, 255, 255]);

  context.uniform1i(context.getUniformLocation(program, "tex"), 0);

  context.activeTexture(context.TEXTURE_0 + 5);
  context.bindTexture(context.TEXTURE_2D, texture);

  context.viewport(0, 0, canvas.width, canvas.height);

  context.clearColor(255, 0, 0, 255);
  context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT);

  // We need to ensure that the compositor has run before the drawing
  // takes place.  requestAnimationFrame was tried for this purpose,
  // but it did not produce the failing behaviour in crbug.com/105045.
  // A timeout of 100 ms was found to consistently reproduce the problem.
  setTimeout(draw, 100);
}
</script>
<canvas id="webgl-canvas" width="32px" height="32px"></canvas>
</body>
</html>