[Plot] Fall back from WebGL on context loss

When a WebGL context is loss, fall back to displaying
plots using regular canvas 2d API. WTD-475.
This commit is contained in:
Victor Woeltjen 2015-06-19 16:02:52 -07:00
parent dac44623ee
commit b6fdf4d6ab

View File

@ -155,6 +155,7 @@ define(
}
}
// Switch from WebGL to plain 2D if context is lost
function fallbackFromWebGL() {
element.html(TEMPLATE);
canvas = element.find("canvas")[0];
@ -173,6 +174,11 @@ define(
return;
}
// WebGL is a bit of a special case; it may work, then fail
// later for various reasons, so we need to listen for this
// and fall back to plain canvas drawing when it occurs.
canvas.addEventListener("webglcontextlost", fallbackFromWebGL);
// Check for resize, on a timer
activeInterval = $interval(drawIfResized, 1000);