Merge pull request #7805 from fredj/unstatic-private
Remove private static members from constructors
This commit is contained in:
@@ -36,16 +36,15 @@ inherits(GeometryCollection, Geometry);
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* @param {Array.<ol.geom.Geometry>} geometries Geometries.
|
* @param {Array.<ol.geom.Geometry>} geometries Geometries.
|
||||||
* @private
|
|
||||||
* @return {Array.<ol.geom.Geometry>} Cloned geometries.
|
* @return {Array.<ol.geom.Geometry>} Cloned geometries.
|
||||||
*/
|
*/
|
||||||
GeometryCollection.cloneGeometries_ = function(geometries) {
|
function cloneGeometries(geometries) {
|
||||||
const clonedGeometries = [];
|
const clonedGeometries = [];
|
||||||
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
for (let i = 0, ii = geometries.length; i < ii; ++i) {
|
||||||
clonedGeometries.push(geometries[i].clone());
|
clonedGeometries.push(geometries[i].clone());
|
||||||
}
|
}
|
||||||
return clonedGeometries;
|
return clonedGeometries;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -140,7 +139,7 @@ GeometryCollection.prototype.computeExtent = function(extent) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
GeometryCollection.prototype.getGeometries = function() {
|
GeometryCollection.prototype.getGeometries = function() {
|
||||||
return GeometryCollection.cloneGeometries_(this.geometries_);
|
return cloneGeometries(this.geometries_);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
@@ -262,8 +261,7 @@ GeometryCollection.prototype.scale = function(sx, opt_sy, opt_anchor) {
|
|||||||
* @api
|
* @api
|
||||||
*/
|
*/
|
||||||
GeometryCollection.prototype.setGeometries = function(geometries) {
|
GeometryCollection.prototype.setGeometries = function(geometries) {
|
||||||
this.setGeometriesArray(
|
this.setGeometriesArray(cloneGeometries(geometries));
|
||||||
GeometryCollection.cloneGeometries_(geometries));
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,22 @@ import CanvasTextReplay from '../canvas/TextReplay.js';
|
|||||||
import _ol_render_replay_ from '../replay.js';
|
import _ol_render_replay_ from '../replay.js';
|
||||||
import _ol_transform_ from '../../transform.js';
|
import _ol_transform_ from '../../transform.js';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object.<ol.render.ReplayType,
|
||||||
|
* function(new: ol.render.canvas.Replay, number, ol.Extent,
|
||||||
|
* number, number, boolean, Array.<ol.DeclutterGroup>)>}
|
||||||
|
*/
|
||||||
|
const BATCH_CONSTRUCTORS = {
|
||||||
|
'Circle': CanvasPolygonReplay,
|
||||||
|
'Default': CanvasReplay,
|
||||||
|
'Image': CanvasImageReplay,
|
||||||
|
'LineString': CanvasLineStringReplay,
|
||||||
|
'Polygon': CanvasPolygonReplay,
|
||||||
|
'Text': CanvasTextReplay
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.ReplayGroup}
|
* @extends {ol.render.ReplayGroup}
|
||||||
@@ -109,9 +125,8 @@ inherits(CanvasReplayGroup, ReplayGroup);
|
|||||||
* This cache is used for storing calculated pixel circles for increasing performance.
|
* This cache is used for storing calculated pixel circles for increasing performance.
|
||||||
* It is a static property to allow each Replaygroup to access it.
|
* It is a static property to allow each Replaygroup to access it.
|
||||||
* @type {Object.<number, Array.<Array.<(boolean|undefined)>>>}
|
* @type {Object.<number, Array.<Array.<(boolean|undefined)>>>}
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
CanvasReplayGroup.circleArrayCache_ = {
|
const circleArrayCache = {
|
||||||
0: [[true]]
|
0: [[true]]
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -122,9 +137,8 @@ CanvasReplayGroup.circleArrayCache_ = {
|
|||||||
* @param {Array.<Array.<(boolean|undefined)>>} array The array that will be altered.
|
* @param {Array.<Array.<(boolean|undefined)>>} array The array that will be altered.
|
||||||
* @param {number} x X coordinate.
|
* @param {number} x X coordinate.
|
||||||
* @param {number} y Y coordinate.
|
* @param {number} y Y coordinate.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_ = function(array, x, y) {
|
function fillCircleArrayRowToMiddle(array, x, y) {
|
||||||
let i;
|
let i;
|
||||||
const radius = Math.floor(array.length / 2);
|
const radius = Math.floor(array.length / 2);
|
||||||
if (x >= radius) {
|
if (x >= radius) {
|
||||||
@@ -136,7 +150,7 @@ CanvasReplayGroup.fillCircleArrayRowToMiddle_ = function(array, x, y) {
|
|||||||
array[i][y] = true;
|
array[i][y] = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -146,11 +160,10 @@ CanvasReplayGroup.fillCircleArrayRowToMiddle_ = function(array, x, y) {
|
|||||||
* A cache is used to increase performance.
|
* A cache is used to increase performance.
|
||||||
* @param {number} radius Radius.
|
* @param {number} radius Radius.
|
||||||
* @returns {Array.<Array.<(boolean|undefined)>>} An array with marked circle points.
|
* @returns {Array.<Array.<(boolean|undefined)>>} An array with marked circle points.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
CanvasReplayGroup.getCircleArray_ = function(radius) {
|
export function getCircleArray(radius) {
|
||||||
if (CanvasReplayGroup.circleArrayCache_[radius] !== undefined) {
|
if (circleArrayCache[radius] !== undefined) {
|
||||||
return CanvasReplayGroup.circleArrayCache_[radius];
|
return circleArrayCache[radius];
|
||||||
}
|
}
|
||||||
|
|
||||||
const arraySize = radius * 2 + 1;
|
const arraySize = radius * 2 + 1;
|
||||||
@@ -164,14 +177,14 @@ CanvasReplayGroup.getCircleArray_ = function(radius) {
|
|||||||
let error = 0;
|
let error = 0;
|
||||||
|
|
||||||
while (x >= y) {
|
while (x >= y) {
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + x, radius + y);
|
fillCircleArrayRowToMiddle(arr, radius + x, radius + y);
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + y, radius + x);
|
fillCircleArrayRowToMiddle(arr, radius + y, radius + x);
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - y, radius + x);
|
fillCircleArrayRowToMiddle(arr, radius - y, radius + x);
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - x, radius + y);
|
fillCircleArrayRowToMiddle(arr, radius - x, radius + y);
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - x, radius - y);
|
fillCircleArrayRowToMiddle(arr, radius - x, radius - y);
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius - y, radius - x);
|
fillCircleArrayRowToMiddle(arr, radius - y, radius - x);
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + y, radius - x);
|
fillCircleArrayRowToMiddle(arr, radius + y, radius - x);
|
||||||
CanvasReplayGroup.fillCircleArrayRowToMiddle_(arr, radius + x, radius - y);
|
fillCircleArrayRowToMiddle(arr, radius + x, radius - y);
|
||||||
|
|
||||||
y++;
|
y++;
|
||||||
error += 1 + 2 * y;
|
error += 1 + 2 * y;
|
||||||
@@ -181,9 +194,9 @@ CanvasReplayGroup.getCircleArray_ = function(radius) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CanvasReplayGroup.circleArrayCache_[radius] = arr;
|
circleArrayCache[radius] = arr;
|
||||||
return arr;
|
return arr;
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -312,7 +325,7 @@ CanvasReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
|||||||
buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent);
|
buffer(hitExtent, resolution * (this.renderBuffer_ + hitTolerance), hitExtent);
|
||||||
}
|
}
|
||||||
|
|
||||||
const mask = CanvasReplayGroup.getCircleArray_(hitTolerance);
|
const mask = getCircleArray(hitTolerance);
|
||||||
let declutteredFeatures;
|
let declutteredFeatures;
|
||||||
if (this.declutterTree_) {
|
if (this.declutterTree_) {
|
||||||
declutteredFeatures = this.declutterTree_.all().map(function(entry) {
|
declutteredFeatures = this.declutterTree_.all().map(function(entry) {
|
||||||
@@ -412,7 +425,7 @@ CanvasReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
|||||||
}
|
}
|
||||||
let replay = replays[replayType];
|
let replay = replays[replayType];
|
||||||
if (replay === undefined) {
|
if (replay === undefined) {
|
||||||
const Constructor = CanvasReplayGroup.BATCH_CONSTRUCTORS_[replayType];
|
const Constructor = BATCH_CONSTRUCTORS[replayType];
|
||||||
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
replay = new Constructor(this.tolerance_, this.maxExtent_,
|
||||||
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_);
|
this.resolution_, this.pixelRatio_, this.overlaps_, this.declutterTree_);
|
||||||
replays[replayType] = replay;
|
replays[replayType] = replay;
|
||||||
@@ -487,20 +500,4 @@ CanvasReplayGroup.prototype.replay = function(context,
|
|||||||
context.restore();
|
context.restore();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @private
|
|
||||||
* @type {Object.<ol.render.ReplayType,
|
|
||||||
* function(new: ol.render.canvas.Replay, number, ol.Extent,
|
|
||||||
* number, number, boolean, Array.<ol.DeclutterGroup>)>}
|
|
||||||
*/
|
|
||||||
CanvasReplayGroup.BATCH_CONSTRUCTORS_ = {
|
|
||||||
'Circle': CanvasPolygonReplay,
|
|
||||||
'Default': CanvasReplay,
|
|
||||||
'Image': CanvasImageReplay,
|
|
||||||
'LineString': CanvasLineStringReplay,
|
|
||||||
'Polygon': CanvasPolygonReplay,
|
|
||||||
'Text': CanvasTextReplay
|
|
||||||
};
|
|
||||||
export default CanvasReplayGroup;
|
export default CanvasReplayGroup;
|
||||||
|
|||||||
@@ -16,6 +16,23 @@ import Locations from '../webgl/linestringreplay/defaultshader/Locations.js';
|
|||||||
import _ol_webgl_ from '../../webgl.js';
|
import _ol_webgl_ from '../../webgl.js';
|
||||||
import WebGLBuffer from '../../webgl/Buffer.js';
|
import WebGLBuffer from '../../webgl/Buffer.js';
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @enum {number}
|
||||||
|
*/
|
||||||
|
const Instruction = {
|
||||||
|
ROUND: 2,
|
||||||
|
BEGIN_LINE: 3,
|
||||||
|
END_LINE: 5,
|
||||||
|
BEGIN_LINE_CAP: 7,
|
||||||
|
END_LINE_CAP: 11,
|
||||||
|
BEVEL_FIRST: 13,
|
||||||
|
BEVEL_SECOND: 17,
|
||||||
|
MITER_BOTTOM: 19,
|
||||||
|
MITER_TOP: 23
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.webgl.Replay}
|
* @extends {ol.render.webgl.Replay}
|
||||||
@@ -85,7 +102,7 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
let numVertices = this.vertices.length;
|
let numVertices = this.vertices.length;
|
||||||
let numIndices = this.indices.length;
|
let numIndices = this.indices.length;
|
||||||
//To save a vertex, the direction of a point is a product of the sign (1 or -1), a prime from
|
//To save a vertex, the direction of a point is a product of the sign (1 or -1), a prime from
|
||||||
//ol.render.webgl.LineStringReplay.Instruction_, and a rounding factor (1 or 2). If the product is even,
|
//Instruction, and a rounding factor (1 or 2). If the product is even,
|
||||||
//we round it. If it is odd, we don't.
|
//we round it. If it is odd, we don't.
|
||||||
const lineJoin = this.state_.lineJoin === 'bevel' ? 0 :
|
const lineJoin = this.state_.lineJoin === 'bevel' ? 0 :
|
||||||
this.state_.lineJoin === 'miter' ? 1 : 2;
|
this.state_.lineJoin === 'miter' ? 1 : 2;
|
||||||
@@ -121,10 +138,10 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
|
|
||||||
if (lineCap) {
|
if (lineCap) {
|
||||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||||
lastSign * WebGLLineStringReplay.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices);
|
lastSign * Instruction.BEGIN_LINE_CAP * lineCap, numVertices);
|
||||||
|
|
||||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||||
-lastSign * WebGLLineStringReplay.Instruction_.BEGIN_LINE_CAP * lineCap, numVertices);
|
-lastSign * Instruction.BEGIN_LINE_CAP * lineCap, numVertices);
|
||||||
|
|
||||||
this.indices[numIndices++] = n + 2;
|
this.indices[numIndices++] = n + 2;
|
||||||
this.indices[numIndices++] = n;
|
this.indices[numIndices++] = n;
|
||||||
@@ -137,10 +154,10 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
}
|
}
|
||||||
|
|
||||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||||
lastSign * WebGLLineStringReplay.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices);
|
lastSign * Instruction.BEGIN_LINE * (lineCap || 1), numVertices);
|
||||||
|
|
||||||
numVertices = this.addVertices_([0, 0], p1, p2,
|
numVertices = this.addVertices_([0, 0], p1, p2,
|
||||||
-lastSign * WebGLLineStringReplay.Instruction_.BEGIN_LINE * (lineCap || 1), numVertices);
|
-lastSign * Instruction.BEGIN_LINE * (lineCap || 1), numVertices);
|
||||||
|
|
||||||
lastIndex = numVertices / 7 - 1;
|
lastIndex = numVertices / 7 - 1;
|
||||||
|
|
||||||
@@ -156,10 +173,10 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
p0 = p0 || [0, 0];
|
p0 = p0 || [0, 0];
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||||
lastSign * WebGLLineStringReplay.Instruction_.END_LINE * (lineCap || 1), numVertices);
|
lastSign * Instruction.END_LINE * (lineCap || 1), numVertices);
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||||
-lastSign * WebGLLineStringReplay.Instruction_.END_LINE * (lineCap || 1), numVertices);
|
-lastSign * Instruction.END_LINE * (lineCap || 1), numVertices);
|
||||||
|
|
||||||
this.indices[numIndices++] = n;
|
this.indices[numIndices++] = n;
|
||||||
this.indices[numIndices++] = lastIndex - 1;
|
this.indices[numIndices++] = lastIndex - 1;
|
||||||
@@ -171,10 +188,10 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
|
|
||||||
if (lineCap) {
|
if (lineCap) {
|
||||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||||
lastSign * WebGLLineStringReplay.Instruction_.END_LINE_CAP * lineCap, numVertices);
|
lastSign * Instruction.END_LINE_CAP * lineCap, numVertices);
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, [0, 0],
|
numVertices = this.addVertices_(p0, p1, [0, 0],
|
||||||
-lastSign * WebGLLineStringReplay.Instruction_.END_LINE_CAP * lineCap, numVertices);
|
-lastSign * Instruction.END_LINE_CAP * lineCap, numVertices);
|
||||||
|
|
||||||
this.indices[numIndices++] = n + 2;
|
this.indices[numIndices++] = n + 2;
|
||||||
this.indices[numIndices++] = n;
|
this.indices[numIndices++] = n;
|
||||||
@@ -197,13 +214,13 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
? -1 : 1;
|
? -1 : 1;
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
sign * WebGLLineStringReplay.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
sign * Instruction.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
sign * WebGLLineStringReplay.Instruction_.BEVEL_SECOND * (lineJoin || 1), numVertices);
|
sign * Instruction.BEVEL_SECOND * (lineJoin || 1), numVertices);
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
-sign * WebGLLineStringReplay.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
-sign * Instruction.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
||||||
|
|
||||||
if (i > offset) {
|
if (i > offset) {
|
||||||
this.indices[numIndices++] = n;
|
this.indices[numIndices++] = n;
|
||||||
@@ -225,7 +242,7 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
//Add miter
|
//Add miter
|
||||||
if (lineJoin) {
|
if (lineJoin) {
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
sign * WebGLLineStringReplay.Instruction_.MITER_TOP * lineJoin, numVertices);
|
sign * Instruction.MITER_TOP * lineJoin, numVertices);
|
||||||
|
|
||||||
this.indices[numIndices++] = n + 1;
|
this.indices[numIndices++] = n + 1;
|
||||||
this.indices[numIndices++] = n + 3;
|
this.indices[numIndices++] = n + 3;
|
||||||
@@ -239,10 +256,10 @@ WebGLLineStringReplay.prototype.drawCoordinates_ = function(flatCoordinates, off
|
|||||||
? 1 : -1;
|
? 1 : -1;
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
sign * WebGLLineStringReplay.Instruction_.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
sign * Instruction.BEVEL_FIRST * (lineJoin || 1), numVertices);
|
||||||
|
|
||||||
numVertices = this.addVertices_(p0, p1, p2,
|
numVertices = this.addVertices_(p0, p1, p2,
|
||||||
-sign * WebGLLineStringReplay.Instruction_.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
-sign * Instruction.MITER_BOTTOM * (lineJoin || 1), numVertices);
|
||||||
|
|
||||||
this.indices[numIndices++] = n;
|
this.indices[numIndices++] = n;
|
||||||
this.indices[numIndices++] = lastIndex - 1;
|
this.indices[numIndices++] = lastIndex - 1;
|
||||||
@@ -664,19 +681,4 @@ WebGLLineStringReplay.prototype.setFillStrokeStyle = function(fillStyle, strokeS
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @enum {number}
|
|
||||||
* @private
|
|
||||||
*/
|
|
||||||
WebGLLineStringReplay.Instruction_ = {
|
|
||||||
ROUND: 2,
|
|
||||||
BEGIN_LINE: 3,
|
|
||||||
END_LINE: 5,
|
|
||||||
BEGIN_LINE_CAP: 7,
|
|
||||||
END_LINE_CAP: 11,
|
|
||||||
BEVEL_FIRST: 13,
|
|
||||||
BEVEL_SECOND: 17,
|
|
||||||
MITER_BOTTOM: 19,
|
|
||||||
MITER_TOP: 23
|
|
||||||
};
|
|
||||||
export default WebGLLineStringReplay;
|
export default WebGLLineStringReplay;
|
||||||
|
|||||||
@@ -13,6 +13,25 @@ import WebGLLineStringReplay from '../webgl/LineStringReplay.js';
|
|||||||
import WebGLPolygonReplay from '../webgl/PolygonReplay.js';
|
import WebGLPolygonReplay from '../webgl/PolygonReplay.js';
|
||||||
import WebGLTextReplay from '../webgl/TextReplay.js';
|
import WebGLTextReplay from '../webgl/TextReplay.js';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Array.<number>}
|
||||||
|
*/
|
||||||
|
const HIT_DETECTION_SIZE = [1, 1];
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @type {Object.<ol.render.ReplayType,
|
||||||
|
* function(new: ol.render.webgl.Replay, number,
|
||||||
|
* ol.Extent)>}
|
||||||
|
*/
|
||||||
|
const BATCH_CONSTRUCTORS = {
|
||||||
|
'Circle': WebGLCircleReplay,
|
||||||
|
'Image': WebGLImageReplay,
|
||||||
|
'LineString': WebGLLineStringReplay,
|
||||||
|
'Polygon': WebGLPolygonReplay,
|
||||||
|
'Text': WebGLTextReplay
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @constructor
|
* @constructor
|
||||||
* @extends {ol.render.ReplayGroup}
|
* @extends {ol.render.ReplayGroup}
|
||||||
@@ -115,7 +134,7 @@ WebGLReplayGroup.prototype.getReplay = function(zIndex, replayType) {
|
|||||||
/**
|
/**
|
||||||
* @type {Function}
|
* @type {Function}
|
||||||
*/
|
*/
|
||||||
const Constructor = WebGLReplayGroup.BATCH_CONSTRUCTORS_[replayType];
|
const Constructor = BATCH_CONSTRUCTORS[replayType];
|
||||||
replay = new Constructor(this.tolerance_, this.maxExtent_);
|
replay = new Constructor(this.tolerance_, this.maxExtent_);
|
||||||
replays[replayType] = replay;
|
replays[replayType] = replay;
|
||||||
}
|
}
|
||||||
@@ -246,12 +265,12 @@ WebGLReplayGroup.prototype.forEachFeatureAtCoordinate = function(
|
|||||||
}
|
}
|
||||||
|
|
||||||
return this.replayHitDetection_(context,
|
return this.replayHitDetection_(context,
|
||||||
coordinate, resolution, rotation, WebGLReplayGroup.HIT_DETECTION_SIZE_,
|
coordinate, resolution, rotation, HIT_DETECTION_SIZE,
|
||||||
pixelRatio, opacity, skippedFeaturesHash,
|
pixelRatio, opacity, skippedFeaturesHash,
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
* @return {?} Callback result.
|
* @return {?} Callback result.
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
const imageData = new Uint8Array(4);
|
const imageData = new Uint8Array(4);
|
||||||
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
|
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
|
||||||
@@ -287,12 +306,12 @@ WebGLReplayGroup.prototype.hasFeatureAtCoordinate = function(
|
|||||||
gl.FRAMEBUFFER, context.getHitDetectionFramebuffer());
|
gl.FRAMEBUFFER, context.getHitDetectionFramebuffer());
|
||||||
|
|
||||||
const hasFeature = this.replayHitDetection_(context,
|
const hasFeature = this.replayHitDetection_(context,
|
||||||
coordinate, resolution, rotation, WebGLReplayGroup.HIT_DETECTION_SIZE_,
|
coordinate, resolution, rotation, HIT_DETECTION_SIZE,
|
||||||
pixelRatio, opacity, skippedFeaturesHash,
|
pixelRatio, opacity, skippedFeaturesHash,
|
||||||
/**
|
/**
|
||||||
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
* @param {ol.Feature|ol.render.Feature} feature Feature.
|
||||||
* @return {boolean} Is there a feature?
|
* @return {boolean} Is there a feature?
|
||||||
*/
|
*/
|
||||||
function(feature) {
|
function(feature) {
|
||||||
const imageData = new Uint8Array(4);
|
const imageData = new Uint8Array(4);
|
||||||
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
|
gl.readPixels(0, 0, 1, 1, gl.RGBA, gl.UNSIGNED_BYTE, imageData);
|
||||||
@@ -302,25 +321,4 @@ WebGLReplayGroup.prototype.hasFeatureAtCoordinate = function(
|
|||||||
return hasFeature !== undefined;
|
return hasFeature !== undefined;
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @private
|
|
||||||
* @type {Array.<number>}
|
|
||||||
*/
|
|
||||||
WebGLReplayGroup.HIT_DETECTION_SIZE_ = [1, 1];
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @const
|
|
||||||
* @private
|
|
||||||
* @type {Object.<ol.render.ReplayType,
|
|
||||||
* function(new: ol.render.webgl.Replay, number,
|
|
||||||
* ol.Extent)>}
|
|
||||||
*/
|
|
||||||
WebGLReplayGroup.BATCH_CONSTRUCTORS_ = {
|
|
||||||
'Circle': WebGLCircleReplay,
|
|
||||||
'Image': WebGLImageReplay,
|
|
||||||
'LineString': WebGLLineStringReplay,
|
|
||||||
'Polygon': WebGLPolygonReplay,
|
|
||||||
'Text': WebGLTextReplay
|
|
||||||
};
|
|
||||||
export default WebGLReplayGroup;
|
export default WebGLReplayGroup;
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ const MapRenderer = function(container, map) {
|
|||||||
|
|
||||||
Disposable.call(this);
|
Disposable.call(this);
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @private
|
* @private
|
||||||
* @type {ol.PluggableMap}
|
* @type {ol.PluggableMap}
|
||||||
@@ -81,11 +80,10 @@ MapRenderer.prototype.removeLayerRenderers = function() {
|
|||||||
/**
|
/**
|
||||||
* @param {ol.PluggableMap} map Map.
|
* @param {ol.PluggableMap} map Map.
|
||||||
* @param {olx.FrameState} frameState Frame state.
|
* @param {olx.FrameState} frameState Frame state.
|
||||||
* @private
|
|
||||||
*/
|
*/
|
||||||
MapRenderer.expireIconCache_ = function(map, frameState) {
|
function expireIconCache(map, frameState) {
|
||||||
iconImageCache.expire();
|
iconImageCache.expire();
|
||||||
};
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -314,9 +312,7 @@ MapRenderer.prototype.removeUnusedLayerRenderers_ = function(map, frameState) {
|
|||||||
* @protected
|
* @protected
|
||||||
*/
|
*/
|
||||||
MapRenderer.prototype.scheduleExpireIconCache = function(frameState) {
|
MapRenderer.prototype.scheduleExpireIconCache = function(frameState) {
|
||||||
frameState.postRenderFunctions.push(
|
frameState.postRenderFunctions.push(/** @type {ol.PostRenderFunction} */ (expireIconCache));
|
||||||
/** @type {ol.PostRenderFunction} */ (MapRenderer.expireIconCache_)
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
import CanvasReplayGroup from '../../../../../src/ol/render/canvas/ReplayGroup.js';
|
import {getCircleArray} from '../../../../../src/ol/render/canvas/ReplayGroup.js';
|
||||||
|
|
||||||
|
|
||||||
describe('ol.render.canvas.ReplayGroup', function() {
|
describe('ol.render.canvas.ReplayGroup', function() {
|
||||||
@@ -8,7 +8,7 @@ describe('ol.render.canvas.ReplayGroup', function() {
|
|||||||
const radius = 10;
|
const radius = 10;
|
||||||
const minRadiusSq = Math.pow(radius - Math.SQRT2, 2);
|
const minRadiusSq = Math.pow(radius - Math.SQRT2, 2);
|
||||||
const maxRadiusSq = Math.pow(radius + Math.SQRT2, 2);
|
const maxRadiusSq = Math.pow(radius + Math.SQRT2, 2);
|
||||||
const circleArray = CanvasReplayGroup.getCircleArray_(radius);
|
const circleArray = getCircleArray(radius);
|
||||||
const size = radius * 2 + 1;
|
const size = radius * 2 + 1;
|
||||||
expect(circleArray.length).to.be(size);
|
expect(circleArray.length).to.be(size);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user