Merge pull request #1330 from twpayne/fail-if-major-performance-caveat
Don't use WebGL if there as a major performance caveat
This commit is contained in:
@@ -88,6 +88,7 @@ ol.renderer.webgl.Map = function(container, map) {
|
|||||||
this.gl_ = ol.webgl.getContext(this.canvas_, {
|
this.gl_ = ol.webgl.getContext(this.canvas_, {
|
||||||
antialias: true,
|
antialias: true,
|
||||||
depth: false,
|
depth: false,
|
||||||
|
failIfMajorPerformanceCaveat: true,
|
||||||
preserveDrawingBuffer: false,
|
preserveDrawingBuffer: false,
|
||||||
stencil: false
|
stencil: false
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -52,14 +52,20 @@ ol.webgl.getContext = function(canvas, opt_attributes) {
|
|||||||
* @const
|
* @const
|
||||||
* @type {boolean}
|
* @type {boolean}
|
||||||
*/
|
*/
|
||||||
ol.webgl.SUPPORTED = (function() {
|
ol.webgl.SUPPORTED = (
|
||||||
|
/**
|
||||||
|
* @return {boolean} WebGL supported.
|
||||||
|
*/
|
||||||
|
function() {
|
||||||
if (!('WebGLRenderingContext' in goog.global)) {
|
if (!('WebGLRenderingContext' in goog.global)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
var canvas = /** @type {HTMLCanvasElement} */
|
var canvas = /** @type {HTMLCanvasElement} */
|
||||||
(goog.dom.createElement(goog.dom.TagName.CANVAS));
|
(goog.dom.createElement(goog.dom.TagName.CANVAS));
|
||||||
return !goog.isNull(ol.webgl.getContext(canvas));
|
return !goog.isNull(ol.webgl.getContext(canvas, {
|
||||||
|
failIfMajorPerformanceCaveat: true
|
||||||
|
}));
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user