More clean-ups in the canvas replay code

This commit is contained in:
Éric Lemoine
2014-12-05 12:29:53 +01:00
parent 4c2a0d2053
commit 9421bbd362

View File

@@ -1854,27 +1854,8 @@ ol.render.canvas.ReplayGroup = function(tolerance, maxExtent, resolution) {
}; };
/**
* @param {CanvasRenderingContext2D} context Context.
* @param {ol.Extent} extent Extent.
* @param {number} pixelRatio Pixel ratio.
* @param {goog.vec.Mat4.Number} transform Transform.
* @param {number} viewRotation View rotation.
* @param {Object} skippedFeaturesHash Ids of features to skip
*/
ol.render.canvas.ReplayGroup.prototype.replay = function(context, extent,
pixelRatio, transform, viewRotation, skippedFeaturesHash) {
/** @type {Array.<number>} */
var zs = goog.array.map(goog.object.getKeys(this.replaysByZIndex_), Number);
goog.array.sort(zs);
this.replay_(zs, context, extent, pixelRatio, transform,
viewRotation, skippedFeaturesHash);
};
/** /**
* @private * @private
* @param {Array.<number>} zs Z-indices array.
* @param {CanvasRenderingContext2D} context Context. * @param {CanvasRenderingContext2D} context Context.
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {goog.vec.Mat4.Number} transform Transform. * @param {goog.vec.Mat4.Number} transform Transform.
@@ -1886,8 +1867,12 @@ ol.render.canvas.ReplayGroup.prototype.replay = function(context, extent,
* @template T * @template T
*/ */
ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function( ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
zs, context, extent, transform, viewRotation, skippedFeaturesHash, context, extent, transform, viewRotation, skippedFeaturesHash,
geometryCallback) { geometryCallback) {
/** @type {Array.<number>} */
var zs = goog.array.map(goog.object.getKeys(this.replaysByZIndex_), Number);
goog.array.sort(zs, function(a, b) { return b - a; });
var i, ii, j, replays, replay, result; var i, ii, j, replays, replay, result;
for (i = 0, ii = zs.length; i < ii; ++i) { for (i = 0, ii = zs.length; i < ii; ++i) {
replays = this.replaysByZIndex_[zs[i].toString()]; replays = this.replaysByZIndex_[zs[i].toString()];
@@ -1908,8 +1893,6 @@ ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
/** /**
* @private
* @param {Array.<number>} zs Z-indices array.
* @param {CanvasRenderingContext2D} context Context. * @param {CanvasRenderingContext2D} context Context.
* @param {ol.Extent} extent Extent. * @param {ol.Extent} extent Extent.
* @param {number} pixelRatio Pixel ratio. * @param {number} pixelRatio Pixel ratio.
@@ -1917,9 +1900,12 @@ ol.render.canvas.ReplayGroup.prototype.replayHitDetection_ = function(
* @param {number} viewRotation View rotation. * @param {number} viewRotation View rotation.
* @param {Object} skippedFeaturesHash Ids of features to skip * @param {Object} skippedFeaturesHash Ids of features to skip
*/ */
ol.render.canvas.ReplayGroup.prototype.replay_ = function( ol.render.canvas.ReplayGroup.prototype.replay = function(
zs, context, extent, pixelRatio, transform, viewRotation, context, extent, pixelRatio, transform, viewRotation, skippedFeaturesHash) {
skippedFeaturesHash) {
/** @type {Array.<number>} */
var zs = goog.array.map(goog.object.getKeys(this.replaysByZIndex_), Number);
goog.array.sort(zs);
var maxExtent = this.maxExtent_; var maxExtent = this.maxExtent_;
var minX = maxExtent[0]; var minX = maxExtent[0];
@@ -1974,14 +1960,10 @@ ol.render.canvas.ReplayGroup.prototype.forEachGeometryAtPixel = function(
1 / resolution, -1 / resolution, -rotation, 1 / resolution, -1 / resolution, -rotation,
-coordinate[0], -coordinate[1]); -coordinate[0], -coordinate[1]);
/** @type {Array.<number>} */
var zs = goog.array.map(goog.object.getKeys(this.replaysByZIndex_), Number);
goog.array.sort(zs, function(a, b) { return b - a; });
var context = this.hitDetectionContext_; var context = this.hitDetectionContext_;
context.clearRect(0, 0, 1, 1); context.clearRect(0, 0, 1, 1);
return this.replayHitDetection_(zs, context, extent, transform, return this.replayHitDetection_(context, extent, transform,
rotation, skippedFeaturesHash, rotation, skippedFeaturesHash,
/** /**
* @param {ol.geom.Geometry} geometry Geometry. * @param {ol.geom.Geometry} geometry Geometry.