[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:
@@ -155,6 +155,7 @@ define(
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Switch from WebGL to plain 2D if context is lost
|
||||||
function fallbackFromWebGL() {
|
function fallbackFromWebGL() {
|
||||||
element.html(TEMPLATE);
|
element.html(TEMPLATE);
|
||||||
canvas = element.find("canvas")[0];
|
canvas = element.find("canvas")[0];
|
||||||
@@ -173,6 +174,11 @@ define(
|
|||||||
return;
|
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
|
// Check for resize, on a timer
|
||||||
activeInterval = $interval(drawIfResized, 1000);
|
activeInterval = $interval(drawIfResized, 1000);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user