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

Unified Diff: content/test/data/gpu/pixel_offscreenCanvas_webgl_resize_on_worker.html

Issue 2588053003: Make OffscreenCanvas resizable (Closed)
Patch Set: rebase Created 4 years 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
Index: content/test/data/gpu/pixel_offscreenCanvas_webgl_resize_on_worker.html
diff --git a/content/test/data/gpu/pixel_offscreenCanvas_webgl_resize_on_worker.html b/content/test/data/gpu/pixel_offscreenCanvas_webgl_resize_on_worker.html
new file mode 100644
index 0000000000000000000000000000000000000000..ace65f3edd7d9afc6e6a01cddd26c437105ace44
--- /dev/null
+++ b/content/test/data/gpu/pixel_offscreenCanvas_webgl_resize_on_worker.html
@@ -0,0 +1,116 @@
+<!DOCTYPE HTML>
+
+<!-- READ BEFORE UPDATING:
+If this test is updated make sure to increment the "revision" value of the
+associated test in content/test/gpu/gpu_tests/pixel_test_pages.py. This will ensure
+that the baseline images are regenerated on the next run.
+-->
+
+<html>
+<head>
+<title>OffscreenCanvas webgl.commit with resizing: red triangle with softened edge.</title>
+<style type="text/css">
+.nomargin {
+ margin: 0px auto;
+}
+</style>
+<script id="myWorker" type="text/worker">
+function drawTriangle(gl)
+{
+ gl.clearColor(0, 1, 0, 1);
+ gl.clear(gl.COLOR_BUFFER_BIT);
+
+ var prog = gl.createProgram();
+ var vs = gl.createShader(gl.VERTEX_SHADER);
+ gl.shaderSource(vs, [
+ 'attribute vec2 pos;', 'void main() {',
+ ' gl_Position = vec4(pos, 0., .5);', '}'
+ ].join('\n'));
+ gl.compileShader(vs);
+ if (!gl.getShaderParameter(vs, gl.COMPILE_STATUS)) {
+ throw 'failed to compiled shader';
+ }
+ gl.attachShader(prog, vs);
+
+ var fs = gl.createShader(gl.FRAGMENT_SHADER);
+ gl.shaderSource(
+ fs, [ 'void main() {', ' gl_FragColor = vec4(1, 0, 0.5, 1);', '}' ].join('\n'));
+ gl.compileShader(fs);
+ if (!gl.getShaderParameter(fs, gl.COMPILE_STATUS)) {
+ throw 'failed to compiled shader';
+ }
+ gl.attachShader(prog, fs);
+
+ gl.linkProgram(prog);
+ if (!gl.getProgramParameter(prog, gl.LINK_STATUS)) {
+ throw "Could not link the shader program!";
+ }
+ gl.useProgram(prog);
+
+ gl.bindBuffer(gl.ARRAY_BUFFER, gl.createBuffer());
+ gl.bufferData(gl.ARRAY_BUFFER, new Float32Array([ -.5, .5, 0, 0, -.5, -.5 ]),
+ gl.STATIC_DRAW);
+ var attr = gl.getAttribLocation(prog, 'pos');
+ gl.enableVertexAttribArray(attr);
+ gl.vertexAttribPointer(attr, 2, gl.FLOAT, false, 0, 0);
+
+ gl.drawArrays(gl.TRIANGLE_STRIP, 0, 3);
+
+
+}
+
+self.onmessage = function(e) {
+ var transfered = e.data;
+ // Resize the canvas from 200X200 to 40X50
+ // The triangle should scale proportionately with edge softened
+ transfered.width = 40;
+ transfered.height = 50;
+
+ var gl = transfered.getContext('webgl');
+ drawTriangle(gl);
+ gl.commit();
+
+ self.postMessage("");
+};
+</script>
+<script>
+var g_swapsBeforeAck = 15;
+
+function makeWorker(script)
+{
+ var blob = new Blob([script]);
+ return new Worker(URL.createObjectURL(blob));
+}
+
+function waitForFinish()
+{
+ if (g_swapsBeforeAck == 0) {
+ domAutomationController.setAutomationId(1);
+ domAutomationController.send("SUCCESS");
+ } else {
+ g_swapsBeforeAck--;
+ document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1;
+ window.webkitRequestAnimationFrame(waitForFinish);
+ }
+}
+
+function main()
+{
+ var canvas2D = document.getElementById("c");
+ var offscreenCanvas = canvas2D.transferControlToOffscreen();
+ var worker = makeWorker(document.getElementById("myWorker").textContent);
+ worker.onmessage = function (e) {
+ waitForFinish();
+ };
+ worker.postMessage(offscreenCanvas, [offscreenCanvas]);
+}
+</script>
+</head>
+<body onload="main()">
+<div style="position:relative; width:200px; height:200px; background-color:white">
+</div>
+<div id="container" style="position:absolute; top:0px; left:0px">
+<canvas id="c" width="200" height="200" class="nomargin"></canvas>
+</div>
+</body>
+</html>
« no previous file with comments | « content/test/data/gpu/pixel_offscreenCanvas_2d_resize_on_worker.html ('k') | content/test/gpu/gpu_tests/pixel_expectations.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698