blob: ecdc4ff35c04689b82338defbae68492222f2bb9 [file] [log] [blame]
<!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 2d commit flow on main thread: Four-color squares on white background.</title>
<style type="text/css">
.nomargin {
margin: 0px auto;
}
</style>
</head>
<body onload="main()">
<div style="position:relative; width:300px; height:300px; 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>
<script>
var g_swapsBeforeAck = 15;
function main()
{
drawLoop();
}
var g_animationFrameNumber = 0;
var canvas = document.getElementById("c");
var offscreenCanvas = canvas.transferControlToOffscreen();
var offscreen2d = offscreenCanvas.getContext("2d");
function drawLoop()
{
if (g_animationFrameNumber < 3) {
offscreen2d.fillStyle = "red";
offscreen2d.fillRect(0, 0, 200, 200);
g_animationFrameNumber++;
offscreen2d.commit().then(drawLoop);
} else {
offscreen2d.fillStyle = "red";
offscreen2d.fillRect(0, 0, 100, 100);
offscreen2d.fillStyle = "green";
offscreen2d.fillRect(100, 0, 100, 100);
offscreen2d.fillStyle = "blue";
offscreen2d.fillRect(0, 100, 100, 100);
offscreen2d.fillStyle = "black";
offscreen2d.fillRect(100, 100, 100, 100);
offscreen2d.commit();
// The following fill is never committed
offscreen2d.fillStyle = "blue";
offscreen2d.fillRect(0, 0, 200, 200);
waitForFinish();
}
}
function waitForFinish()
{
if (g_swapsBeforeAck == 0) {
domAutomationController.setAutomationId(1);
domAutomationController.send("SUCCESS");
} else {
g_swapsBeforeAck--;
document.getElementById('container').style.zIndex = g_swapsBeforeAck + 1;
window.requestAnimationFrame(waitForFinish);
}
}
</script>
</body>
</html>