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

Side by Side Diff: content/test/data/gpu/pixel_offscreenCanvas_2d_resize.html

Issue 2588053003: Make OffscreenCanvas resizable (Closed)
Patch Set: fix Created 3 years, 12 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
OLDNEW
(Empty)
1 <!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.
2
3 <!-- READ BEFORE UPDATING:
4 If this test is updated make sure to increment the "revision" value of the
5 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.
6 that the baseline images are regenerated on the next run.
7 -->
8
9 <html>
10 <head>
11 <title>OffscreenCanvas 2d commit flow with resizing: 100X200 canvas as a result. </title>
12 <style type="text/css">
13 .nomargin {
14 margin: 0px auto;
15 }
16 </style>
17 <script id="myWorker" type="text/worker">
18 self.onmessage = function(e) {
19 var transfered = e.data;
20 var ctx2d = transfered.getContext('2d');
21 ctx2d.fillStyle = "purple";
22 ctx2d.fillRect(0, 0, transfered.width, transfered.height);
23 ctx2d.commit();
24
25 // Resize offscreenCanvas from 150X150 to 100X200.
26 transfered.width = 100;
27 transfered.height = 200;
28 ctx2d.fillStyle = "green";
29 ctx2d.fillRect(0, 0, transfered.width, transfered.height);
30 ctx2d.commit();
31
32 self.postMessage("");
33 };
34 </script>
35 <script>
36 var g_swapsBeforeAck = 15;
37
38 function makeWorker(script)
39 {
40 var blob = new Blob([script]);
41 return new Worker(URL.createObjectURL(blob));
42 }
43
44 function waitForFinish()
45 {
46 if (g_swapsBeforeAck == 0) {
47 domAutomationController.setAutomationId(1);
48 domAutomationController.send("SUCCESS");
49 } else {
50 g_swapsBeforeAck--;
51 document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1;
52 window.webkitRequestAnimationFrame(waitForFinish);
53 }
54 }
55
56 function main()
57 {
58 var canvas2D = document.getElementById("c");
59 var offscreenCanvas = canvas2D.transferControlToOffscreen();
60 var worker = makeWorker(document.getElementById("myWorker").textContent);
61 worker.postMessage(offscreenCanvas, [offscreenCanvas]);
62 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
63 waitForFinish();
64 };
65 }
66 </script>
67 </head>
68 <body onload="main()">
69 <div style="position:relative; width:200px; height:200px; background-color:white ">
70 </div>
71 <div id="container" style="position:absolute; top:0px; left:0px">
72 <canvas id="c" width="150" height="150" class="nomargin"></canvas>
73 </div>
74 </body>
75 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698