<!DOCTYPE HTML>
<html>
<head>
<title>Low Latency 2D Canvas drawImage Test</title>
<style type="text/css">
.nomargin {
margin: 0px auto;
}
</style>
<script>
let g_swapsBeforeAck = 15;
function waitForFinish()
{
if (g_swapsBeforeAck == 0) {
domAutomationController.send("SUCCESS");
} else {
g_swapsBeforeAck--;
window.requestAnimationFrame(waitForFinish);
}
}
function main()
{
let c1 = document.getElementById("c1");
let ctx1 = c1.getContext("2d", {"desynchronized": true});
let c2 = document.getElementById("c2");
let ctx2 = c2.getContext("2d", {"desynchronized": true});
let width = c1.width;
let height = c1.height;
ctx1.fillStyle = "#FF0000";
ctx1.fillRect(0, 0, 100, 100);
ctx2.drawImage(c1, 0, 0, 100, 100, 0, 0, 100, 100);
ctx1.fillStyle = "#00FF00";
ctx1.fillRect(0, 50, 50, 50);
ctx2.drawImage(c1, 0, 50, 50, 50, 0, 50, 50, 50);
ctx1.fillStyle = "#0000FF";
ctx1.fillRect(50, 0, 50, 50);
ctx2.drawImage(c1, 50, 0, 50, 50, 50, 0, 50, 50);
waitForFinish();
}
</script>
</head>
<body onload="main()">
<div id="container" style="position:absolute; top:0px; left:0px">
<canvas id="c1" width="100" height="100" class="nomargin"></canvas>
<canvas id="c2" width="100" height="100" class="nomargin"></canvas>
</div>
</body>
</html>