tizen beta release
[framework/web/webkit-efl.git] / LayoutTests / fast / canvas / webgl / webgl-texture-binding-preserved.html
1 <html>
2 <head>
3 <script src="../../js/resources/js-test-pre.js"></script>
4 <script src="resources/webgl-test.js"></script>
5 <script src="resources/webgl-test-utils.js"> </script>
6 </head>
7 <body>
8 <div id="description"></div>
9 <div id="console"></div>
10 <script>
11 description("Checks that painting WebGL contents doesn't pollute the context state.");
12
13 var wtu = WebGLTestUtils;
14
15 if (window.layoutTestController) {
16     layoutTestController.dumpAsText();
17     layoutTestController.waitUntilDone();
18 }
19
20 var canvas;
21 var context;
22 var requestAnimationFrame;
23
24 function draw() {
25   // Draw a blue quad to the screen.  The compositor should have executed
26   // before reaching this point.  If the texture state was corruted, then 
27   // a red quad will be drawn.  See crbug.com/105045.
28   wtu.drawQuad(context);
29
30   wtu.checkCanvasRect(context, 0, 0, 1, 1, [0, 0, 255, 255], "Should have rendered blue.", 1);
31   if (window.layoutTestController)
32       layoutTestController.notifyDone();
33 }
34
35 window.onload = function()
36 {
37   if (window.initNonKhronosFramework) {
38     window.initNonKhronosFramework(false);
39   }
40
41   canvas = document.getElementById("webgl-canvas");
42   canvas.width = 50; canvas.height = 50;
43   context = create3DContext(canvas);
44
45   requestAnimationFrame = window.webkitRequestAnimationFrame
46
47   var program = wtu.setupTexturedQuad(context);
48   var bufferObjects = wtu.setupUnitQuad(context);
49   var texture = wtu.createColoredTexture(context, 1, 1, [0, 0, 255, 255]);
50
51   context.uniform1i(context.getUniformLocation(program, "tex"), 0);
52
53   context.activeTexture(context.TEXTURE_0 + 5);
54   context.bindTexture(context.TEXTURE_2D, texture);
55
56   context.viewport(0, 0, canvas.width, canvas.height);
57
58   context.clearColor(255, 0, 0, 255);
59   context.clear(context.COLOR_BUFFER_BIT | context.DEPTH_BUFFER_BIT);
60
61   // We need to ensure that the compositor has run before the drawing
62   // takes place.
63   setTimeout(draw, 100);
64 }
65 </script>
66 <script src="../../js/resources/js-test-post.js"></script>
67 <canvas id="webgl-canvas" width="32px" height="32px"></canvas>
68 </body>
69 </html>