From dd83952c28123d2c30adddc652b916ea2f1acf4e Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 27 Feb 2014 18:59:05 +0100 Subject: [PATCH 1/6] Make renderSync always force a render --- src/ol/map.js | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index 5223a1ced5..3c68d771b9 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -1022,13 +1022,7 @@ ol.Map.prototype.isRendered = function() { * Render. */ ol.Map.prototype.renderSync = function() { - if (this.animationDelay_.isActive()) { - // pass - } else if (this.freezeRenderingCount_ === 0) { - this.animationDelay_.fire(); - } else { - this.dirty_ = true; - } + this.animationDelay_.fire(); }; From e0c8b57e116d535df5f8102a794bbcb600eb3aed Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 27 Feb 2014 12:50:41 +0100 Subject: [PATCH 2/6] Don't use withFrozenRendering in ol.interaction.Interaction.rotateWithoutConstraints --- src/ol/interaction/interaction.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index 789f9c0812..92196acc62 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -127,16 +127,12 @@ ol.interaction.Interaction.rotateWithoutConstraints = })); } } + goog.asserts.assertInstanceof(view, ol.View2D); if (goog.isDefAndNotNull(opt_anchor)) { var center = view.calculateCenterRotate(rotation, opt_anchor); - map.withFrozenRendering(function() { - goog.asserts.assertInstanceof(view, ol.View2D); - view.setCenter(center); - view.setRotation(rotation); - }); - } else { - view.setRotation(rotation); + view.setCenter(center); } + view.setRotation(rotation); } }; From c9c8497b7eedfc2f5773ce67c2fe64904f899996 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 27 Feb 2014 12:50:57 +0100 Subject: [PATCH 3/6] Don't use withFrozenRendering in ol.interaction.Interaction.zoomWithoutConstraints --- src/ol/interaction/interaction.js | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/ol/interaction/interaction.js b/src/ol/interaction/interaction.js index 92196acc62..dbc57deee1 100644 --- a/src/ol/interaction/interaction.js +++ b/src/ol/interaction/interaction.js @@ -206,15 +206,11 @@ ol.interaction.Interaction.zoomWithoutConstraints = })); } } + goog.asserts.assertInstanceof(view, ol.View2D); if (goog.isDefAndNotNull(opt_anchor)) { var center = view.calculateCenterZoom(resolution, opt_anchor); - map.withFrozenRendering(function() { - goog.asserts.assertInstanceof(view, ol.View2D); - view.setCenter(center); - view.setResolution(resolution); - }); - } else { - view.setResolution(resolution); + view.setCenter(center); } + view.setResolution(resolution); } }; From 73be72380b00a04c4fcc8906c775a50a19be36b1 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 27 Feb 2014 12:51:20 +0100 Subject: [PATCH 4/6] Don't use withFrozenRendering in ol.interaction.DragRotateAndZoom#handleDragEnd --- src/ol/interaction/dragrotateandzoominteraction.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/ol/interaction/dragrotateandzoominteraction.js b/src/ol/interaction/dragrotateandzoominteraction.js index 4e86fce382..0d5f095365 100644 --- a/src/ol/interaction/dragrotateandzoominteraction.js +++ b/src/ol/interaction/dragrotateandzoominteraction.js @@ -110,12 +110,10 @@ ol.interaction.DragRotateAndZoom.prototype.handleDragEnd = var view2D = view.getView2D(); var view2DState = view2D.getView2DState(); var direction = this.lastScaleDelta_ - 1; - map.withFrozenRendering(function() { - ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation); - ol.interaction.Interaction.zoom(map, view2D, view2DState.resolution, - undefined, ol.interaction.DRAGROTATEANDZOOM_ANIMATION_DURATION, - direction); - }); + ol.interaction.Interaction.rotate(map, view2D, view2DState.rotation); + ol.interaction.Interaction.zoom(map, view2D, view2DState.resolution, + undefined, ol.interaction.DRAGROTATEANDZOOM_ANIMATION_DURATION, + direction); this.lastScaleDelta_ = 0; return true; }; From ad29e6bceb8e1d44d76d1e6fcd106a4fcf8edcab Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 27 Feb 2014 12:51:42 +0100 Subject: [PATCH 5/6] Don't use withFrozenRendering in ol.interaction.Select#handleMapBrowserEvent --- src/ol/interaction/selectinteraction.js | 78 ++++++++++++------------- 1 file changed, 36 insertions(+), 42 deletions(-) diff --git a/src/ol/interaction/selectinteraction.js b/src/ol/interaction/selectinteraction.js index 1b6b44104a..4c9e85d63b 100644 --- a/src/ol/interaction/selectinteraction.js +++ b/src/ol/interaction/selectinteraction.js @@ -97,50 +97,44 @@ ol.interaction.Select.prototype.handleMapBrowserEvent = var add = this.addCondition_(mapBrowserEvent); var map = mapBrowserEvent.map; var features = this.featureOverlay_.getFeatures(); - map.withFrozenRendering( - /** - * @this {ol.interaction.Select} - */ - function() { - if (add) { - map.forEachFeatureAtPixel(mapBrowserEvent.pixel, - /** - * @param {ol.Feature} feature Feature. - * @param {ol.layer.Layer} layer Layer. - */ - function(feature, layer) { - if (goog.array.indexOf(features.getArray(), feature) == -1) { - features.push(feature); - } - }, undefined, this.layerFilter_); - } else { - /** @type {ol.Feature|undefined} */ - var feature = map.forEachFeatureAtPixel(mapBrowserEvent.pixel, - /** - * @param {ol.Feature} feature Feature. - * @param {ol.layer.Layer} layer Layer. - */ - function(feature, layer) { - return feature; - }, undefined, this.layerFilter_); - if (goog.isDef(feature)) { - if (features.getLength() == 1) { - if (features.getAt(0) !== feature) { - features.setAt(0, feature); - } - } else { - if (features.getLength() != 1) { - features.clear(); - } - features.push(feature); - } - } else { - if (features.getLength() !== 0) { - features.clear(); - } + if (add) { + map.forEachFeatureAtPixel(mapBrowserEvent.pixel, + /** + * @param {ol.Feature} feature Feature. + * @param {ol.layer.Layer} layer Layer. + */ + function(feature, layer) { + if (goog.array.indexOf(features.getArray(), feature) == -1) { + features.push(feature); } + }, undefined, this.layerFilter_); + } else { + /** @type {ol.Feature|undefined} */ + var feature = map.forEachFeatureAtPixel(mapBrowserEvent.pixel, + /** + * @param {ol.Feature} feature Feature. + * @param {ol.layer.Layer} layer Layer. + */ + function(feature, layer) { + return feature; + }, undefined, this.layerFilter_); + if (goog.isDef(feature)) { + if (features.getLength() == 1) { + if (features.getAt(0) !== feature) { + features.setAt(0, feature); } - }, this); + } else { + if (features.getLength() != 1) { + features.clear(); + } + features.push(feature); + } + } else { + if (features.getLength() !== 0) { + features.clear(); + } + } + } return false; }; From 9a7261d6b3f952e47ae24ca6fd45b7691c16a540 Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 27 Feb 2014 19:01:39 +0100 Subject: [PATCH 6/6] Remove ol.Map#withFrozenRendering --- src/ol/map.js | 59 ++------------------------------------------------- 1 file changed, 2 insertions(+), 57 deletions(-) diff --git a/src/ol/map.js b/src/ol/map.js index 3c68d771b9..8ee68204b9 100644 --- a/src/ol/map.js +++ b/src/ol/map.js @@ -215,18 +215,6 @@ ol.Map = function(options) { */ this.frameState_ = null; - /** - * @private - * @type {number} - */ - this.freezeRenderingCount_ = 0; - - /** - * @private - * @type {boolean} - */ - this.dirty_ = false; - /** * @private * @type {goog.events.Key} @@ -526,14 +514,6 @@ ol.Map.prototype.forEachFeatureAtPixel = }; -/** - * Freeze rendering. - */ -ol.Map.prototype.freezeRendering = function() { - ++this.freezeRenderingCount_; -}; - - /** * Returns the geographical coordinate for a browser event. * @param {Event} event Event. @@ -1030,12 +1010,8 @@ ol.Map.prototype.renderSync = function() { * Request that renderFrame_ be called some time in the future. */ ol.Map.prototype.render = function() { - if (this.freezeRenderingCount_ === 0) { - if (!this.animationDelay_.isActive()) { - this.animationDelay_.start(); - } - } else { - this.dirty_ = true; + if (!this.animationDelay_.isActive()) { + this.animationDelay_.start(); } }; @@ -1116,10 +1092,6 @@ ol.Map.prototype.renderFrame_ = function(time) { var i, ii, view2DState; - if (this.freezeRenderingCount_ !== 0) { - return; - } - /** * Check whether a size has non-zero width and height. Note that this * function is here because the compiler doesn't recognize that size is @@ -1196,7 +1168,6 @@ ol.Map.prototype.renderFrame_ = function(time) { this.frameState_ = frameState; this.renderer_.renderFrame(frameState); - this.dirty_ = false; if (!goog.isNull(frameState)) { if (frameState.animate) { @@ -1279,17 +1250,6 @@ goog.exportProperty( ol.Map.prototype.setView); -/** - * Unfreeze rendering. - */ -ol.Map.prototype.unfreezeRendering = function() { - goog.asserts.assert(this.freezeRenderingCount_ > 0); - if (--this.freezeRenderingCount_ === 0 && this.dirty_) { - this.animationDelay_.fire(); - } -}; - - /** * Force a recalculation of the map viewport size. This should be called when * third-party code changes the size of the map viewport. @@ -1313,21 +1273,6 @@ ol.Map.prototype.updateSize = function() { }; -/** - * @param {function(this: T)} f Function. - * @param {T=} opt_this The object to use as `this` in `f`. - * @template T - */ -ol.Map.prototype.withFrozenRendering = function(f, opt_this) { - this.freezeRendering(); - try { - f.call(opt_this); - } finally { - this.unfreezeRendering(); - } -}; - - /** * @typedef {{controls: ol.Collection, * deviceOptions: olx.DeviceOptions,