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

Michael Meeks (via logerrit) logerrit at kemper.freedesktop.org
Wed Sep 9 11:06:41 UTC 2020


 loleaflet/src/layer/tile/CanvasTileLayer.js |   17 ++++++++++-------
 1 file changed, 10 insertions(+), 7 deletions(-)

New commits:
commit 64a860340886498be592c3ee09d8f1fc6022ef31
Author:     Michael Meeks <michael.meeks at collabora.com>
AuthorDate: Wed Sep 9 12:02:50 2020 +0100
Commit:     Michael Meeks <michael.meeks at collabora.com>
CommitDate: Wed Sep 9 12:06:06 2020 +0100

    calc tiles: clarify some magic.
    
    Change-Id: I2d95dd09b5640a5216e72366493ddf77541c8b73

diff --git a/loleaflet/src/layer/tile/CanvasTileLayer.js b/loleaflet/src/layer/tile/CanvasTileLayer.js
index aee0f9b60..dd198966b 100644
--- a/loleaflet/src/layer/tile/CanvasTileLayer.js
+++ b/loleaflet/src/layer/tile/CanvasTileLayer.js
@@ -162,7 +162,9 @@ L.CanvasTilePainter = L.Class.extend({
 		var tileBounds = new L.Bounds(tileTopLeft, tileTopLeft.add(ctx.tileSize));
 
 		for (var i = 0; i < ctx.paneBoundsList.length; ++i) {
+			// co-ordinates of this pane in core document pixels
 			var paneBounds = this._layer._cssBoundsToCore(ctx.paneBoundsList[i]);
+			// co-ordinates of the main-(bottom right) pane in core document pixels
 			var viewBounds = this._layer._cssBoundsToCore(ctx.viewBounds);
 
 			// into real pixel-land ...
@@ -172,16 +174,17 @@ L.CanvasTilePainter = L.Class.extend({
 			if (!paneBounds.intersects(tileBounds))
 				continue;
 
-			var offset = paneBounds.getTopLeft(); // allocates
-			offset.x = Math.min(offset.x, viewBounds.min.x);
-			offset.y = Math.min(offset.y, viewBounds.min.y);
+			var paneOffset = paneBounds.getTopLeft(); // allocates
+			// Cute way to detect the in-canvas pixel offset of each pane
+			paneOffset.x = Math.min(paneOffset.x, viewBounds.min.x);
+			paneOffset.y = Math.min(paneOffset.y, viewBounds.min.y);
 
 			// when using the pinch to zoom, set additional translation based */
 			// on the pinch movement
 			if (this._map._animatingZoom) {
 				var centerOffset = this._map._getCenterOffset(this._map._animateToCenter);
-				offset.x += Math.round(centerOffset.x);
-				offset.y += Math.round(centerOffset.y);
+				paneOffset.x += Math.round(centerOffset.x);
+				paneOffset.y += Math.round(centerOffset.y);
 			}
 
 			// intersect - to avoid state thrash through clipping
@@ -198,8 +201,8 @@ L.CanvasTilePainter = L.Class.extend({
 						  crop.min.x - tileBounds.min.x,
 						  crop.min.y - tileBounds.min.y,
 						  cropWidth, cropHeight,
-						  crop.min.x - offset.x,
-						  crop.min.y - offset.y,
+						  crop.min.x - paneOffset.x,
+						  crop.min.y - paneOffset.y,
 						  cropWidth, cropHeight);
 			if (this._layer._debug)
 			{


More information about the Libreoffice-commits mailing list