Remove goog.asserts.*
This pull requests replaces type check hint assertions with type casts, library sanity check assertions with conditional console.assert statements in debug mode, and runtime sanity checks with assertions that throw an ol.AssertionError with an error code for lookup outside the library.
This commit is contained in:
@@ -1,6 +1,5 @@
|
||||
goog.provide('ol.webgl.Context');
|
||||
|
||||
goog.require('goog.asserts');
|
||||
goog.require('ol');
|
||||
goog.require('ol.Disposable');
|
||||
goog.require('ol.array');
|
||||
@@ -85,7 +84,7 @@ ol.webgl.Context = function(canvas, gl) {
|
||||
// use the OES_element_index_uint extension if available
|
||||
if (this.hasOESElementIndexUint) {
|
||||
var ext = gl.getExtension('OES_element_index_uint');
|
||||
goog.asserts.assert(ext,
|
||||
ol.DEBUG && console.assert(ext,
|
||||
'Failed to get extension "OES_element_index_uint"');
|
||||
}
|
||||
|
||||
@@ -115,7 +114,7 @@ ol.webgl.Context.prototype.bindBuffer = function(target, buf) {
|
||||
} else {
|
||||
var buffer = gl.createBuffer();
|
||||
gl.bindBuffer(target, buffer);
|
||||
goog.asserts.assert(target == ol.webgl.ARRAY_BUFFER ||
|
||||
ol.DEBUG && console.assert(target == ol.webgl.ARRAY_BUFFER ||
|
||||
target == ol.webgl.ELEMENT_ARRAY_BUFFER,
|
||||
'target is supposed to be an ARRAY_BUFFER or ELEMENT_ARRAY_BUFFER');
|
||||
var /** @type {ArrayBufferView} */ arrayBuffer;
|
||||
@@ -124,8 +123,6 @@ ol.webgl.Context.prototype.bindBuffer = function(target, buf) {
|
||||
} else if (target == ol.webgl.ELEMENT_ARRAY_BUFFER) {
|
||||
arrayBuffer = this.hasOESElementIndexUint ?
|
||||
new Uint32Array(arr) : new Uint16Array(arr);
|
||||
} else {
|
||||
goog.asserts.fail();
|
||||
}
|
||||
gl.bufferData(target, arrayBuffer, buf.getUsage());
|
||||
this.bufferCache_[bufferKey] = {
|
||||
@@ -142,7 +139,7 @@ ol.webgl.Context.prototype.bindBuffer = function(target, buf) {
|
||||
ol.webgl.Context.prototype.deleteBuffer = function(buf) {
|
||||
var gl = this.getGL();
|
||||
var bufferKey = String(ol.getUid(buf));
|
||||
goog.asserts.assert(bufferKey in this.bufferCache_,
|
||||
ol.DEBUG && console.assert(bufferKey in this.bufferCache_,
|
||||
'attempted to delete uncached buffer');
|
||||
var bufferCacheEntry = this.bufferCache_[bufferKey];
|
||||
if (!gl.isContextLost()) {
|
||||
@@ -222,7 +219,7 @@ ol.webgl.Context.prototype.getShader = function(shaderObject) {
|
||||
var shader = gl.createShader(shaderObject.getType());
|
||||
gl.shaderSource(shader, shaderObject.getSource());
|
||||
gl.compileShader(shader);
|
||||
goog.asserts.assert(
|
||||
ol.DEBUG && console.assert(
|
||||
gl.getShaderParameter(shader, ol.webgl.COMPILE_STATUS) ||
|
||||
gl.isContextLost(),
|
||||
gl.getShaderInfoLog(shader) || 'illegal state, shader not compiled or context lost');
|
||||
@@ -252,7 +249,7 @@ ol.webgl.Context.prototype.getProgram = function(
|
||||
gl.attachShader(program, this.getShader(fragmentShaderObject));
|
||||
gl.attachShader(program, this.getShader(vertexShaderObject));
|
||||
gl.linkProgram(program);
|
||||
goog.asserts.assert(
|
||||
ol.DEBUG && console.assert(
|
||||
gl.getProgramParameter(program, ol.webgl.LINK_STATUS) ||
|
||||
gl.isContextLost(),
|
||||
gl.getProgramInfoLog(program) || 'illegal state, shader not linked or context lost');
|
||||
|
||||
Reference in New Issue
Block a user