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

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

Issue 2588053003: Make OffscreenCanvas resizable (Closed)
Patch Set: fix 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_2d_resize.html
diff --git a/content/test/data/gpu/pixel_offscreenCanvas_2d_resize.html b/content/test/data/gpu/pixel_offscreenCanvas_2d_resize.html
new file mode 100644
index 0000000000000000000000000000000000000000..8b181b5b9cb8a00d251286636ba0a48500df6143
--- /dev/null
+++ b/content/test/data/gpu/pixel_offscreenCanvas_2d_resize.html
@@ -0,0 +1,75 @@
+<!DOCTYPE HTML>
Ken Russell (switch to Gerrit) 2016/12/20 06:01:24 Is it worth naming the new test something like "..
xlai (Olivia) 2016/12/20 18:13:38 Done.
+
+<!-- READ BEFORE UPDATING:
+If this test is updated make sure to increment the "revision" value of the
+associated test in content/test/gpu/page_sets/pixel_tests.py. This will ensure
Ken Russell (switch to Gerrit) 2016/12/20 06:01:24 Could you update the comment to point to content/t
xlai (Olivia) 2016/12/20 18:13:38 Done.
+that the baseline images are regenerated on the next run.
+-->
+
+<html>
+<head>
+<title>OffscreenCanvas 2d commit flow with resizing: 100X200 canvas as a result.</title>
+<style type="text/css">
+.nomargin {
+ margin: 0px auto;
+}
+</style>
+<script id="myWorker" type="text/worker">
+self.onmessage = function(e) {
+ var transfered = e.data;
+ var ctx2d = transfered.getContext('2d');
+ ctx2d.fillStyle = "purple";
+ ctx2d.fillRect(0, 0, transfered.width, transfered.height);
+ ctx2d.commit();
+
+ // Resize offscreenCanvas from 150X150 to 100X200.
+ transfered.width = 100;
+ transfered.height = 200;
+ ctx2d.fillStyle = "green";
+ ctx2d.fillRect(0, 0, transfered.width, transfered.height);
+ ctx2d.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.postMessage(offscreenCanvas, [offscreenCanvas]);
+ worker.onmessage = function (e) {
Ken Russell (switch to Gerrit) 2016/12/20 06:01:24 The fact that the onmessage handler is set after c
xlai (Olivia) 2016/12/20 18:13:38 Done. I will follow up with another CL that edits
+ waitForFinish();
+ };
+}
+</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="150" height="150" class="nomargin"></canvas>
+</div>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698