Remove goog.isNull in renderer classes

This commit is contained in:
Marc Jansen
2015-09-29 15:19:47 +02:00
parent 31a68e21a5
commit 138adf0509
15 changed files with 61 additions and 62 deletions
@@ -79,7 +79,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachFeatureAtCoordinate =
*/
ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
function(pixel, frameState, callback, thisArg) {
if (goog.isNull(this.getImage())) {
if (!this.getImage()) {
return undefined;
}
@@ -99,7 +99,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
}
} else {
// for all other image sources directly check the image
if (goog.isNull(this.imageTransformInv_)) {
if (!this.imageTransformInv_) {
this.imageTransformInv_ = goog.vec.Mat4.createNumber();
goog.vec.Mat4.invert(this.imageTransform_, this.imageTransformInv_);
}
@@ -107,7 +107,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
var pixelOnCanvas =
this.getPixelOnCanvas(pixel, this.imageTransformInv_);
if (goog.isNull(this.hitCanvasContext_)) {
if (!this.hitCanvasContext_) {
this.hitCanvasContext_ = ol.dom.createCanvasContext2D(1, 1);
}
@@ -129,8 +129,7 @@ ol.renderer.canvas.ImageLayer.prototype.forEachLayerAtPixel =
* @inheritDoc
*/
ol.renderer.canvas.ImageLayer.prototype.getImage = function() {
return goog.isNull(this.image_) ?
null : this.image_.getImage();
return !this.image_ ? null : this.image_.getImage();
};
@@ -172,14 +171,14 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
!ol.extent.isEmpty(renderedExtent)) {
var projection = viewState.projection;
var sourceProjection = imageSource.getProjection();
if (!goog.isNull(sourceProjection)) {
if (sourceProjection) {
goog.asserts.assert(ol.proj.equivalent(projection, sourceProjection),
'projection and sourceProjection are equivalent');
projection = sourceProjection;
}
image = imageSource.getImage(
renderedExtent, viewResolution, pixelRatio, projection);
if (!goog.isNull(image)) {
if (image) {
var loaded = this.loadImage(image);
if (loaded) {
this.image_ = image;
@@ -187,7 +186,7 @@ ol.renderer.canvas.ImageLayer.prototype.prepareFrame =
}
}
if (!goog.isNull(this.image_)) {
if (this.image_) {
image = this.image_;
var imageExtent = image.getExtent();
var imageResolution = image.getResolution();
@@ -44,7 +44,7 @@ ol.renderer.canvas.Layer.prototype.composeFrame =
this.dispatchPreComposeEvent(context, frameState);
var image = this.getImage();
if (!goog.isNull(image)) {
if (image) {
// clipped rendering if layer extent is set
var extent = layerState.extent;
@@ -252,7 +252,7 @@ ol.renderer.canvas.Layer.testCanvasSize = (function() {
var imageData = null;
return function(size) {
if (goog.isNull(context)) {
if (!context) {
context = ol.dom.createCanvasContext2D(1, 1);
imageData = context.createImageData(1, 1);
var data = imageData.data;
+1 -1
View File
@@ -146,7 +146,7 @@ ol.renderer.canvas.Map.prototype.getType = function() {
*/
ol.renderer.canvas.Map.prototype.renderFrame = function(frameState) {
if (goog.isNull(frameState)) {
if (!frameState) {
if (this.renderedVisible_) {
goog.style.setElementShown(this.canvas_, false);
this.renderedVisible_ = false;
@@ -231,12 +231,12 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
var canvasHeight = tilePixelSize[1] * tileRange.getHeight();
var canvas, context;
if (goog.isNull(this.canvas_)) {
goog.asserts.assert(goog.isNull(this.canvasSize_),
if (!this.canvas_) {
goog.asserts.assert(!this.canvasSize_,
'canvasSize is null (because canvas is null)');
goog.asserts.assert(goog.isNull(this.context_),
goog.asserts.assert(!this.context_,
'context is null (because canvas is null)');
goog.asserts.assert(goog.isNull(this.renderedCanvasTileRange_),
goog.asserts.assert(!this.renderedCanvasTileRange_,
'renderedCanvasTileRange is null (because canvas is null)');
context = ol.dom.createCanvasContext2D(canvasWidth, canvasHeight);
this.canvas_ = context.canvas;
@@ -245,9 +245,9 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
this.canvasTooBig_ =
!ol.renderer.canvas.Layer.testCanvasSize(this.canvasSize_);
} else {
goog.asserts.assert(!goog.isNull(this.canvasSize_),
goog.asserts.assert(this.canvasSize_,
'non-null canvasSize (because canvas is not null)');
goog.asserts.assert(!goog.isNull(this.context_),
goog.asserts.assert(this.context_,
'non-null context (because canvas is not null)');
canvas = this.canvas_;
context = this.context_;
@@ -277,7 +277,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
}
var canvasTileRange, canvasTileRangeWidth, minX, minY;
if (goog.isNull(this.renderedCanvasTileRange_)) {
if (!this.renderedCanvasTileRange_) {
canvasTileRangeWidth = canvasWidth / tilePixelSize[0];
var canvasTileRangeHeight = canvasHeight / tilePixelSize[1];
minX = tileRange.minX -
@@ -336,7 +336,7 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
tilesToClear.push(tile);
childTileRange = tileGrid.getTileCoordChildTileRange(
tile.tileCoord, tmpTileRange, tmpExtent);
if (!goog.isNull(childTileRange)) {
if (childTileRange) {
findLoadedTiles(z + 1, childTileRange);
}
}
@@ -450,11 +450,11 @@ ol.renderer.canvas.TileLayer.prototype.prepareFrame =
*/
ol.renderer.canvas.TileLayer.prototype.forEachLayerAtPixel =
function(pixel, frameState, callback, thisArg) {
if (goog.isNull(this.context_)) {
if (!this.context_) {
return undefined;
}
if (goog.isNull(this.imageTransformInv_)) {
if (!this.imageTransformInv_) {
this.imageTransformInv_ = goog.vec.Mat4.createNumber();
goog.vec.Mat4.invert(this.imageTransform_, this.imageTransformInv_);
}
@@ -92,7 +92,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
this.dispatchPreComposeEvent(context, frameState, transform);
var replayGroup = this.replayGroup_;
if (!goog.isNull(replayGroup) && !replayGroup.isEmpty()) {
if (replayGroup && !replayGroup.isEmpty()) {
var layer = this.getLayer();
var replayContext;
if (layer.hasListener(ol.render.EventType.RENDER)) {
@@ -156,7 +156,7 @@ ol.renderer.canvas.VectorLayer.prototype.composeFrame =
*/
ol.renderer.canvas.VectorLayer.prototype.forEachFeatureAtCoordinate =
function(coordinate, frameState, callback, thisArg) {
if (goog.isNull(this.replayGroup_)) {
if (!this.replayGroup_) {
return undefined;
} else {
var resolution = frameState.viewState.resolution;
@@ -290,7 +290,7 @@ ol.renderer.canvas.VectorLayer.prototype.prepareFrame =
this.dirty_ = this.dirty_ || dirty;
}
};
if (!goog.isNull(vectorLayerRenderOrder)) {
if (vectorLayerRenderOrder) {
/** @type {Array.<ol.Feature>} */
var features = [];
vectorSource.forEachFeatureInExtentAtResolution(extent, resolution,