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

Unified Diff: conformance/more/demos/video.html

Issue 8342021: Add webgl conformance tests r15841. (Closed) Base URL: svn://chrome-svn/chrome/trunk/deps/third_party/webgl/sdk/tests/
Patch Set: Created 9 years, 2 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
« no previous file with comments | « conformance/more/demos/opengl_web.html ('k') | conformance/more/functions/bindBuffer.html » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: conformance/more/demos/video.html
===================================================================
--- conformance/more/demos/video.html (revision 0)
+++ conformance/more/demos/video.html (revision 0)
@@ -0,0 +1,135 @@
+<html>
+<head>
+<meta charset="utf-8">
+<script type="application/x-javascript" src="../util.js"></script>
+<script>
+var processor = {
+ lastTime : new Date,
+ timerCallback: function() {
+ if (this.video.paused || this.video.ended) {
+ return;
+ }
+ this.computeFrame();
+ var t = new Date;
+ var elapsed = t - this.lastTime;
+ this.lastTime = t;
+ var self = this;
+ setTimeout(function () {
+ self.timerCallback();
+ }, Math.max(0, 33-elapsed));
+ },
+
+ init: function() {
+ if (this.initDone) return;
+ this.c2 = document.getElementById("c2");
+ this.ctx2 = this.c2.getContext(GL_CONTEXT_ID);
+ this.greenScreen = new Filter(this.ctx2, 'identity-flip-vert', 'greenScreen');
+ this.ctx2.activeTexture(this.ctx2.TEXTURE0);
+ this.tex = loadTexture(this.ctx2, this.c1, false);
+ this.ctx2.activeTexture(this.ctx2.TEXTURE1);
+ this.tex2 = loadTexture(this.ctx2, document.getElementById('i'), false);
+ this.ctx2.activeTexture(this.ctx2.TEXTURE0);
+ this.initDone = true;
+ },
+
+ doLoad: function() {
+ this.video = document.getElementById("video");
+ this.c1 = document.getElementById("c1");
+ this.ctx1 = this.c1.getContext("2d");
+ this.ctx1.globalCompositeOperation = 'copy';
+ this.ctx1.fillRect(0,0,this.c1.width, this.c1.height);
+ var self = this;
+ this.video.addEventListener("play", function() {
+ self.init();
+ self.width = self.video.videoWidth;
+ self.height = self.video.videoHeight;
+ self.lastTime = new Date;
+ self.timerCallback();
+ }, false);
+ },
+
+ computeFrame: function() {
+// this.ctx1.drawImage(this.video, 0, 0, this.width, this.height);
+ this.ctx2.texImage2D(this.ctx2.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, this.video);
+ this.greenScreen.apply(function(s) {
+ s.uniform1i('Texture', 0);
+ s.uniform1i('Texture2', 1);
+ });
+
+ return;
+ }
+};
+
+</script>
+<script id="identity-flip-vert" type="x-shader/x-vertex">
+ attribute vec3 Vertex;
+ attribute vec2 Tex;
+
+ varying vec4 texCoord0;
+ void main()
+ {
+ texCoord0 = vec4(Tex.s,1.0-Tex.t,0.0,0.0);
+ gl_Position = vec4(Vertex, 1.0);
+ }
+</script>
+<script id="greenScreen" type="x-shader/x-fragment">
+ precision mediump float;
+
+ uniform sampler2D Texture;
+ uniform sampler2D Texture2;
+
+ varying vec4 texCoord0;
+ void main()
+ {
+ vec4 c = texture2D(Texture, texCoord0.st);
+ float r = c.r * 0.5;
+ float a = c.g * 6.28;
+ float x = cos(a) * r;
+ float y = sin(a) * r;
+ vec4 c2 = texture2D(Texture2, vec2(0.7+x, 0.5+y));
+ // Shaders with branches are not allowed when dealing with non-SOP content
+ // so instead of "if (b) c2.a = 0;", we use mix()
+ bool b = (c.g > 120.0/255.0 && c.r > 120.0/255.0 && c.b < 50.0/255.0);
+ c2.a = mix(c2.a, 0.0, float(b));
+ gl_FragColor = c2;
+ }
+</script>
+ <style>
+ body {
+ background: black;
+ color:#CCCCCC;
+ }
+ a {
+ color: white;
+ }
+ #c2 {
+ background-image: url(http://www.mozbox.org/pub/green/foo.png);
+ background-repeat: repeat;
+ }
+ div {
+ float: left;
+ border :1px solid #444444;
+ padding:10px;
+ margin: 10px;
+ background:#3B3B3B;
+ }
+ img { display: none; }
+ </style>
+ </head>
+ <body onload="processor.doLoad()">
+ <div>
+ This is a port of Paul Rouget's <a href="http://blog.mozbox.org/post/2009/02/25/video-canvas%3A-special-effects">Canvas+Video green screen demo</a>, plus a texture lookup from the Firefox logo based on the values of the green and red color channels.
+ </div>
+ <div>
+ <video id="video" controls="true">
+ <source src="http://www.mozbox.org/pub/green/video.ogv"></source>
+ <source src="http://cs.helsinki.fi/u/ilmarihe/c3d/demos/video.mp4"></source>
+ </video>
+ <canvas id="c1" width="320" height="192"></canvas>
+ </div>
+ <div>
+ <canvas id="c2" width="640" height="384"></canvas>
+ </div>
+ <img id="i" src="http://www.mozbox.org/pub/green/foo.png">
+ </body>
+</html>
Property changes on: conformance/more/demos/video.html
___________________________________________________________________
Added: svn:eol-style
+ LF
« no previous file with comments | « conformance/more/demos/opengl_web.html ('k') | conformance/more/functions/bindBuffer.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698