[Libreoffice-commits] online.git: Branch 'feature/latency' - 2 commits - loleaflet/src
Tamás Zolnai
tamas.zolnai at collabora.com
Thu Jun 14 16:59:08 UTC 2018
loleaflet/src/layer/tile/GridLayer.js | 99 ++++++++++++++++++++--------------
loleaflet/src/layer/tile/TileLayer.js | 19 +-----
2 files changed, 65 insertions(+), 53 deletions(-)
New commits:
commit d1c4f3cd092479c01733856045d836c85f902557
Author: Tamás Zolnai <tamas.zolnai at collabora.com>
Date: Thu Jun 14 16:50:34 2018 +0200
Clientzoom should also be send immediatelly after change
Change-Id: I7ed83ba3857c42388db925658e810fc6b89b647b
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index 596f1fb90..660d2c297 100644
--- a/loleaflet/src/layer/tile/GridLayer.js
+++ b/loleaflet/src/layer/tile/GridLayer.js
@@ -544,7 +544,6 @@ L.GridLayer = L.Layer.extend({
// so we're able to cancel the previous requests that are being processed
this._cancelTiles();
}
-
// if its the first batch of tiles to load
if (this._noTilesToLoad()) {
this.fire('loading');
@@ -555,8 +554,12 @@ L.GridLayer = L.Layer.extend({
this._addTiles(queue, fragment);
this._level.el.appendChild(fragment);
}
+
this._invalidateClientVisibleArea();
this._sendClientVisibleArea();
+
+ this._updateClientZoom();
+ this._sendClientZoom();
},
_updateOnChangePart: function () {
@@ -684,6 +687,12 @@ L.GridLayer = L.Layer.extend({
this._level.el.appendChild(fragment);
}
+
+ this._invalidateClientVisibleArea();
+ this._sendClientVisibleArea();
+
+ this._updateClientZoom();
+ this._sendClientZoom();
},
_invalidateClientVisibleArea: function() {
@@ -709,7 +718,15 @@ L.GridLayer = L.Layer.extend({
this._map._socket.sendMessage(payload);
this._clientVisibleArea = false;
}
- },
+ },
+
+ _sendClientZoom: function () {
+ if (this._clientZoom) {
+ // the zoom level has changed
+ this._map._socket.sendMessage('clientzoom ' + this._clientZoom);
+ this._clientZoom = null;
+ }
+ },
_cancelTiles: function() {
this._map._socket.sendMessage('canceltiles');
diff --git a/loleaflet/src/layer/tile/TileLayer.js b/loleaflet/src/layer/tile/TileLayer.js
index dbd1b0871..42087226f 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -147,10 +147,7 @@ L.TileLayer = L.GridLayer.extend({
this._msgQueue = [];
this._toolbarCommandValues = {};
this._previewInvalidations = [];
- this._clientZoom = 'tilepixelwidth=' + this._tileWidthPx + ' ' +
- 'tilepixelheight=' + this._tileHeightPx + ' ' +
- 'tiletwipwidth=' + this.options.tileWidthTwips + ' ' +
- 'tiletwipheight=' + this.options.tileHeightTwips;
+ this._updateClientZoom();
this._followThis = -1;
this._editorId = -1;
@@ -1472,11 +1469,8 @@ L.TileLayer = L.GridLayer.extend({
},
_postMouseEvent: function(type, x, y, count, buttons, modifier) {
- if (this._clientZoom) {
- // the zoom level has changed
- this._map._socket.sendMessage('clientzoom ' + this._clientZoom);
- this._clientZoom = null;
- }
+
+ this._sendClientZoom();
this._sendClientVisibleArea();
@@ -1505,11 +1499,8 @@ L.TileLayer = L.GridLayer.extend({
this._cellCursorOnPgDn = new L.LatLngBounds(this._prevCellCursor.getSouthWest(), this._prevCellCursor.getNorthEast());
}
}
- if (this._clientZoom) {
- // the zoom level has changed
- this._map._socket.sendMessage('clientzoom ' + this._clientZoom);
- this._clientZoom = null;
- }
+
+ this._sendClientZoom();
this._sendClientVisibleArea();
commit 4c477465cd6f64439c86e1cbe489d12e8c56284f
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.
Reviewed-on: https://gerrit.libreoffice.org/55467
Reviewed-by: Tamás Zolnai <tamas.zolnai at collabora.com>
Tested-by: Tamás Zolnai <tamas.zolnai at collabora.com>
(cherry picked from commit d35fb55511c1d1d7bc851696dd1655dcb6468602)
Change-Id: I4cf86266b4f51cd7e96b9db10da108f644ecdceb
diff --git a/loleaflet/src/layer/tile/GridLayer.js b/loleaflet/src/layer/tile/GridLayer.js
index ec3a4dc6e..596f1fb90 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
@@ -622,25 +605,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
@@ -721,7 +686,6 @@ L.GridLayer = L.Layer.extend({
}
},
-
_invalidateClientVisibleArea: function() {
if (this._debug) {
this._debugInfo.clearLayers();
@@ -745,6 +709,46 @@ L.GridLayer = L.Layer.extend({
this._map._socket.sendMessage(payload);
this._clientVisibleArea = false;
}
+ },
+
+ _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) {
More information about the Libreoffice-commits
mailing list