From e03953dc61933737c38ab2d98984a91b4379b67a Mon Sep 17 00:00:00 2001 From: Tom Payne Date: Thu, 7 Nov 2013 15:44:21 +0100 Subject: [PATCH] Avoid stroke state changes --- src/ol/replay/canvas/canvasbatchgroup.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/src/ol/replay/canvas/canvasbatchgroup.js b/src/ol/replay/canvas/canvasbatchgroup.js index 776cf32000..ede86bbff1 100644 --- a/src/ol/replay/canvas/canvasbatchgroup.js +++ b/src/ol/replay/canvas/canvasbatchgroup.js @@ -11,6 +11,7 @@ goog.require('goog.object'); goog.require('ol.replay'); goog.require('ol.replay.IBatch'); goog.require('ol.replay.IBatchGroup'); +goog.require('ol.style.stroke'); /** @@ -54,6 +55,12 @@ ol.replay.canvas.Batch = function() { */ this.pixelCoordinates_ = []; + /** + * @private + * @type {?ol.style.Stroke} + */ + this.currentStrokeStyle_ = null; + }; @@ -138,10 +145,14 @@ ol.replay.canvas.Batch.prototype.drawLineStringGeometry = * @inheritDoc */ ol.replay.canvas.Batch.prototype.setStrokeStyle = function(strokeStyle) { - this.instructions_.push({ - type: ol.replay.canvas.InstructionType.SET_STROKE_STYLE, - argument: strokeStyle - }); + if (goog.isNull(this.currentStrokeStyle_) || + !ol.style.stroke.equals(this.currentStrokeStyle_, strokeStyle)) { + this.instructions_.push({ + type: ol.replay.canvas.InstructionType.SET_STROKE_STYLE, + argument: strokeStyle + }); + this.currentStrokeStyle_ = strokeStyle; + } };