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

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

<!DOCTYPE HTML>

<html>
<head>
<meta name="viewport" content="initial-scale=1">
<title>WebGL Low to High Power alpha:false Transition Test</title>
<style type="text/css">
.nomargin {
  margin: 0px auto;
}
</style>
<script src="pixel_webgl_fullscreen_quad.js"></script>

<script>
function ready() {
  sendResult("READY", "Ready for initialize() to be called");
}

function initialize(runningOnDualGPUMacBookPro) {
  if (runningOnDualGPUMacBookPro)
    setRunningOnDualGpuSystem();
  if (setup({ alpha: false }))
    drawSomeFrames(allocateHighPowerContext);
}

function allocateHighPowerContext() {
  assertRunningOnLowPowerGpu();
  c2.getContext("webgl", { powerPreference: "high-performance" });
  // On macOS there is an approximately two second delay between activating the
  // discrete GPU and applications receiving a notification of its activation.
  // Avoid a race condition, and test flakiness, by waiting for twice as long as
  // this delay.
  setTimeout(() => {
    assertRunningOnHighPerformanceGpu();
    drawSomeFrames(waitForFinish);
  }, 4000);
}

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>
<canvas id="c2" width="1" height="1" class="nomargin"></canvas>
</body>
</html>