[Libreoffice-commits] online.git: Branch 'feature/calc-canvas' - loleaflet/src

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Tue Sep 8 14:25:56 UTC 2020


 loleaflet/src/layer/tile/CanvasTileLayer.js |   14 +++-----------
 1 file changed, 3 insertions(+), 11 deletions(-)

New commits:
commit c1c1ae1a395abc54d279487560e4fa5fac5c5af6
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Tue Sep 8 15:25:09 2020 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Tue Sep 8 15:25:09 2020 +0100

    calc canvas: avoid lots of canvas context save/restores.
    
    Change-Id: Ib813686ef7d495e660ad8fa3b545391180b9e019

diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js
index 4a35b4939..5a030050a 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -130,14 +130,12 @@ L.CanvasTilePainter = L.Class.extend({
 	},
 
 	clear: function () {
-		this._canvasCtx.save();
-		this._canvasCtx.scale(1, 1);
+		this._canvasCtx.setTransform(1,0,0,1,0,0);
 		if (this._layer._debug)
 			this._canvasCtx.fillStyle = 'rgba(255, 0, 0, 0.5)';
 		else
 			this._canvasCtx.fillStyle = 'white';
 		this._canvasCtx.fillRect(0, 0, this._width, this._height);
-		this._canvasCtx.restore();
 	},
 
 	// Details of tile areas to render
@@ -176,10 +174,7 @@ L.CanvasTilePainter = L.Class.extend({
 			if (topLeft.y)
 				topLeft.y = viewBounds.min.y;
 
-			this._canvasCtx.save();
-			this._canvasCtx.scale(1, 1);
-			this._canvasCtx.translate(-topLeft.x, -topLeft.y);
-
+			this._canvasCtx.setTransform(1,0,0,1,-topLeft.x, -topLeft.y);
 			// when using the pinch to zoom, set additional translation based
 			// on the pinch movement
 			if (this._map._animatingZoom) {
@@ -199,7 +194,6 @@ L.CanvasTilePainter = L.Class.extend({
 				this._canvasCtx.strokeStyle = 'rgba(255, 0, 0, 0.5)';
 				this._canvasCtx.strokeRect(tile.coords.x, tile.coords.y, 256, 256);
 			}
-			this._canvasCtx.restore();
 		}
 	},
 
@@ -209,11 +203,9 @@ L.CanvasTilePainter = L.Class.extend({
 			return;
 		}
 		var splitPos = this._layer._cssPixelsToCore(splitPanesContext.getSplitPos());
-		this._canvasCtx.save();
-		this._canvasCtx.scale(1, 1);
+		this._canvasCtx.setTransform(1,0,0,1,0,0);
 		this._canvasCtx.strokeStyle = 'red';
 		this._canvasCtx.strokeRect(0, 0, splitPos.x, splitPos.y);
-		this._canvasCtx.restore();
 	},
 
 	_updateWithRAF: function () {


More information about the Libreoffice-commits mailing list