[Libreoffice-commits] online.git: Branch 'distro/collabora/collabora-online-3' - loleaflet/src

Tamás Zolnai tamas.zolnai at collabora.com
Fri Jun 8 15:34:31 UTC 2018


 loleaflet/src/layer/tile/GridLayer.js |   79 ++++++++++++++++++----------------
 1 file changed, 42 insertions(+), 37 deletions(-)

New commits:
commit 0e1a70795b94e120ac3f70b48848e85bb572f00c
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date:   Fri Jun 8 13:27:10 2018 +0200

    Zooming in for the first time shows tiles appearing instead of interpolation
    
    Drop only those tiles which are not part of the new visible area.
    
    Change-Id: I4cf86266b4f51cd7e96b9db10da108f644ecdceb
    Reviewed-on: https://gerrit.libreoffice.org/55480
    Reviewed-by: Jan Holesovsky <kendy at collabora.com>
    Tested-by: Jan Holesovsky <kendy at collabora.com>

diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 0325284f8..1fc666a7f 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -542,24 +542,7 @@ L.GridLayer = L.Layer.extend({
 			if (newView) {
 				// we know that a new set of tiles that cover the whole view has been requested
 				// so we're able to cancel the previous requests that are being processed
-				this._map._socket.sendMessage('canceltiles');
-				for (key in this._tiles) {
-					// When _invalidCount > 0 the tile has been invalidated, however the new tile content
-					// has not yet been fetched and because of `canceltiles` message it will never be
-					// so we need to remove the tile, or when the tile is back inside the visible area
-					// its content would be the old invalidated one;
-					// example: a tile is invalidated but a sudden scroll to the cell cursor position causes
-					// to move the tile out of the visible area before the new content is fetched
-					if (!this._tiles[key].loaded || this._tiles[key]._invalidCount > 0) {
-						L.DomUtil.remove(this._tiles[key].el);
-						delete this._tiles[key];
-						if (this._debug) {
-							this._debugCancelledTiles++;
-							this._debugShowTileData();
-						}
-					}
-				}
-				this._emptyTilesCount = 0;
+				this._cancelTiles();
 			}
 
 			// if its the first batch of tiles to load
@@ -620,25 +603,7 @@ L.GridLayer = L.Layer.extend({
 			if (newView) {
 				// we know that a new set of tiles that cover the whole view has been requested
 				// so we're able to cancel the previous requests that are being processed
-				this._map._socket.sendMessage('canceltiles');
-				for (key in this._tiles) {
-					tile = this._tiles[key];
-					// When _invalidCount > 0 the tile has been invalidated, however the new tile content
-					// has not yet been fetched and because of `canceltiles` message it will never be
-					// so we need to remove the tile, or when the tile is back inside the visible area
-					// its content would be the old invalidated one;
-					// example: a tile is invalidated but a sudden scroll to the cell cursor position causes
-					// to move the tile out of the visible area before the new content is fetched
-					if (!tile.loaded || tile._invalidCount > 0) {
-						L.DomUtil.remove(tile.el);
-						delete this._tiles[key];
-						if (this._debug && this._debugDataCancelledTiles) {
-							this._debugCancelledTiles++;
-							this._debugDataCancelledTiles.setPrefix('Cancelled tiles: ' + this._debugCancelledTiles);
-						}
-					}
-				}
-				this._emptyTilesCount = 0;
+				this._cancelTiles();
 			}
 
 			// if its the first batch of tiles to load
@@ -719,6 +684,46 @@ L.GridLayer = L.Layer.extend({
 		}
 	},
 
+	_cancelTiles: function() {
+		this._map._socket.sendMessage('canceltiles');
+		for (var key in this._tiles) {
+			var tile = this._tiles[key];
+			// When _invalidCount > 0 the tile has been invalidated, however the new tile content
+			// has not yet been fetched and because of `canceltiles` message it will never be
+			// so we need to remove the tile, or when the tile is back inside the visible area
+			// its content would be the old invalidated one. Drop only those tiles which are not in
+			// the new visible area.
+			// example: a tile is invalidated but a sudden scroll to the cell cursor position causes
+			// to move the tile out of the visible area before the new content is fetched
+
+			var dropTile = !tile.loaded;
+			var coords = tile.coords;
+			if (coords.part === this._selectedPart) {
+				var visibleTopLeft = this._latLngToTwips(this._map.getBounds().getNorthWest());
+				var visibleBottomRight = this._latLngToTwips(this._map.getBounds().getSouthEast());
+				var visibleArea = new L.Bounds(visibleTopLeft, visibleBottomRight);
+				var tileTopLeft = this._coordsToTwips(coords);
+				var tileBottomRight = new L.Point(this._tileWidthTwips, this._tileHeightTwips);
+				var tileBounds = new L.Bounds(tileTopLeft, tileTopLeft.add(tileBottomRight));
+				dropTile |= (tile._invalidCount > 0 && !visibleArea.intersects(tileBounds));
+			}
+			else {
+				dropTile |= tile._invalidCount > 0;
+			}
+
+
+			if (dropTile) {
+				L.DomUtil.remove(tile.el);
+				delete this._tiles[key];
+				if (this._debug && this._debugDataCancelledTiles) {
+					this._debugCancelledTiles++;
+					this._debugDataCancelledTiles.setPrefix('Cancelled tiles: ' + this._debugCancelledTiles);
+				}
+			}
+		}
+		this._emptyTilesCount = 0;
+	},
+
 	_isValidTile: function (coords) {
 		if (coords.x < 0 || coords.y < 0) {
 			return false;


More information about the Libreoffice-commits mailing list