<!DOCTYPE HTML>
<html>
<head>
<meta name="viewport" content="initial-scale=1">
<title>WebGL High to Low Power Transition Test</title>
<style type="text/css">
.nomargin {
margin: 0px auto;
}
</style>
<script src="pixel_webgl_fullscreen_quad.js"></script>
<script>
function ready() {
sendResult("CONTINUE", "Ready for second tab to be launched");
}
function initialize(runningOnDualGPUMacBookPro) {
if (runningOnDualGPUMacBookPro)
setRunningOnDualGpuSystem();
if (setup()) {
if (runningOnDualGPUMacBookPro) {
drawSomeFrames(notifyHarness);
} else {
// Short circuit the tab and high perf portion since we are not on a dual
// GPU machine.
runToCompletion();
}
}
}
function notifyHarness() {
assertRunningOnHighPerformanceGpu();
sendResult("CONTINUE", "Ready for second tab to be closed");
// When running on the passthrough command decoder and ANGLE, ANGLE
// can only detect the need to switch GPUs upon context switch.
// Schedule some rendering work 10 seconds from now so that ANGLE
// can detect and perform the switch.
const numSecondsBeforeGPUSwitch = 10;
setTimeout(() => drawSomeFrames(() => {}),
numSecondsBeforeGPUSwitch * 1000);
}
function runToCompletion() {
assertRunningOnLowPowerGpu();
drawSomeFrames(waitForFinish);
}
function waitForFinish()
{
let numFramesBeforeEnd = 15;
function waitForFinishImpl() {
if (--numFramesBeforeEnd == 0) {
sendResult("SUCCESS", "Test complete");
} else {
window.requestAnimationFrame(waitForFinishImpl);
}
}
window.requestAnimationFrame(waitForFinishImpl);
}
</script>
</head>
<body onload="ready()">
<canvas id="c" width="300" height="300" class="nomargin" style="position:absolute; top:0px; left:0px;"></canvas>
</body>
</html>