Use blocked scoped variables
In addition to using const and let, this also upgrades our linter config and removes lint (mostly whitespace).
This commit is contained in:
@@ -21,7 +21,7 @@ import _ol_webgl_Context_ from '../../webgl/Context.js';
|
||||
* @param {ol.layer.Image} imageLayer Tile layer.
|
||||
* @api
|
||||
*/
|
||||
var WebGLImageLayerRenderer = function(mapRenderer, imageLayer) {
|
||||
const WebGLImageLayerRenderer = function(mapRenderer, imageLayer) {
|
||||
|
||||
WebGLLayerRenderer.call(this, mapRenderer, imageLayer);
|
||||
|
||||
@@ -68,8 +68,8 @@ WebGLImageLayerRenderer['handles'] = function(type, layer) {
|
||||
*/
|
||||
WebGLImageLayerRenderer['create'] = function(mapRenderer, layer) {
|
||||
return new WebGLImageLayerRenderer(
|
||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||
/** @type {ol.layer.Image} */ (layer)
|
||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||
/** @type {ol.layer.Image} */ (layer)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -85,11 +85,11 @@ WebGLImageLayerRenderer.prototype.createTexture_ = function(image) {
|
||||
// http://www.khronos.org/webgl/wiki/WebGL_and_OpenGL_Differences#Non-Power_of_Two_Texture_Support
|
||||
// http://learningwebgl.com/blog/?p=2101
|
||||
|
||||
var imageElement = image.getImage();
|
||||
var gl = this.mapRenderer.getGL();
|
||||
const imageElement = image.getImage();
|
||||
const gl = this.mapRenderer.getGL();
|
||||
|
||||
return _ol_webgl_Context_.createTexture(
|
||||
gl, imageElement, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
|
||||
gl, imageElement, _ol_webgl_.CLAMP_TO_EDGE, _ol_webgl_.CLAMP_TO_EDGE);
|
||||
};
|
||||
|
||||
|
||||
@@ -97,21 +97,21 @@ WebGLImageLayerRenderer.prototype.createTexture_ = function(image) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLImageLayerRenderer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg) {
|
||||
var layer = this.getLayer();
|
||||
var source = layer.getSource();
|
||||
var resolution = frameState.viewState.resolution;
|
||||
var rotation = frameState.viewState.rotation;
|
||||
var skippedFeatureUids = frameState.skippedFeatureUids;
|
||||
const layer = this.getLayer();
|
||||
const source = layer.getSource();
|
||||
const resolution = frameState.viewState.resolution;
|
||||
const rotation = frameState.viewState.rotation;
|
||||
const skippedFeatureUids = frameState.skippedFeatureUids;
|
||||
return source.forEachFeatureAtCoordinate(
|
||||
coordinate, resolution, rotation, hitTolerance, skippedFeatureUids,
|
||||
coordinate, resolution, rotation, hitTolerance, skippedFeatureUids,
|
||||
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
return callback.call(thisArg, feature, layer);
|
||||
});
|
||||
function(feature) {
|
||||
return callback.call(thisArg, feature, layer);
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
@@ -120,38 +120,38 @@ WebGLImageLayerRenderer.prototype.forEachFeatureAtCoordinate = function(coordina
|
||||
*/
|
||||
WebGLImageLayerRenderer.prototype.prepareFrame = function(frameState, layerState, context) {
|
||||
|
||||
var gl = this.mapRenderer.getGL();
|
||||
const gl = this.mapRenderer.getGL();
|
||||
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
var viewState = frameState.viewState;
|
||||
var viewCenter = viewState.center;
|
||||
var viewResolution = viewState.resolution;
|
||||
var viewRotation = viewState.rotation;
|
||||
const pixelRatio = frameState.pixelRatio;
|
||||
const viewState = frameState.viewState;
|
||||
const viewCenter = viewState.center;
|
||||
const viewResolution = viewState.resolution;
|
||||
const viewRotation = viewState.rotation;
|
||||
|
||||
var image = this.image_;
|
||||
var texture = this.texture;
|
||||
var imageLayer = /** @type {ol.layer.Image} */ (this.getLayer());
|
||||
var imageSource = imageLayer.getSource();
|
||||
let image = this.image_;
|
||||
let texture = this.texture;
|
||||
const imageLayer = /** @type {ol.layer.Image} */ (this.getLayer());
|
||||
const imageSource = imageLayer.getSource();
|
||||
|
||||
var hints = frameState.viewHints;
|
||||
const hints = frameState.viewHints;
|
||||
|
||||
var renderedExtent = frameState.extent;
|
||||
let renderedExtent = frameState.extent;
|
||||
if (layerState.extent !== undefined) {
|
||||
renderedExtent = getIntersection(renderedExtent, layerState.extent);
|
||||
}
|
||||
if (!hints[ViewHint.ANIMATING] && !hints[ViewHint.INTERACTING] &&
|
||||
!isEmpty(renderedExtent)) {
|
||||
var projection = viewState.projection;
|
||||
let projection = viewState.projection;
|
||||
if (!ENABLE_RASTER_REPROJECTION) {
|
||||
var sourceProjection = imageSource.getProjection();
|
||||
const sourceProjection = imageSource.getProjection();
|
||||
if (sourceProjection) {
|
||||
projection = sourceProjection;
|
||||
}
|
||||
}
|
||||
var image_ = imageSource.getImage(renderedExtent, viewResolution,
|
||||
pixelRatio, projection);
|
||||
const image_ = imageSource.getImage(renderedExtent, viewResolution,
|
||||
pixelRatio, projection);
|
||||
if (image_) {
|
||||
var loaded = this.loadImage(image_);
|
||||
const loaded = this.loadImage(image_);
|
||||
if (loaded) {
|
||||
image = image_;
|
||||
texture = this.createTexture_(image_);
|
||||
@@ -160,13 +160,13 @@ WebGLImageLayerRenderer.prototype.prepareFrame = function(frameState, layerState
|
||||
* @param {WebGLRenderingContext} gl GL.
|
||||
* @param {WebGLTexture} texture Texture.
|
||||
*/
|
||||
var postRenderFunction = function(gl, texture) {
|
||||
const postRenderFunction = function(gl, texture) {
|
||||
if (!gl.isContextLost()) {
|
||||
gl.deleteTexture(texture);
|
||||
}
|
||||
}.bind(null, gl, this.texture);
|
||||
frameState.postRenderFunctions.push(
|
||||
/** @type {ol.PostRenderFunction} */ (postRenderFunction)
|
||||
/** @type {ol.PostRenderFunction} */ (postRenderFunction)
|
||||
);
|
||||
}
|
||||
}
|
||||
@@ -174,15 +174,15 @@ WebGLImageLayerRenderer.prototype.prepareFrame = function(frameState, layerState
|
||||
}
|
||||
|
||||
if (image) {
|
||||
var canvas = this.mapRenderer.getContext().getCanvas();
|
||||
const canvas = this.mapRenderer.getContext().getCanvas();
|
||||
|
||||
this.updateProjectionMatrix_(canvas.width, canvas.height,
|
||||
pixelRatio, viewCenter, viewResolution, viewRotation,
|
||||
image.getExtent());
|
||||
pixelRatio, viewCenter, viewResolution, viewRotation,
|
||||
image.getExtent());
|
||||
this.hitTransformationMatrix_ = null;
|
||||
|
||||
// Translate and scale to flip the Y coord.
|
||||
var texCoordMatrix = this.texCoordMatrix;
|
||||
const texCoordMatrix = this.texCoordMatrix;
|
||||
_ol_transform_.reset(texCoordMatrix);
|
||||
_ol_transform_.scale(texCoordMatrix, 1, -1);
|
||||
_ol_transform_.translate(texCoordMatrix, 0, -1);
|
||||
@@ -206,23 +206,23 @@ WebGLImageLayerRenderer.prototype.prepareFrame = function(frameState, layerState
|
||||
* @private
|
||||
*/
|
||||
WebGLImageLayerRenderer.prototype.updateProjectionMatrix_ = function(canvasWidth, canvasHeight, pixelRatio,
|
||||
viewCenter, viewResolution, viewRotation, imageExtent) {
|
||||
viewCenter, viewResolution, viewRotation, imageExtent) {
|
||||
|
||||
var canvasExtentWidth = canvasWidth * viewResolution;
|
||||
var canvasExtentHeight = canvasHeight * viewResolution;
|
||||
const canvasExtentWidth = canvasWidth * viewResolution;
|
||||
const canvasExtentHeight = canvasHeight * viewResolution;
|
||||
|
||||
var projectionMatrix = this.projectionMatrix;
|
||||
const projectionMatrix = this.projectionMatrix;
|
||||
_ol_transform_.reset(projectionMatrix);
|
||||
_ol_transform_.scale(projectionMatrix,
|
||||
pixelRatio * 2 / canvasExtentWidth,
|
||||
pixelRatio * 2 / canvasExtentHeight);
|
||||
pixelRatio * 2 / canvasExtentWidth,
|
||||
pixelRatio * 2 / canvasExtentHeight);
|
||||
_ol_transform_.rotate(projectionMatrix, -viewRotation);
|
||||
_ol_transform_.translate(projectionMatrix,
|
||||
imageExtent[0] - viewCenter[0],
|
||||
imageExtent[1] - viewCenter[1]);
|
||||
imageExtent[0] - viewCenter[0],
|
||||
imageExtent[1] - viewCenter[1]);
|
||||
_ol_transform_.scale(projectionMatrix,
|
||||
(imageExtent[2] - imageExtent[0]) / 2,
|
||||
(imageExtent[3] - imageExtent[1]) / 2);
|
||||
(imageExtent[2] - imageExtent[0]) / 2,
|
||||
(imageExtent[3] - imageExtent[1]) / 2);
|
||||
_ol_transform_.translate(projectionMatrix, 1, 1);
|
||||
|
||||
};
|
||||
@@ -232,7 +232,7 @@ WebGLImageLayerRenderer.prototype.updateProjectionMatrix_ = function(canvasWidth
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLImageLayerRenderer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState) {
|
||||
var hasFeature = this.forEachFeatureAtCoordinate(coordinate, frameState, 0, TRUE, this);
|
||||
const hasFeature = this.forEachFeatureAtCoordinate(coordinate, frameState, 0, TRUE, this);
|
||||
return hasFeature !== undefined;
|
||||
};
|
||||
|
||||
@@ -248,9 +248,9 @@ WebGLImageLayerRenderer.prototype.forEachLayerAtPixel = function(pixel, frameSta
|
||||
if (this.getLayer().getSource().forEachFeatureAtCoordinate !== nullFunction) {
|
||||
// for ImageCanvas sources use the original hit-detection logic,
|
||||
// so that for example also transparent polygons are detected
|
||||
var coordinate = _ol_transform_.apply(
|
||||
frameState.pixelToCoordinateTransform, pixel.slice());
|
||||
var hasFeature = this.forEachFeatureAtCoordinate(coordinate, frameState, 0, TRUE, this);
|
||||
const coordinate = _ol_transform_.apply(
|
||||
frameState.pixelToCoordinateTransform, pixel.slice());
|
||||
const hasFeature = this.forEachFeatureAtCoordinate(coordinate, frameState, 0, TRUE, this);
|
||||
|
||||
if (hasFeature) {
|
||||
return callback.call(thisArg, this.getLayer(), null);
|
||||
@@ -258,16 +258,16 @@ WebGLImageLayerRenderer.prototype.forEachLayerAtPixel = function(pixel, frameSta
|
||||
return undefined;
|
||||
}
|
||||
} else {
|
||||
var imageSize =
|
||||
const imageSize =
|
||||
[this.image_.getImage().width, this.image_.getImage().height];
|
||||
|
||||
if (!this.hitTransformationMatrix_) {
|
||||
this.hitTransformationMatrix_ = this.getHitTransformationMatrix_(
|
||||
frameState.size, imageSize);
|
||||
frameState.size, imageSize);
|
||||
}
|
||||
|
||||
var pixelOnFrameBuffer = _ol_transform_.apply(
|
||||
this.hitTransformationMatrix_, pixel.slice());
|
||||
const pixelOnFrameBuffer = _ol_transform_.apply(
|
||||
this.hitTransformationMatrix_, pixel.slice());
|
||||
|
||||
if (pixelOnFrameBuffer[0] < 0 || pixelOnFrameBuffer[0] > imageSize[0] ||
|
||||
pixelOnFrameBuffer[1] < 0 || pixelOnFrameBuffer[1] > imageSize[1]) {
|
||||
@@ -281,9 +281,9 @@ WebGLImageLayerRenderer.prototype.forEachLayerAtPixel = function(pixel, frameSta
|
||||
|
||||
this.hitCanvasContext_.clearRect(0, 0, 1, 1);
|
||||
this.hitCanvasContext_.drawImage(this.image_.getImage(),
|
||||
pixelOnFrameBuffer[0], pixelOnFrameBuffer[1], 1, 1, 0, 0, 1, 1);
|
||||
pixelOnFrameBuffer[0], pixelOnFrameBuffer[1], 1, 1, 0, 0, 1, 1);
|
||||
|
||||
var imageData = this.hitCanvasContext_.getImageData(0, 0, 1, 1).data;
|
||||
const imageData = this.hitCanvasContext_.getImageData(0, 0, 1, 1).data;
|
||||
if (imageData[3] > 0) {
|
||||
return callback.call(thisArg, this.getLayer(), imageData);
|
||||
} else {
|
||||
@@ -304,7 +304,7 @@ WebGLImageLayerRenderer.prototype.forEachLayerAtPixel = function(pixel, frameSta
|
||||
WebGLImageLayerRenderer.prototype.getHitTransformationMatrix_ = function(mapSize, imageSize) {
|
||||
// the first matrix takes a map pixel, flips the y-axis and scales to
|
||||
// a range between -1 ... 1
|
||||
var mapCoordTransform = _ol_transform_.create();
|
||||
const mapCoordTransform = _ol_transform_.create();
|
||||
_ol_transform_.translate(mapCoordTransform, -1, -1);
|
||||
_ol_transform_.scale(mapCoordTransform, 2 / mapSize[0], 2 / mapSize[1]);
|
||||
_ol_transform_.translate(mapCoordTransform, 0, mapSize[1]);
|
||||
@@ -312,10 +312,10 @@ WebGLImageLayerRenderer.prototype.getHitTransformationMatrix_ = function(mapSize
|
||||
|
||||
// the second matrix is the inverse of the projection matrix used in the
|
||||
// shader for drawing
|
||||
var projectionMatrixInv = _ol_transform_.invert(this.projectionMatrix.slice());
|
||||
const projectionMatrixInv = _ol_transform_.invert(this.projectionMatrix.slice());
|
||||
|
||||
// the third matrix scales to the image dimensions and flips the y-axis again
|
||||
var transform = _ol_transform_.create();
|
||||
const transform = _ol_transform_.create();
|
||||
_ol_transform_.translate(transform, 0, imageSize[1]);
|
||||
_ol_transform_.scale(transform, 1, -1);
|
||||
_ol_transform_.scale(transform, imageSize[0] / 2, imageSize[1] / 2);
|
||||
|
||||
@@ -21,7 +21,7 @@ import _ol_webgl_Context_ from '../../webgl/Context.js';
|
||||
* @param {ol.renderer.webgl.Map} mapRenderer Map renderer.
|
||||
* @param {ol.layer.Layer} layer Layer.
|
||||
*/
|
||||
var WebGLLayerRenderer = function(mapRenderer, layer) {
|
||||
const WebGLLayerRenderer = function(mapRenderer, layer) {
|
||||
|
||||
LayerRenderer.call(this, layer);
|
||||
|
||||
@@ -96,7 +96,7 @@ inherits(WebGLLayerRenderer, LayerRenderer);
|
||||
*/
|
||||
WebGLLayerRenderer.prototype.bindFramebuffer = function(frameState, framebufferDimension) {
|
||||
|
||||
var gl = this.mapRenderer.getGL();
|
||||
const gl = this.mapRenderer.getGL();
|
||||
|
||||
if (this.framebufferDimension === undefined ||
|
||||
this.framebufferDimension != framebufferDimension) {
|
||||
@@ -105,7 +105,7 @@ WebGLLayerRenderer.prototype.bindFramebuffer = function(frameState, framebufferD
|
||||
* @param {WebGLFramebuffer} framebuffer Framebuffer.
|
||||
* @param {WebGLTexture} texture Texture.
|
||||
*/
|
||||
var postRenderFunction = function(gl, framebuffer, texture) {
|
||||
const postRenderFunction = function(gl, framebuffer, texture) {
|
||||
if (!gl.isContextLost()) {
|
||||
gl.deleteFramebuffer(framebuffer);
|
||||
gl.deleteTexture(texture);
|
||||
@@ -113,16 +113,16 @@ WebGLLayerRenderer.prototype.bindFramebuffer = function(frameState, framebufferD
|
||||
}.bind(null, gl, this.framebuffer, this.texture);
|
||||
|
||||
frameState.postRenderFunctions.push(
|
||||
/** @type {ol.PostRenderFunction} */ (postRenderFunction)
|
||||
/** @type {ol.PostRenderFunction} */ (postRenderFunction)
|
||||
);
|
||||
|
||||
var texture = _ol_webgl_Context_.createEmptyTexture(
|
||||
gl, framebufferDimension, framebufferDimension);
|
||||
const texture = _ol_webgl_Context_.createEmptyTexture(
|
||||
gl, framebufferDimension, framebufferDimension);
|
||||
|
||||
var framebuffer = gl.createFramebuffer();
|
||||
const framebuffer = gl.createFramebuffer();
|
||||
gl.bindFramebuffer(_ol_webgl_.FRAMEBUFFER, framebuffer);
|
||||
gl.framebufferTexture2D(_ol_webgl_.FRAMEBUFFER,
|
||||
_ol_webgl_.COLOR_ATTACHMENT0, _ol_webgl_.TEXTURE_2D, texture, 0);
|
||||
_ol_webgl_.COLOR_ATTACHMENT0, _ol_webgl_.TEXTURE_2D, texture, 0);
|
||||
|
||||
this.texture = texture;
|
||||
this.framebuffer = framebuffer;
|
||||
@@ -146,14 +146,14 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
||||
|
||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.arrayBuffer_);
|
||||
|
||||
var gl = context.getGL();
|
||||
const gl = context.getGL();
|
||||
|
||||
var fragmentShader = _ol_renderer_webgl_defaultmapshader_.fragment;
|
||||
var vertexShader = _ol_renderer_webgl_defaultmapshader_.vertex;
|
||||
const fragmentShader = _ol_renderer_webgl_defaultmapshader_.fragment;
|
||||
const vertexShader = _ol_renderer_webgl_defaultmapshader_.vertex;
|
||||
|
||||
var program = context.getProgram(fragmentShader, vertexShader);
|
||||
const program = context.getProgram(fragmentShader, vertexShader);
|
||||
|
||||
var locations;
|
||||
let locations;
|
||||
if (!this.defaultLocations_) {
|
||||
locations = new _ol_renderer_webgl_defaultmapshader_Locations_(gl, program);
|
||||
this.defaultLocations_ = locations;
|
||||
@@ -164,17 +164,17 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
||||
if (context.useProgram(program)) {
|
||||
gl.enableVertexAttribArray(locations.a_position);
|
||||
gl.vertexAttribPointer(
|
||||
locations.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
||||
locations.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
||||
gl.enableVertexAttribArray(locations.a_texCoord);
|
||||
gl.vertexAttribPointer(
|
||||
locations.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
||||
locations.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
||||
gl.uniform1i(locations.u_texture, 0);
|
||||
}
|
||||
|
||||
gl.uniformMatrix4fv(locations.u_texCoordMatrix, false,
|
||||
fromTransform(this.tmpMat4_, this.getTexCoordMatrix()));
|
||||
fromTransform(this.tmpMat4_, this.getTexCoordMatrix()));
|
||||
gl.uniformMatrix4fv(locations.u_projectionMatrix, false,
|
||||
fromTransform(this.tmpMat4_, this.getProjectionMatrix()));
|
||||
fromTransform(this.tmpMat4_, this.getProjectionMatrix()));
|
||||
gl.uniform1f(locations.u_opacity, layerState.opacity);
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, this.getTexture());
|
||||
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
|
||||
@@ -190,20 +190,20 @@ WebGLLayerRenderer.prototype.composeFrame = function(frameState, layerState, con
|
||||
* @private
|
||||
*/
|
||||
WebGLLayerRenderer.prototype.dispatchComposeEvent_ = function(type, context, frameState) {
|
||||
var layer = this.getLayer();
|
||||
const layer = this.getLayer();
|
||||
if (layer.hasListener(type)) {
|
||||
var viewState = frameState.viewState;
|
||||
var resolution = viewState.resolution;
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
var extent = frameState.extent;
|
||||
var center = viewState.center;
|
||||
var rotation = viewState.rotation;
|
||||
var size = frameState.size;
|
||||
const viewState = frameState.viewState;
|
||||
const resolution = viewState.resolution;
|
||||
const pixelRatio = frameState.pixelRatio;
|
||||
const extent = frameState.extent;
|
||||
const center = viewState.center;
|
||||
const rotation = viewState.rotation;
|
||||
const size = frameState.size;
|
||||
|
||||
var render = new _ol_render_webgl_Immediate_(
|
||||
context, center, resolution, rotation, size, extent, pixelRatio);
|
||||
var composeEvent = new RenderEvent(
|
||||
type, render, frameState, null, context);
|
||||
const render = new _ol_render_webgl_Immediate_(
|
||||
context, center, resolution, rotation, size, extent, pixelRatio);
|
||||
const composeEvent = new RenderEvent(
|
||||
type, render, frameState, null, context);
|
||||
layer.dispatchEvent(composeEvent);
|
||||
}
|
||||
};
|
||||
|
||||
+103
-103
@@ -25,7 +25,7 @@ import ContextEventType from '../../webgl/ContextEventType.js';
|
||||
/**
|
||||
* @type {number} Texture cache high water mark.
|
||||
*/
|
||||
var WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
|
||||
const WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
|
||||
|
||||
|
||||
/**
|
||||
@@ -35,7 +35,7 @@ var WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK = 1024;
|
||||
* @param {ol.PluggableMap} map Map.
|
||||
* @api
|
||||
*/
|
||||
var WebGLMapRenderer = function(container, map) {
|
||||
const WebGLMapRenderer = function(container, map) {
|
||||
MapRenderer.call(this, container, map);
|
||||
|
||||
/**
|
||||
@@ -93,9 +93,9 @@ var WebGLMapRenderer = function(container, map) {
|
||||
this.context_ = new _ol_webgl_Context_(this.canvas_, this.gl_);
|
||||
|
||||
_ol_events_.listen(this.canvas_, ContextEventType.LOST,
|
||||
this.handleWebGLContextLost, this);
|
||||
this.handleWebGLContextLost, this);
|
||||
_ol_events_.listen(this.canvas_, ContextEventType.RESTORED,
|
||||
this.handleWebGLContextRestored, this);
|
||||
this.handleWebGLContextRestored, this);
|
||||
|
||||
/**
|
||||
* @private
|
||||
@@ -114,26 +114,26 @@ var WebGLMapRenderer = function(container, map) {
|
||||
* @type {ol.structs.PriorityQueue.<Array>}
|
||||
*/
|
||||
this.tileTextureQueue_ = new PriorityQueue(
|
||||
/**
|
||||
/**
|
||||
* @param {Array.<*>} element Element.
|
||||
* @return {number} Priority.
|
||||
* @this {ol.renderer.webgl.Map}
|
||||
*/
|
||||
(function(element) {
|
||||
var tileCenter = /** @type {ol.Coordinate} */ (element[1]);
|
||||
var tileResolution = /** @type {number} */ (element[2]);
|
||||
var deltaX = tileCenter[0] - this.focus_[0];
|
||||
var deltaY = tileCenter[1] - this.focus_[1];
|
||||
return 65536 * Math.log(tileResolution) +
|
||||
(function(element) {
|
||||
const tileCenter = /** @type {ol.Coordinate} */ (element[1]);
|
||||
const tileResolution = /** @type {number} */ (element[2]);
|
||||
const deltaX = tileCenter[0] - this.focus_[0];
|
||||
const deltaY = tileCenter[1] - this.focus_[1];
|
||||
return 65536 * Math.log(tileResolution) +
|
||||
Math.sqrt(deltaX * deltaX + deltaY * deltaY) / tileResolution;
|
||||
}).bind(this),
|
||||
/**
|
||||
}).bind(this),
|
||||
/**
|
||||
* @param {Array.<*>} element Element.
|
||||
* @return {string} Key.
|
||||
*/
|
||||
function(element) {
|
||||
return /** @type {ol.Tile} */ (element[0]).getKey();
|
||||
});
|
||||
function(element) {
|
||||
return /** @type {ol.Tile} */ (element[0]).getKey();
|
||||
});
|
||||
|
||||
|
||||
/**
|
||||
@@ -146,12 +146,12 @@ var WebGLMapRenderer = function(container, map) {
|
||||
function(map, frameState) {
|
||||
if (!this.tileTextureQueue_.isEmpty()) {
|
||||
this.tileTextureQueue_.reprioritize();
|
||||
var element = this.tileTextureQueue_.dequeue();
|
||||
var tile = /** @type {ol.Tile} */ (element[0]);
|
||||
var tileSize = /** @type {ol.Size} */ (element[3]);
|
||||
var tileGutter = /** @type {number} */ (element[4]);
|
||||
const element = this.tileTextureQueue_.dequeue();
|
||||
const tile = /** @type {ol.Tile} */ (element[0]);
|
||||
const tileSize = /** @type {ol.Size} */ (element[3]);
|
||||
const tileGutter = /** @type {number} */ (element[4]);
|
||||
this.bindTileTexture(
|
||||
tile, tileSize, tileGutter, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
||||
tile, tileSize, tileGutter, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
||||
}
|
||||
return false;
|
||||
}.bind(this);
|
||||
@@ -198,27 +198,27 @@ WebGLMapRenderer['create'] = function(container, map) {
|
||||
* @param {number} minFilter Min filter.
|
||||
*/
|
||||
WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter, magFilter, minFilter) {
|
||||
var gl = this.getGL();
|
||||
var tileKey = tile.getKey();
|
||||
const gl = this.getGL();
|
||||
const tileKey = tile.getKey();
|
||||
if (this.textureCache_.containsKey(tileKey)) {
|
||||
var textureCacheEntry = this.textureCache_.get(tileKey);
|
||||
const textureCacheEntry = this.textureCache_.get(tileKey);
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, textureCacheEntry.texture);
|
||||
if (textureCacheEntry.magFilter != magFilter) {
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
||||
textureCacheEntry.magFilter = magFilter;
|
||||
}
|
||||
if (textureCacheEntry.minFilter != minFilter) {
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
||||
textureCacheEntry.minFilter = minFilter;
|
||||
}
|
||||
} else {
|
||||
var texture = gl.createTexture();
|
||||
const texture = gl.createTexture();
|
||||
gl.bindTexture(_ol_webgl_.TEXTURE_2D, texture);
|
||||
if (tileGutter > 0) {
|
||||
var clipTileCanvas = this.clipTileContext_.canvas;
|
||||
var clipTileContext = this.clipTileContext_;
|
||||
const clipTileCanvas = this.clipTileContext_.canvas;
|
||||
const clipTileContext = this.clipTileContext_;
|
||||
if (this.clipTileCanvasWidth_ !== tileSize[0] ||
|
||||
this.clipTileCanvasHeight_ !== tileSize[1]) {
|
||||
clipTileCanvas.width = tileSize[0];
|
||||
@@ -229,23 +229,23 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
|
||||
clipTileContext.clearRect(0, 0, tileSize[0], tileSize[1]);
|
||||
}
|
||||
clipTileContext.drawImage(tile.getImage(), tileGutter, tileGutter,
|
||||
tileSize[0], tileSize[1], 0, 0, tileSize[0], tileSize[1]);
|
||||
tileSize[0], tileSize[1], 0, 0, tileSize[0], tileSize[1]);
|
||||
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
|
||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
||||
_ol_webgl_.UNSIGNED_BYTE, clipTileCanvas);
|
||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
||||
_ol_webgl_.UNSIGNED_BYTE, clipTileCanvas);
|
||||
} else {
|
||||
gl.texImage2D(_ol_webgl_.TEXTURE_2D, 0,
|
||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
||||
_ol_webgl_.UNSIGNED_BYTE, tile.getImage());
|
||||
_ol_webgl_.RGBA, _ol_webgl_.RGBA,
|
||||
_ol_webgl_.UNSIGNED_BYTE, tile.getImage());
|
||||
}
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MAG_FILTER, magFilter);
|
||||
gl.texParameteri(
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
||||
_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_MIN_FILTER, minFilter);
|
||||
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_S,
|
||||
_ol_webgl_.CLAMP_TO_EDGE);
|
||||
_ol_webgl_.CLAMP_TO_EDGE);
|
||||
gl.texParameteri(_ol_webgl_.TEXTURE_2D, _ol_webgl_.TEXTURE_WRAP_T,
|
||||
_ol_webgl_.CLAMP_TO_EDGE);
|
||||
_ol_webgl_.CLAMP_TO_EDGE);
|
||||
this.textureCache_.set(tileKey, {
|
||||
texture: texture,
|
||||
magFilter: magFilter,
|
||||
@@ -261,23 +261,23 @@ WebGLMapRenderer.prototype.bindTileTexture = function(tile, tileSize, tileGutter
|
||||
* @private
|
||||
*/
|
||||
WebGLMapRenderer.prototype.dispatchComposeEvent_ = function(type, frameState) {
|
||||
var map = this.getMap();
|
||||
const map = this.getMap();
|
||||
if (map.hasListener(type)) {
|
||||
var context = this.context_;
|
||||
const context = this.context_;
|
||||
|
||||
var extent = frameState.extent;
|
||||
var size = frameState.size;
|
||||
var viewState = frameState.viewState;
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
const extent = frameState.extent;
|
||||
const size = frameState.size;
|
||||
const viewState = frameState.viewState;
|
||||
const pixelRatio = frameState.pixelRatio;
|
||||
|
||||
var resolution = viewState.resolution;
|
||||
var center = viewState.center;
|
||||
var rotation = viewState.rotation;
|
||||
const resolution = viewState.resolution;
|
||||
const center = viewState.center;
|
||||
const rotation = viewState.rotation;
|
||||
|
||||
var vectorContext = new _ol_render_webgl_Immediate_(context,
|
||||
center, resolution, rotation, size, extent, pixelRatio);
|
||||
var composeEvent = new RenderEvent(type, vectorContext,
|
||||
frameState, null, context);
|
||||
const vectorContext = new _ol_render_webgl_Immediate_(context,
|
||||
center, resolution, rotation, size, extent, pixelRatio);
|
||||
const composeEvent = new RenderEvent(type, vectorContext,
|
||||
frameState, null, context);
|
||||
map.dispatchEvent(composeEvent);
|
||||
}
|
||||
};
|
||||
@@ -287,18 +287,18 @@ WebGLMapRenderer.prototype.dispatchComposeEvent_ = function(type, frameState) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLMapRenderer.prototype.disposeInternal = function() {
|
||||
var gl = this.getGL();
|
||||
const gl = this.getGL();
|
||||
if (!gl.isContextLost()) {
|
||||
this.textureCache_.forEach(
|
||||
/**
|
||||
/**
|
||||
* @param {?ol.WebglTextureCacheEntry} textureCacheEntry
|
||||
* Texture cache entry.
|
||||
*/
|
||||
function(textureCacheEntry) {
|
||||
if (textureCacheEntry) {
|
||||
gl.deleteTexture(textureCacheEntry.texture);
|
||||
}
|
||||
});
|
||||
function(textureCacheEntry) {
|
||||
if (textureCacheEntry) {
|
||||
gl.deleteTexture(textureCacheEntry.texture);
|
||||
}
|
||||
});
|
||||
}
|
||||
this.context_.dispose();
|
||||
MapRenderer.prototype.disposeInternal.call(this);
|
||||
@@ -311,8 +311,8 @@ WebGLMapRenderer.prototype.disposeInternal = function() {
|
||||
* @private
|
||||
*/
|
||||
WebGLMapRenderer.prototype.expireCache_ = function(map, frameState) {
|
||||
var gl = this.getGL();
|
||||
var textureCacheEntry;
|
||||
const gl = this.getGL();
|
||||
let textureCacheEntry;
|
||||
while (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ >
|
||||
WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) {
|
||||
textureCacheEntry = this.textureCache_.peekLast();
|
||||
@@ -371,9 +371,9 @@ WebGLMapRenderer.prototype.handleWebGLContextLost = function(event) {
|
||||
this.textureCache_.clear();
|
||||
this.textureCacheFrameMarkerCount_ = 0;
|
||||
|
||||
var renderers = this.getLayerRenderers();
|
||||
for (var id in renderers) {
|
||||
var renderer = /** @type {ol.renderer.webgl.Layer} */ (renderers[id]);
|
||||
const renderers = this.getLayerRenderers();
|
||||
for (const id in renderers) {
|
||||
const renderer = /** @type {ol.renderer.webgl.Layer} */ (renderers[id]);
|
||||
renderer.handleWebGLContextLost();
|
||||
}
|
||||
};
|
||||
@@ -392,11 +392,11 @@ WebGLMapRenderer.prototype.handleWebGLContextRestored = function() {
|
||||
* @private
|
||||
*/
|
||||
WebGLMapRenderer.prototype.initializeGL_ = function() {
|
||||
var gl = this.gl_;
|
||||
const gl = this.gl_;
|
||||
gl.activeTexture(_ol_webgl_.TEXTURE0);
|
||||
gl.blendFuncSeparate(
|
||||
_ol_webgl_.SRC_ALPHA, _ol_webgl_.ONE_MINUS_SRC_ALPHA,
|
||||
_ol_webgl_.ONE, _ol_webgl_.ONE_MINUS_SRC_ALPHA);
|
||||
_ol_webgl_.SRC_ALPHA, _ol_webgl_.ONE_MINUS_SRC_ALPHA,
|
||||
_ol_webgl_.ONE, _ol_webgl_.ONE_MINUS_SRC_ALPHA);
|
||||
gl.disable(_ol_webgl_.CULL_FACE);
|
||||
gl.disable(_ol_webgl_.DEPTH_TEST);
|
||||
gl.disable(_ol_webgl_.SCISSOR_TEST);
|
||||
@@ -418,8 +418,8 @@ WebGLMapRenderer.prototype.isTileTextureLoaded = function(tile) {
|
||||
*/
|
||||
WebGLMapRenderer.prototype.renderFrame = function(frameState) {
|
||||
|
||||
var context = this.getContext();
|
||||
var gl = this.getGL();
|
||||
const context = this.getContext();
|
||||
const gl = this.getGL();
|
||||
|
||||
if (gl.isContextLost()) {
|
||||
return false;
|
||||
@@ -441,12 +441,12 @@ WebGLMapRenderer.prototype.renderFrame = function(frameState) {
|
||||
this.dispatchComposeEvent_(RenderEventType.PRECOMPOSE, frameState);
|
||||
|
||||
/** @type {Array.<ol.LayerState>} */
|
||||
var layerStatesToDraw = [];
|
||||
var layerStatesArray = frameState.layerStatesArray;
|
||||
const layerStatesToDraw = [];
|
||||
const layerStatesArray = frameState.layerStatesArray;
|
||||
stableSort(layerStatesArray, MapRenderer.sortByZIndex);
|
||||
|
||||
var viewResolution = frameState.viewState.resolution;
|
||||
var i, ii, layerRenderer, layerState;
|
||||
const viewResolution = frameState.viewState.resolution;
|
||||
let i, ii, layerRenderer, layerState;
|
||||
for (i = 0, ii = layerStatesArray.length; i < ii; ++i) {
|
||||
layerState = layerStatesArray[i];
|
||||
if (Layer.visibleAtResolution(layerState, viewResolution) &&
|
||||
@@ -458,8 +458,8 @@ WebGLMapRenderer.prototype.renderFrame = function(frameState) {
|
||||
}
|
||||
}
|
||||
|
||||
var width = frameState.size[0] * frameState.pixelRatio;
|
||||
var height = frameState.size[1] * frameState.pixelRatio;
|
||||
const width = frameState.size[0] * frameState.pixelRatio;
|
||||
const height = frameState.size[1] * frameState.pixelRatio;
|
||||
if (this.canvas_.width != width || this.canvas_.height != height) {
|
||||
this.canvas_.width = width;
|
||||
this.canvas_.height = height;
|
||||
@@ -488,7 +488,7 @@ WebGLMapRenderer.prototype.renderFrame = function(frameState) {
|
||||
if (this.textureCache_.getCount() - this.textureCacheFrameMarkerCount_ >
|
||||
WEBGL_TEXTURE_CACHE_HIGH_WATER_MARK) {
|
||||
frameState.postRenderFunctions.push(
|
||||
/** @type {ol.PostRenderFunction} */ (this.expireCache_.bind(this))
|
||||
/** @type {ol.PostRenderFunction} */ (this.expireCache_.bind(this))
|
||||
);
|
||||
}
|
||||
|
||||
@@ -509,26 +509,26 @@ WebGLMapRenderer.prototype.renderFrame = function(frameState) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLMapRenderer.prototype.forEachFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, callback, thisArg,
|
||||
layerFilter, thisArg2) {
|
||||
var result;
|
||||
layerFilter, thisArg2) {
|
||||
let result;
|
||||
|
||||
if (this.getGL().isContextLost()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var viewState = frameState.viewState;
|
||||
const viewState = frameState.viewState;
|
||||
|
||||
var layerStates = frameState.layerStatesArray;
|
||||
var numLayers = layerStates.length;
|
||||
var i;
|
||||
const layerStates = frameState.layerStatesArray;
|
||||
const numLayers = layerStates.length;
|
||||
let i;
|
||||
for (i = numLayers - 1; i >= 0; --i) {
|
||||
var layerState = layerStates[i];
|
||||
var layer = layerState.layer;
|
||||
const layerState = layerStates[i];
|
||||
const layer = layerState.layer;
|
||||
if (Layer.visibleAtResolution(layerState, viewState.resolution) &&
|
||||
layerFilter.call(thisArg2, layer)) {
|
||||
var layerRenderer = this.getLayerRenderer(layer);
|
||||
const layerRenderer = this.getLayerRenderer(layer);
|
||||
result = layerRenderer.forEachFeatureAtCoordinate(
|
||||
coordinate, frameState, hitTolerance, callback, thisArg);
|
||||
coordinate, frameState, hitTolerance, callback, thisArg);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
@@ -542,23 +542,23 @@ WebGLMapRenderer.prototype.forEachFeatureAtCoordinate = function(coordinate, fra
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLMapRenderer.prototype.hasFeatureAtCoordinate = function(coordinate, frameState, hitTolerance, layerFilter, thisArg) {
|
||||
var hasFeature = false;
|
||||
let hasFeature = false;
|
||||
|
||||
if (this.getGL().isContextLost()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var viewState = frameState.viewState;
|
||||
const viewState = frameState.viewState;
|
||||
|
||||
var layerStates = frameState.layerStatesArray;
|
||||
var numLayers = layerStates.length;
|
||||
var i;
|
||||
const layerStates = frameState.layerStatesArray;
|
||||
const numLayers = layerStates.length;
|
||||
let i;
|
||||
for (i = numLayers - 1; i >= 0; --i) {
|
||||
var layerState = layerStates[i];
|
||||
var layer = layerState.layer;
|
||||
const layerState = layerStates[i];
|
||||
const layer = layerState.layer;
|
||||
if (Layer.visibleAtResolution(layerState, viewState.resolution) &&
|
||||
layerFilter.call(thisArg, layer)) {
|
||||
var layerRenderer = this.getLayerRenderer(layer);
|
||||
const layerRenderer = this.getLayerRenderer(layer);
|
||||
hasFeature =
|
||||
layerRenderer.hasFeatureAtCoordinate(coordinate, frameState);
|
||||
if (hasFeature) {
|
||||
@@ -574,25 +574,25 @@ WebGLMapRenderer.prototype.hasFeatureAtCoordinate = function(coordinate, frameSt
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLMapRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg,
|
||||
layerFilter, thisArg2) {
|
||||
layerFilter, thisArg2) {
|
||||
if (this.getGL().isContextLost()) {
|
||||
return false;
|
||||
}
|
||||
|
||||
var viewState = frameState.viewState;
|
||||
var result;
|
||||
const viewState = frameState.viewState;
|
||||
let result;
|
||||
|
||||
var layerStates = frameState.layerStatesArray;
|
||||
var numLayers = layerStates.length;
|
||||
var i;
|
||||
const layerStates = frameState.layerStatesArray;
|
||||
const numLayers = layerStates.length;
|
||||
let i;
|
||||
for (i = numLayers - 1; i >= 0; --i) {
|
||||
var layerState = layerStates[i];
|
||||
var layer = layerState.layer;
|
||||
const layerState = layerStates[i];
|
||||
const layer = layerState.layer;
|
||||
if (Layer.visibleAtResolution(layerState, viewState.resolution) &&
|
||||
layerFilter.call(thisArg, layer)) {
|
||||
var layerRenderer = /** @type {ol.renderer.webgl.Layer} */ (this.getLayerRenderer(layer));
|
||||
const layerRenderer = /** @type {ol.renderer.webgl.Layer} */ (this.getLayerRenderer(layer));
|
||||
result = layerRenderer.forEachLayerAtPixel(
|
||||
pixel, frameState, callback, thisArg);
|
||||
pixel, frameState, callback, thisArg);
|
||||
if (result) {
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,7 @@ import _ol_webgl_Buffer_ from '../../webgl/Buffer.js';
|
||||
* @param {ol.layer.Tile} tileLayer Tile layer.
|
||||
* @api
|
||||
*/
|
||||
var WebGLTileLayerRenderer = function(mapRenderer, tileLayer) {
|
||||
const WebGLTileLayerRenderer = function(mapRenderer, tileLayer) {
|
||||
|
||||
WebGLLayerRenderer.call(this, mapRenderer, tileLayer);
|
||||
|
||||
@@ -108,8 +108,8 @@ WebGLTileLayerRenderer['handles'] = function(type, layer) {
|
||||
*/
|
||||
WebGLTileLayerRenderer['create'] = function(mapRenderer, layer) {
|
||||
return new WebGLTileLayerRenderer(
|
||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||
/** @type {ol.layer.Tile} */ (layer)
|
||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||
/** @type {ol.layer.Tile} */ (layer)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -118,7 +118,7 @@ WebGLTileLayerRenderer['create'] = function(mapRenderer, layer) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLTileLayerRenderer.prototype.disposeInternal = function() {
|
||||
var context = this.mapRenderer.getContext();
|
||||
const context = this.mapRenderer.getContext();
|
||||
context.deleteBuffer(this.renderArrayBuffer_);
|
||||
WebGLLayerRenderer.prototype.disposeInternal.call(this);
|
||||
};
|
||||
@@ -128,7 +128,7 @@ WebGLTileLayerRenderer.prototype.disposeInternal = function() {
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLTileLayerRenderer.prototype.createLoadedTileFinder = function(source, projection, tiles) {
|
||||
var mapRenderer = this.mapRenderer;
|
||||
const mapRenderer = this.mapRenderer;
|
||||
|
||||
return (
|
||||
/**
|
||||
@@ -138,7 +138,7 @@ WebGLTileLayerRenderer.prototype.createLoadedTileFinder = function(source, proje
|
||||
*/
|
||||
function(zoom, tileRange) {
|
||||
function callback(tile) {
|
||||
var loaded = mapRenderer.isTileTextureLoaded(tile);
|
||||
const loaded = mapRenderer.isTileTextureLoaded(tile);
|
||||
if (loaded) {
|
||||
if (!tiles[zoom]) {
|
||||
tiles[zoom] = {};
|
||||
@@ -166,47 +166,47 @@ WebGLTileLayerRenderer.prototype.handleWebGLContextLost = function() {
|
||||
*/
|
||||
WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState, context) {
|
||||
|
||||
var mapRenderer = this.mapRenderer;
|
||||
var gl = context.getGL();
|
||||
const mapRenderer = this.mapRenderer;
|
||||
const gl = context.getGL();
|
||||
|
||||
var viewState = frameState.viewState;
|
||||
var projection = viewState.projection;
|
||||
const viewState = frameState.viewState;
|
||||
const projection = viewState.projection;
|
||||
|
||||
var tileLayer = /** @type {ol.layer.Tile} */ (this.getLayer());
|
||||
var tileSource = tileLayer.getSource();
|
||||
var tileGrid = tileSource.getTileGridForProjection(projection);
|
||||
var z = tileGrid.getZForResolution(viewState.resolution);
|
||||
var tileResolution = tileGrid.getResolution(z);
|
||||
const tileLayer = /** @type {ol.layer.Tile} */ (this.getLayer());
|
||||
const tileSource = tileLayer.getSource();
|
||||
const tileGrid = tileSource.getTileGridForProjection(projection);
|
||||
const z = tileGrid.getZForResolution(viewState.resolution);
|
||||
const tileResolution = tileGrid.getResolution(z);
|
||||
|
||||
var tilePixelSize =
|
||||
const tilePixelSize =
|
||||
tileSource.getTilePixelSize(z, frameState.pixelRatio, projection);
|
||||
var pixelRatio = tilePixelSize[0] /
|
||||
const pixelRatio = tilePixelSize[0] /
|
||||
_ol_size_.toSize(tileGrid.getTileSize(z), this.tmpSize_)[0];
|
||||
var tilePixelResolution = tileResolution / pixelRatio;
|
||||
var tileGutter = tileSource.getTilePixelRatio(pixelRatio) * tileSource.getGutter(projection);
|
||||
const tilePixelResolution = tileResolution / pixelRatio;
|
||||
const tileGutter = tileSource.getTilePixelRatio(pixelRatio) * tileSource.getGutter(projection);
|
||||
|
||||
var center = viewState.center;
|
||||
var extent = frameState.extent;
|
||||
var tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
|
||||
const center = viewState.center;
|
||||
const extent = frameState.extent;
|
||||
const tileRange = tileGrid.getTileRangeForExtentAndZ(extent, z);
|
||||
|
||||
var framebufferExtent;
|
||||
let framebufferExtent;
|
||||
if (this.renderedTileRange_ &&
|
||||
this.renderedTileRange_.equals(tileRange) &&
|
||||
this.renderedRevision_ == tileSource.getRevision()) {
|
||||
framebufferExtent = this.renderedFramebufferExtent_;
|
||||
} else {
|
||||
|
||||
var tileRangeSize = tileRange.getSize();
|
||||
const tileRangeSize = tileRange.getSize();
|
||||
|
||||
var maxDimension = Math.max(
|
||||
tileRangeSize[0] * tilePixelSize[0],
|
||||
tileRangeSize[1] * tilePixelSize[1]);
|
||||
var framebufferDimension = roundUpToPowerOfTwo(maxDimension);
|
||||
var framebufferExtentDimension = tilePixelResolution * framebufferDimension;
|
||||
var origin = tileGrid.getOrigin(z);
|
||||
var minX = origin[0] +
|
||||
const maxDimension = Math.max(
|
||||
tileRangeSize[0] * tilePixelSize[0],
|
||||
tileRangeSize[1] * tilePixelSize[1]);
|
||||
const framebufferDimension = roundUpToPowerOfTwo(maxDimension);
|
||||
const framebufferExtentDimension = tilePixelResolution * framebufferDimension;
|
||||
const origin = tileGrid.getOrigin(z);
|
||||
const minX = origin[0] +
|
||||
tileRange.minX * tilePixelSize[0] * tilePixelResolution;
|
||||
var minY = origin[1] +
|
||||
const minY = origin[1] +
|
||||
tileRange.minY * tilePixelSize[1] * tilePixelResolution;
|
||||
framebufferExtent = [
|
||||
minX, minY,
|
||||
@@ -220,7 +220,7 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
gl.clear(_ol_webgl_.COLOR_BUFFER_BIT);
|
||||
gl.disable(_ol_webgl_.BLEND);
|
||||
|
||||
var program = context.getProgram(this.fragmentShader_, this.vertexShader_);
|
||||
const program = context.getProgram(this.fragmentShader_, this.vertexShader_);
|
||||
context.useProgram(program);
|
||||
if (!this.locations_) {
|
||||
this.locations_ = new _ol_renderer_webgl_tilelayershader_Locations_(gl, program);
|
||||
@@ -229,27 +229,27 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
context.bindBuffer(_ol_webgl_.ARRAY_BUFFER, this.renderArrayBuffer_);
|
||||
gl.enableVertexAttribArray(this.locations_.a_position);
|
||||
gl.vertexAttribPointer(
|
||||
this.locations_.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
||||
this.locations_.a_position, 2, _ol_webgl_.FLOAT, false, 16, 0);
|
||||
gl.enableVertexAttribArray(this.locations_.a_texCoord);
|
||||
gl.vertexAttribPointer(
|
||||
this.locations_.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
||||
this.locations_.a_texCoord, 2, _ol_webgl_.FLOAT, false, 16, 8);
|
||||
gl.uniform1i(this.locations_.u_texture, 0);
|
||||
|
||||
/**
|
||||
* @type {Object.<number, Object.<string, ol.Tile>>}
|
||||
*/
|
||||
var tilesToDrawByZ = {};
|
||||
const tilesToDrawByZ = {};
|
||||
tilesToDrawByZ[z] = {};
|
||||
|
||||
var findLoadedTiles = this.createLoadedTileFinder(
|
||||
tileSource, projection, tilesToDrawByZ);
|
||||
const findLoadedTiles = this.createLoadedTileFinder(
|
||||
tileSource, projection, tilesToDrawByZ);
|
||||
|
||||
var useInterimTilesOnError = tileLayer.getUseInterimTilesOnError();
|
||||
var allTilesLoaded = true;
|
||||
var tmpExtent = createEmpty();
|
||||
var tmpTileRange = new TileRange(0, 0, 0, 0);
|
||||
var childTileRange, drawable, fullyLoaded, tile, tileState;
|
||||
var x, y, tileExtent;
|
||||
const useInterimTilesOnError = tileLayer.getUseInterimTilesOnError();
|
||||
let allTilesLoaded = true;
|
||||
const tmpExtent = createEmpty();
|
||||
const tmpTileRange = new TileRange(0, 0, 0, 0);
|
||||
let childTileRange, drawable, fullyLoaded, tile, tileState;
|
||||
let x, y, tileExtent;
|
||||
for (x = tileRange.minX; x <= tileRange.maxX; ++x) {
|
||||
for (y = tileRange.minY; y <= tileRange.maxY; ++y) {
|
||||
|
||||
@@ -282,10 +282,10 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
|
||||
allTilesLoaded = false;
|
||||
fullyLoaded = tileGrid.forEachTileCoordParentTileRange(
|
||||
tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent);
|
||||
tile.tileCoord, findLoadedTiles, null, tmpTileRange, tmpExtent);
|
||||
if (!fullyLoaded) {
|
||||
childTileRange = tileGrid.getTileCoordChildTileRange(
|
||||
tile.tileCoord, tmpTileRange, tmpExtent);
|
||||
tile.tileCoord, tmpTileRange, tmpExtent);
|
||||
if (childTileRange) {
|
||||
findLoadedTiles(z + 1, childTileRange);
|
||||
}
|
||||
@@ -296,10 +296,10 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
}
|
||||
|
||||
/** @type {Array.<number>} */
|
||||
var zs = Object.keys(tilesToDrawByZ).map(Number);
|
||||
const zs = Object.keys(tilesToDrawByZ).map(Number);
|
||||
zs.sort(numberSafeCompareFunction);
|
||||
var u_tileOffset = new Float32Array(4);
|
||||
var i, ii, tileKey, tilesToDraw;
|
||||
const u_tileOffset = new Float32Array(4);
|
||||
let i, ii, tileKey, tilesToDraw;
|
||||
for (i = 0, ii = zs.length; i < ii; ++i) {
|
||||
tilesToDraw = tilesToDrawByZ[zs[i]];
|
||||
for (tileKey in tilesToDraw) {
|
||||
@@ -315,7 +315,7 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
framebufferExtentDimension - 1;
|
||||
gl.uniform4fv(this.locations_.u_tileOffset, u_tileOffset);
|
||||
mapRenderer.bindTileTexture(tile, tilePixelSize,
|
||||
tileGutter * pixelRatio, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
||||
tileGutter * pixelRatio, _ol_webgl_.LINEAR, _ol_webgl_.LINEAR);
|
||||
gl.drawArrays(_ol_webgl_.TRIANGLE_STRIP, 0, 4);
|
||||
}
|
||||
}
|
||||
@@ -334,41 +334,41 @@ WebGLTileLayerRenderer.prototype.prepareFrame = function(frameState, layerState,
|
||||
}
|
||||
|
||||
this.updateUsedTiles(frameState.usedTiles, tileSource, z, tileRange);
|
||||
var tileTextureQueue = mapRenderer.getTileTextureQueue();
|
||||
const tileTextureQueue = mapRenderer.getTileTextureQueue();
|
||||
this.manageTilePyramid(
|
||||
frameState, tileSource, tileGrid, pixelRatio, projection, extent, z,
|
||||
tileLayer.getPreload(),
|
||||
/**
|
||||
frameState, tileSource, tileGrid, pixelRatio, projection, extent, z,
|
||||
tileLayer.getPreload(),
|
||||
/**
|
||||
* @param {ol.Tile} tile Tile.
|
||||
*/
|
||||
function(tile) {
|
||||
if (tile.getState() == TileState.LOADED &&
|
||||
function(tile) {
|
||||
if (tile.getState() == TileState.LOADED &&
|
||||
!mapRenderer.isTileTextureLoaded(tile) &&
|
||||
!tileTextureQueue.isKeyQueued(tile.getKey())) {
|
||||
tileTextureQueue.enqueue([
|
||||
tile,
|
||||
tileGrid.getTileCoordCenter(tile.tileCoord),
|
||||
tileGrid.getResolution(tile.tileCoord[0]),
|
||||
tilePixelSize, tileGutter * pixelRatio
|
||||
]);
|
||||
}
|
||||
}, this);
|
||||
tileTextureQueue.enqueue([
|
||||
tile,
|
||||
tileGrid.getTileCoordCenter(tile.tileCoord),
|
||||
tileGrid.getResolution(tile.tileCoord[0]),
|
||||
tilePixelSize, tileGutter * pixelRatio
|
||||
]);
|
||||
}
|
||||
}, this);
|
||||
this.scheduleExpireCache(frameState, tileSource);
|
||||
|
||||
var texCoordMatrix = this.texCoordMatrix;
|
||||
const texCoordMatrix = this.texCoordMatrix;
|
||||
_ol_transform_.reset(texCoordMatrix);
|
||||
_ol_transform_.translate(texCoordMatrix,
|
||||
(Math.round(center[0] / tileResolution) * tileResolution - framebufferExtent[0]) /
|
||||
(Math.round(center[0] / tileResolution) * tileResolution - framebufferExtent[0]) /
|
||||
(framebufferExtent[2] - framebufferExtent[0]),
|
||||
(Math.round(center[1] / tileResolution) * tileResolution - framebufferExtent[1]) /
|
||||
(Math.round(center[1] / tileResolution) * tileResolution - framebufferExtent[1]) /
|
||||
(framebufferExtent[3] - framebufferExtent[1]));
|
||||
if (viewState.rotation !== 0) {
|
||||
_ol_transform_.rotate(texCoordMatrix, viewState.rotation);
|
||||
}
|
||||
_ol_transform_.scale(texCoordMatrix,
|
||||
frameState.size[0] * viewState.resolution /
|
||||
frameState.size[0] * viewState.resolution /
|
||||
(framebufferExtent[2] - framebufferExtent[0]),
|
||||
frameState.size[1] * viewState.resolution /
|
||||
frameState.size[1] * viewState.resolution /
|
||||
(framebufferExtent[3] - framebufferExtent[1]));
|
||||
_ol_transform_.translate(texCoordMatrix, -0.5, -0.5);
|
||||
|
||||
@@ -384,21 +384,21 @@ WebGLTileLayerRenderer.prototype.forEachLayerAtPixel = function(pixel, frameStat
|
||||
return undefined;
|
||||
}
|
||||
|
||||
var pixelOnMapScaled = [
|
||||
const pixelOnMapScaled = [
|
||||
pixel[0] / frameState.size[0],
|
||||
(frameState.size[1] - pixel[1]) / frameState.size[1]];
|
||||
|
||||
var pixelOnFrameBufferScaled = _ol_transform_.apply(
|
||||
this.texCoordMatrix, pixelOnMapScaled.slice());
|
||||
var pixelOnFrameBuffer = [
|
||||
const pixelOnFrameBufferScaled = _ol_transform_.apply(
|
||||
this.texCoordMatrix, pixelOnMapScaled.slice());
|
||||
const pixelOnFrameBuffer = [
|
||||
pixelOnFrameBufferScaled[0] * this.framebufferDimension,
|
||||
pixelOnFrameBufferScaled[1] * this.framebufferDimension];
|
||||
|
||||
var gl = this.mapRenderer.getContext().getGL();
|
||||
const gl = this.mapRenderer.getContext().getGL();
|
||||
gl.bindFramebuffer(gl.FRAMEBUFFER, this.framebuffer);
|
||||
var imageData = new Uint8Array(4);
|
||||
const imageData = new Uint8Array(4);
|
||||
gl.readPixels(pixelOnFrameBuffer[0], pixelOnFrameBuffer[1], 1, 1,
|
||||
gl.RGBA, gl.UNSIGNED_BYTE, imageData);
|
||||
gl.RGBA, gl.UNSIGNED_BYTE, imageData);
|
||||
|
||||
if (imageData[3] > 0) {
|
||||
return callback.call(thisArg, this.getLayer(), imageData);
|
||||
|
||||
@@ -18,7 +18,7 @@ import _ol_transform_ from '../../transform.js';
|
||||
* @param {ol.layer.Vector} vectorLayer Vector layer.
|
||||
* @api
|
||||
*/
|
||||
var WebGLVectorLayerRenderer = function(mapRenderer, vectorLayer) {
|
||||
const WebGLVectorLayerRenderer = function(mapRenderer, vectorLayer) {
|
||||
|
||||
WebGLLayerRenderer.call(this, mapRenderer, vectorLayer);
|
||||
|
||||
@@ -89,8 +89,8 @@ WebGLVectorLayerRenderer['handles'] = function(type, layer) {
|
||||
*/
|
||||
WebGLVectorLayerRenderer['create'] = function(mapRenderer, layer) {
|
||||
return new WebGLVectorLayerRenderer(
|
||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||
/** @type {ol.layer.Vector} */ (layer)
|
||||
/** @type {ol.renderer.webgl.Map} */ (mapRenderer),
|
||||
/** @type {ol.layer.Vector} */ (layer)
|
||||
);
|
||||
};
|
||||
|
||||
@@ -100,18 +100,18 @@ WebGLVectorLayerRenderer['create'] = function(mapRenderer, layer) {
|
||||
*/
|
||||
WebGLVectorLayerRenderer.prototype.composeFrame = function(frameState, layerState, context) {
|
||||
this.layerState_ = layerState;
|
||||
var viewState = frameState.viewState;
|
||||
var replayGroup = this.replayGroup_;
|
||||
var size = frameState.size;
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
var gl = this.mapRenderer.getGL();
|
||||
const viewState = frameState.viewState;
|
||||
const replayGroup = this.replayGroup_;
|
||||
const size = frameState.size;
|
||||
const pixelRatio = frameState.pixelRatio;
|
||||
const gl = this.mapRenderer.getGL();
|
||||
if (replayGroup && !replayGroup.isEmpty()) {
|
||||
gl.enable(gl.SCISSOR_TEST);
|
||||
gl.scissor(0, 0, size[0] * pixelRatio, size[1] * pixelRatio);
|
||||
replayGroup.replay(context,
|
||||
viewState.center, viewState.resolution, viewState.rotation,
|
||||
size, pixelRatio, layerState.opacity,
|
||||
layerState.managed ? frameState.skippedFeatureUids : {});
|
||||
viewState.center, viewState.resolution, viewState.rotation,
|
||||
size, pixelRatio, layerState.opacity,
|
||||
layerState.managed ? frameState.skippedFeatureUids : {});
|
||||
gl.disable(gl.SCISSOR_TEST);
|
||||
}
|
||||
|
||||
@@ -122,9 +122,9 @@ WebGLVectorLayerRenderer.prototype.composeFrame = function(frameState, layerStat
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLVectorLayerRenderer.prototype.disposeInternal = function() {
|
||||
var replayGroup = this.replayGroup_;
|
||||
const replayGroup = this.replayGroup_;
|
||||
if (replayGroup) {
|
||||
var context = this.mapRenderer.getContext();
|
||||
const context = this.mapRenderer.getContext();
|
||||
replayGroup.getDeleteResourcesFunction(context)();
|
||||
this.replayGroup_ = null;
|
||||
}
|
||||
@@ -139,27 +139,27 @@ WebGLVectorLayerRenderer.prototype.forEachFeatureAtCoordinate = function(coordin
|
||||
if (!this.replayGroup_ || !this.layerState_) {
|
||||
return undefined;
|
||||
} else {
|
||||
var context = this.mapRenderer.getContext();
|
||||
var viewState = frameState.viewState;
|
||||
var layer = this.getLayer();
|
||||
var layerState = this.layerState_;
|
||||
const context = this.mapRenderer.getContext();
|
||||
const viewState = frameState.viewState;
|
||||
const layer = this.getLayer();
|
||||
const layerState = this.layerState_;
|
||||
/** @type {Object.<string, boolean>} */
|
||||
var features = {};
|
||||
const features = {};
|
||||
return this.replayGroup_.forEachFeatureAtCoordinate(coordinate,
|
||||
context, viewState.center, viewState.resolution, viewState.rotation,
|
||||
frameState.size, frameState.pixelRatio, layerState.opacity,
|
||||
{},
|
||||
/**
|
||||
context, viewState.center, viewState.resolution, viewState.rotation,
|
||||
frameState.size, frameState.pixelRatio, layerState.opacity,
|
||||
{},
|
||||
/**
|
||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||
* @return {?} Callback result.
|
||||
*/
|
||||
function(feature) {
|
||||
var key = getUid(feature).toString();
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
return callback.call(thisArg, feature, layer);
|
||||
}
|
||||
});
|
||||
function(feature) {
|
||||
const key = getUid(feature).toString();
|
||||
if (!(key in features)) {
|
||||
features[key] = true;
|
||||
return callback.call(thisArg, feature, layer);
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
@@ -171,13 +171,13 @@ WebGLVectorLayerRenderer.prototype.hasFeatureAtCoordinate = function(coordinate,
|
||||
if (!this.replayGroup_ || !this.layerState_) {
|
||||
return false;
|
||||
} else {
|
||||
var context = this.mapRenderer.getContext();
|
||||
var viewState = frameState.viewState;
|
||||
var layerState = this.layerState_;
|
||||
const context = this.mapRenderer.getContext();
|
||||
const viewState = frameState.viewState;
|
||||
const layerState = this.layerState_;
|
||||
return this.replayGroup_.hasFeatureAtCoordinate(coordinate,
|
||||
context, viewState.center, viewState.resolution, viewState.rotation,
|
||||
frameState.size, frameState.pixelRatio, layerState.opacity,
|
||||
frameState.skippedFeatureUids);
|
||||
context, viewState.center, viewState.resolution, viewState.rotation,
|
||||
frameState.size, frameState.pixelRatio, layerState.opacity,
|
||||
frameState.skippedFeatureUids);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -186,9 +186,9 @@ WebGLVectorLayerRenderer.prototype.hasFeatureAtCoordinate = function(coordinate,
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLVectorLayerRenderer.prototype.forEachLayerAtPixel = function(pixel, frameState, callback, thisArg) {
|
||||
var coordinate = _ol_transform_.apply(
|
||||
frameState.pixelToCoordinateTransform, pixel.slice());
|
||||
var hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState);
|
||||
const coordinate = _ol_transform_.apply(
|
||||
frameState.pixelToCoordinateTransform, pixel.slice());
|
||||
const hasFeature = this.hasFeatureAtCoordinate(coordinate, frameState);
|
||||
|
||||
if (hasFeature) {
|
||||
return callback.call(thisArg, this.getLayer(), null);
|
||||
@@ -212,34 +212,34 @@ WebGLVectorLayerRenderer.prototype.handleStyleImageChange_ = function(event) {
|
||||
* @inheritDoc
|
||||
*/
|
||||
WebGLVectorLayerRenderer.prototype.prepareFrame = function(frameState, layerState, context) {
|
||||
var vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||
var vectorSource = vectorLayer.getSource();
|
||||
const vectorLayer = /** @type {ol.layer.Vector} */ (this.getLayer());
|
||||
const vectorSource = vectorLayer.getSource();
|
||||
|
||||
var animating = frameState.viewHints[ViewHint.ANIMATING];
|
||||
var interacting = frameState.viewHints[ViewHint.INTERACTING];
|
||||
var updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
|
||||
var updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
|
||||
const animating = frameState.viewHints[ViewHint.ANIMATING];
|
||||
const interacting = frameState.viewHints[ViewHint.INTERACTING];
|
||||
const updateWhileAnimating = vectorLayer.getUpdateWhileAnimating();
|
||||
const updateWhileInteracting = vectorLayer.getUpdateWhileInteracting();
|
||||
|
||||
if (!this.dirty_ && (!updateWhileAnimating && animating) ||
|
||||
(!updateWhileInteracting && interacting)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
var frameStateExtent = frameState.extent;
|
||||
var viewState = frameState.viewState;
|
||||
var projection = viewState.projection;
|
||||
var resolution = viewState.resolution;
|
||||
var pixelRatio = frameState.pixelRatio;
|
||||
var vectorLayerRevision = vectorLayer.getRevision();
|
||||
var vectorLayerRenderBuffer = vectorLayer.getRenderBuffer();
|
||||
var vectorLayerRenderOrder = vectorLayer.getRenderOrder();
|
||||
const frameStateExtent = frameState.extent;
|
||||
const viewState = frameState.viewState;
|
||||
const projection = viewState.projection;
|
||||
const resolution = viewState.resolution;
|
||||
const pixelRatio = frameState.pixelRatio;
|
||||
const vectorLayerRevision = vectorLayer.getRevision();
|
||||
const vectorLayerRenderBuffer = vectorLayer.getRenderBuffer();
|
||||
let vectorLayerRenderOrder = vectorLayer.getRenderOrder();
|
||||
|
||||
if (vectorLayerRenderOrder === undefined) {
|
||||
vectorLayerRenderOrder = _ol_renderer_vector_.defaultOrder;
|
||||
}
|
||||
|
||||
var extent = buffer(frameStateExtent,
|
||||
vectorLayerRenderBuffer * resolution);
|
||||
const extent = buffer(frameStateExtent,
|
||||
vectorLayerRenderBuffer * resolution);
|
||||
|
||||
if (!this.dirty_ &&
|
||||
this.renderedResolution_ == resolution &&
|
||||
@@ -251,22 +251,22 @@ WebGLVectorLayerRenderer.prototype.prepareFrame = function(frameState, layerStat
|
||||
|
||||
if (this.replayGroup_) {
|
||||
frameState.postRenderFunctions.push(
|
||||
this.replayGroup_.getDeleteResourcesFunction(context));
|
||||
this.replayGroup_.getDeleteResourcesFunction(context));
|
||||
}
|
||||
|
||||
this.dirty_ = false;
|
||||
|
||||
var replayGroup = new _ol_render_webgl_ReplayGroup_(
|
||||
_ol_renderer_vector_.getTolerance(resolution, pixelRatio),
|
||||
extent, vectorLayer.getRenderBuffer());
|
||||
const replayGroup = new _ol_render_webgl_ReplayGroup_(
|
||||
_ol_renderer_vector_.getTolerance(resolution, pixelRatio),
|
||||
extent, vectorLayer.getRenderBuffer());
|
||||
vectorSource.loadFeatures(extent, resolution, projection);
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
* @this {ol.renderer.webgl.VectorLayer}
|
||||
*/
|
||||
var renderFeature = function(feature) {
|
||||
var styles;
|
||||
var styleFunction = feature.getStyleFunction();
|
||||
const renderFeature = function(feature) {
|
||||
let styles;
|
||||
let styleFunction = feature.getStyleFunction();
|
||||
if (styleFunction) {
|
||||
styles = styleFunction.call(feature, resolution);
|
||||
} else {
|
||||
@@ -276,21 +276,21 @@ WebGLVectorLayerRenderer.prototype.prepareFrame = function(frameState, layerStat
|
||||
}
|
||||
}
|
||||
if (styles) {
|
||||
var dirty = this.renderFeature(
|
||||
feature, resolution, pixelRatio, styles, replayGroup);
|
||||
const dirty = this.renderFeature(
|
||||
feature, resolution, pixelRatio, styles, replayGroup);
|
||||
this.dirty_ = this.dirty_ || dirty;
|
||||
}
|
||||
};
|
||||
if (vectorLayerRenderOrder) {
|
||||
/** @type {Array.<ol.Feature>} */
|
||||
var features = [];
|
||||
const features = [];
|
||||
vectorSource.forEachFeatureInExtent(extent,
|
||||
/**
|
||||
/**
|
||||
* @param {ol.Feature} feature Feature.
|
||||
*/
|
||||
function(feature) {
|
||||
features.push(feature);
|
||||
}, this);
|
||||
function(feature) {
|
||||
features.push(feature);
|
||||
}, this);
|
||||
features.sort(vectorLayerRenderOrder);
|
||||
features.forEach(renderFeature.bind(this));
|
||||
} else {
|
||||
@@ -321,19 +321,19 @@ WebGLVectorLayerRenderer.prototype.renderFeature = function(feature, resolution,
|
||||
if (!styles) {
|
||||
return false;
|
||||
}
|
||||
var loading = false;
|
||||
let loading = false;
|
||||
if (Array.isArray(styles)) {
|
||||
for (var i = styles.length - 1, ii = 0; i >= ii; --i) {
|
||||
for (let i = styles.length - 1, ii = 0; i >= ii; --i) {
|
||||
loading = _ol_renderer_vector_.renderFeature(
|
||||
replayGroup, feature, styles[i],
|
||||
_ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio),
|
||||
this.handleStyleImageChange_, this) || loading;
|
||||
replayGroup, feature, styles[i],
|
||||
_ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio),
|
||||
this.handleStyleImageChange_, this) || loading;
|
||||
}
|
||||
} else {
|
||||
loading = _ol_renderer_vector_.renderFeature(
|
||||
replayGroup, feature, styles,
|
||||
_ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio),
|
||||
this.handleStyleImageChange_, this) || loading;
|
||||
replayGroup, feature, styles,
|
||||
_ol_renderer_vector_.getSquaredTolerance(resolution, pixelRatio),
|
||||
this.handleStyleImageChange_, this) || loading;
|
||||
}
|
||||
return loading;
|
||||
};
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {DEBUG_WEBGL} from '../../index.js';
|
||||
import _ol_webgl_Fragment_ from '../../webgl/Fragment.js';
|
||||
import _ol_webgl_Vertex_ from '../../webgl/Vertex.js';
|
||||
var _ol_renderer_webgl_defaultmapshader_ = {};
|
||||
const _ol_renderer_webgl_defaultmapshader_ = {};
|
||||
|
||||
_ol_renderer_webgl_defaultmapshader_.fragment = new _ol_webgl_Fragment_(DEBUG_WEBGL ?
|
||||
'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform float u_opacity;\nuniform sampler2D u_texture;\n\nvoid main(void) {\n vec4 texColor = texture2D(u_texture, v_texCoord);\n gl_FragColor.rgb = texColor.rgb;\n gl_FragColor.a = texColor.a * u_opacity;\n}\n' :
|
||||
|
||||
@@ -10,43 +10,43 @@ import {DEBUG_WEBGL} from '../../../index.js';
|
||||
* @param {WebGLProgram} program Program.
|
||||
* @struct
|
||||
*/
|
||||
var _ol_renderer_webgl_defaultmapshader_Locations_ = function(gl, program) {
|
||||
const _ol_renderer_webgl_defaultmapshader_Locations_ = function(gl, program) {
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_texCoordMatrix = gl.getUniformLocation(
|
||||
program, DEBUG_WEBGL ? 'u_texCoordMatrix' : 'd');
|
||||
program, DEBUG_WEBGL ? 'u_texCoordMatrix' : 'd');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_projectionMatrix = gl.getUniformLocation(
|
||||
program, DEBUG_WEBGL ? 'u_projectionMatrix' : 'e');
|
||||
program, DEBUG_WEBGL ? 'u_projectionMatrix' : 'e');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_opacity = gl.getUniformLocation(
|
||||
program, DEBUG_WEBGL ? 'u_opacity' : 'f');
|
||||
program, DEBUG_WEBGL ? 'u_opacity' : 'f');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_texture = gl.getUniformLocation(
|
||||
program, DEBUG_WEBGL ? 'u_texture' : 'g');
|
||||
program, DEBUG_WEBGL ? 'u_texture' : 'g');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_position = gl.getAttribLocation(
|
||||
program, DEBUG_WEBGL ? 'a_position' : 'b');
|
||||
program, DEBUG_WEBGL ? 'a_position' : 'b');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_texCoord = gl.getAttribLocation(
|
||||
program, DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
||||
program, DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
||||
};
|
||||
|
||||
export default _ol_renderer_webgl_defaultmapshader_Locations_;
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
import {DEBUG_WEBGL} from '../../index.js';
|
||||
import _ol_webgl_Fragment_ from '../../webgl/Fragment.js';
|
||||
import _ol_webgl_Vertex_ from '../../webgl/Vertex.js';
|
||||
var _ol_renderer_webgl_tilelayershader_ = {};
|
||||
const _ol_renderer_webgl_tilelayershader_ = {};
|
||||
|
||||
_ol_renderer_webgl_tilelayershader_.fragment = new _ol_webgl_Fragment_(DEBUG_WEBGL ?
|
||||
'precision mediump float;\nvarying vec2 v_texCoord;\n\n\nuniform sampler2D u_texture;\n\nvoid main(void) {\n gl_FragColor = texture2D(u_texture, v_texCoord);\n}\n' :
|
||||
|
||||
@@ -10,31 +10,31 @@ import {DEBUG_WEBGL} from '../../../index.js';
|
||||
* @param {WebGLProgram} program Program.
|
||||
* @struct
|
||||
*/
|
||||
var _ol_renderer_webgl_tilelayershader_Locations_ = function(gl, program) {
|
||||
const _ol_renderer_webgl_tilelayershader_Locations_ = function(gl, program) {
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_tileOffset = gl.getUniformLocation(
|
||||
program, DEBUG_WEBGL ? 'u_tileOffset' : 'd');
|
||||
program, DEBUG_WEBGL ? 'u_tileOffset' : 'd');
|
||||
|
||||
/**
|
||||
* @type {WebGLUniformLocation}
|
||||
*/
|
||||
this.u_texture = gl.getUniformLocation(
|
||||
program, DEBUG_WEBGL ? 'u_texture' : 'e');
|
||||
program, DEBUG_WEBGL ? 'u_texture' : 'e');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_position = gl.getAttribLocation(
|
||||
program, DEBUG_WEBGL ? 'a_position' : 'b');
|
||||
program, DEBUG_WEBGL ? 'a_position' : 'b');
|
||||
|
||||
/**
|
||||
* @type {number}
|
||||
*/
|
||||
this.a_texCoord = gl.getAttribLocation(
|
||||
program, DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
||||
program, DEBUG_WEBGL ? 'a_texCoord' : 'c');
|
||||
};
|
||||
|
||||
export default _ol_renderer_webgl_tilelayershader_Locations_;
|
||||
|
||||
Reference in New Issue
Block a user