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

Side by Side Diff: third_party/webgl/conformance-suites/1.0.0/conformance/tex-image-and-sub-image-2d-with-video.html

Issue 9360034: Remove everthing except conformance tests in the deps/third_party/webgl (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/
Patch Set: Created 8 years, 10 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 <!--
2 Copyright (c) 2010 The Chromium Authors. All rights reserved.
3 Use of this source code is governed by a BSD-style license that can be
4 found in the LICENSE file.
5 -->
6 <html>
7 <head>
8 <link rel="stylesheet" href="../resources/js-test-style.css"/>
9 <script src="../resources/js-test-pre.js"></script>
10 <script src="resources/webgl-test.js"></script>
11 <script src="resources/webgl-test-utils.js"></script>
12 <script>
13 var wtu = WebGLTestUtils;
14 var gl = null;
15 var textureLoc = null;
16 var successfullyParsed = false;
17
18 if (window.initNonKhronosFramework) {
19 window.initNonKhronosFramework(true);
20 }
21
22 function init()
23 {
24 description('Verify texImage2D and texSubImage2D code paths taking Video Ele ments');
25
26 var canvas = document.getElementById("example");
27 gl = wtu.create3DContext(canvas);
28 var program = wtu.setupTexturedQuad(gl);
29
30 gl.clearColor(0,0,0,1);
31 gl.clearDepth(1);
32
33 textureLoc = gl.getUniformLocation(gl.program, "tex");
34
35 var video = document.getElementById("vid");
36 video.addEventListener(
37 "playing", function() { runTest(video); }, true);
38 video.play();
39 }
40
41 // These two declarations need to be global for "shouldBe" to see them
42 var buf = null;
43 var idx = 0;
44 var pixel = [0, 0, 0];
45 var correctColor = null;
46
47 function runOneIteration(videoElement, useTexSubImage2D, flipY, topColor, bottom Color)
48 {
49 debug('Testing ' + (useTexSubImage2D ? 'texSubImage2D' : 'texImage2D') +
50 ' with flipY=' + flipY);
51 gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
52 // Disable any writes to the alpha channel
53 gl.colorMask(1, 1, 1, 0);
54 var texture = gl.createTexture();
55 // Bind the texture to texture unit 0
56 gl.bindTexture(gl.TEXTURE_2D, texture);
57 // Set up texture parameters
58 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
59 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
60 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
61 gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
62 // Set up pixel store parameters
63 gl.pixelStorei(gl.UNPACK_FLIP_Y_WEBGL, flipY);
64 gl.pixelStorei(gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, false);
65 // Upload the videoElement into the texture
66 if (useTexSubImage2D) {
67 // Initialize the texture to black first
68 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA,
69 videoElement.videoWidth, videoElement.videoHeight, 0,
70 gl.RGBA, gl.UNSIGNED_BYTE, null);
71 gl.texSubImage2D(gl.TEXTURE_2D, 0, 0, 0, gl.RGBA, gl.UNSIGNED_BYTE, vide oElement);
72 } else {
73 gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, vide oElement);
74 }
75
76 var c = document.createElement("canvas");
77 c.width = 16;
78 c.height = 16;
79 c.style.border = "1px solid black";
80 var ctx = c.getContext("2d");
81 ctx.drawImage(videoElement, 0, 0, 16, 16);
82 document.body.appendChild(c);
83
84 // Point the uniform sampler to texture unit 0
85 gl.uniform1i(textureLoc, 0);
86 // Draw the triangles
87 wtu.drawQuad(gl, [0, 0, 0, 255]);
88 // Check a few pixels near the top and bottom and make sure they have
89 // the right color.
90 debug("Checking lower left corner");
91 wtu.checkCanvasRect(gl, 4, 4, 2, 2, bottomColor,
92 "shouldBe " + bottomColor);
93 debug("Checking upper left corner");
94 wtu.checkCanvasRect(gl, 4, gl.canvas.height - 8, 2, 2, topColor,
95 "shouldBe " + topColor);
96 }
97
98 function runTest(videoElement)
99 {
100 var red = [255, 0, 0];
101 var green = [0, 255, 0];
102 runOneIteration(videoElement, false, true, red, green);
103 runOneIteration(videoElement, false, false, green, red);
104 runOneIteration(videoElement, true, true, red, green);
105 runOneIteration(videoElement, true, false, green, red);
106
107 finishTest();
108 }
109 </script>
110 </head>
111 <body onload="init()">
112 <canvas id="example" width="32px" height="32px"></canvas>
113 <div id="description"></div>
114 <div id="console"></div>
115 <video width="640" height="228" id="vid" controls>
116 <source src="resources/red-green.mp4" type='video/mp4; codecs="avc1.42E01E, m p4a.40.2"' />
117 <source src="resources/red-green.webmvp8.webm" type='video/webm; codecs="vp8, vorbis"' />
118 <source src="resources/red-green.theora.ogv" type='video/ogg; codecs="theora, vorbis"' />
119 </video>
120 </body>
121 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698