Chromium Code Reviews| Index: content/test/data/gpu/pixel_acceleratedOffscreen2d_commit_worker.html |
| diff --git a/content/test/data/gpu/pixel_offscreenCanvas_webgl_commit_main.html b/content/test/data/gpu/pixel_acceleratedOffscreen2d_commit_worker.html |
| similarity index 50% |
| copy from content/test/data/gpu/pixel_offscreenCanvas_webgl_commit_main.html |
| copy to content/test/data/gpu/pixel_acceleratedOffscreen2d_commit_worker.html |
| index 3ae0e56c24d2c1864f35277dbaa6b75ff33191d1..c94eed9020c5aa8a37c3e6e0003cf17dc97947d5 100644 |
| --- a/content/test/data/gpu/pixel_offscreenCanvas_webgl_commit_main.html |
| +++ b/content/test/data/gpu/pixel_acceleratedOffscreen2d_commit_worker.html |
| @@ -8,12 +8,21 @@ that the baseline images are regenerated on the next run. |
| <html> |
| <head> |
| -<title>OffscreenCanvas commit flow on main thread: green square on white background.</title> |
| +<title>OffscreenCanvas 2d commit flow on worker thread: blue square on white background.</title> |
| <style type="text/css"> |
| .nomargin { |
| margin: 0px auto; |
| } |
| </style> |
| +<script id="myWorker" type="text/worker"> |
| +self.onmessage = function(e) { |
| + var transferredCanvas = e.data; |
| + var offscreen2d = transferredCanvas.getContext("2d"); |
| + offscreen2d.fillStyle = "blue"; |
| + offscreen2d.fillRect(0, 0, transferredCanvas.width, transferredCanvas.height); |
| + offscreen2d.commit(); |
|
xidachen
2016/09/22 19:42:33
As discussed with kbr@, please add a self.postMess
xlai (Olivia)
2016/09/22 19:53:51
Done.
|
| +}; |
| +</script> |
| <script> |
| var g_swapsBeforeAck = 15; |
| @@ -23,14 +32,18 @@ function main() |
| waitForFinish(); |
| } |
| +function makeWorker(script) |
| +{ |
| + var blob = new Blob([script]); |
| + return new Worker(URL.createObjectURL(blob)); |
| +} |
| + |
| function draw() |
| { |
| - var canvas = document.getElementById("c"); |
| - var offscreenCanvas = canvas.transferControlToOffscreen(); |
| - var gl = offscreenCanvas.getContext("webgl"); |
| - gl.clearColor(0.0, 1.0, 0.0, 1.0); |
| - gl.clear(gl.COLOR_BUFFER_BIT); |
| - gl.commit(); |
| + var canvas2D = document.getElementById("c"); |
| + var offscreenCanvas = canvas2D.transferControlToOffscreen(); |
| + var worker = makeWorker(document.getElementById("myWorker").textContent); |
| + worker.postMessage(offscreenCanvas, [offscreenCanvas]); |
| } |
| function waitForFinish() |
| @@ -44,13 +57,14 @@ function waitForFinish() |
| window.webkitRequestAnimationFrame(waitForFinish); |
| } |
| } |
| + |
| </script> |
| </head> |
| <body onload="main()"> |
| -<div style="position:relative; width:200px; height:200px; background-color:white"> |
| +<div style="position:relative; width:350px; height:350px; background-color:white"> |
| </div> |
| <div id="container" style="position:absolute; top:0px; left:0px"> |
| -<canvas id="c" width="200" height="200" class="nomargin"></canvas> |
| +<canvas id="c" width="320" height="320" class="nomargin"></canvas> |
| </div> |
| </body> |
| </html> |