1
    2
    3
    4
    5
    6
    7
    8
    9
   10
   11
   12
   13
   14
   15
   16
   17
   18
   19
   20
   21
   22
   23
   24
   25
   26
   27
   28
   29
   30
   31
   32
   33
   34
   35
   36
   37
   38
   39
   40
   41
   42
   43
   44
   45
   46
   47
   48
   49
   50
   51
   52
   53
   54
   55
   56
   57
   58
   59
   60
   61
   62
   63
   64
   65
   66
   67
   68
   69

content / test / data / gpu / pixel_webgl_high_to_low_power.html [blame]

<!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>