loleaflet/src/layer/tile/TileLayer.js |   24 ++++++++++++++++--------
 1 file changed, 16 insertions(+), 8 deletions(-)

New commits:
commit c36bca17f544b9c8572673e75421780d2cdd984a
Author: Mihai Varga <[email protected]>
Date:   Wed Aug 5 17:51:30 2015 +0300

    loleaflet: request tiles closer to the cursor first

diff --git a/loleaflet/src/layer/tile/TileLayer.js 
b/loleaflet/src/layer/tile/TileLayer.js
index e77fe32..37413b6 100644
--- a/loleaflet/src/layer/tile/TileLayer.js
+++ b/loleaflet/src/layer/tile/TileLayer.js
@@ -275,6 +275,7 @@ L.TileLayer = L.GridLayer.extend({
                        var visibleTopLeft = 
this._latLngToTwips(this._map.getBounds().getNorthWest());
                        var visibleBottomRight = 
this._latLngToTwips(this._map.getBounds().getSouthEast());
                        var visibleArea = new L.Bounds(visibleTopLeft, 
visibleBottomRight);
+                       var toRequest = [];
 
                        for (var key in this._tiles) {
                                var coords = this._tiles[key].coords;
@@ -289,14 +290,15 @@ L.TileLayer = L.GridLayer.extend({
                                                this._tiles[key]._invalidCount 
= 1;
                                        }
                                        if (visibleArea.intersects(bounds)) {
-                                               this.sendMessage('tile ' +
-                                                                               
'part=' + coords.part + ' ' +
-                                                                               
'width=' + this._tileSize + ' ' +
-                                                                               
'height=' + this._tileSize + ' ' +
-                                                                               
'tileposx=' + tileTopLeft.x + ' '    +
-                                                                               
'tileposy=' + tileTopLeft.y + ' ' +
-                                                                               
'tilewidth=' + this._tileWidthTwips + ' ' +
-                                                                               
'tileheight=' + this._tileHeightTwips, key);
+                                               var msg = 'tile ' +
+                                                               'part=' + 
coords.part + ' ' +
+                                                               'width=' + 
this._tileSize + ' ' +
+                                                               'height=' + 
this._tileSize + ' ' +
+                                                               'tileposx=' + 
tileTopLeft.x + ' '    +
+                                                               'tileposy=' + 
tileTopLeft.y + ' ' +
+                                                               'tilewidth=' + 
this._tileWidthTwips + ' ' +
+                                                               'tileheight=' + 
this._tileHeightTwips;
+                                               toRequest.push({msg: msg, key: 
key, coords: coords});
                                        }
                                        else {
                                                // tile outside of the visible 
area, just remove it
@@ -305,6 +307,12 @@ L.TileLayer = L.GridLayer.extend({
                                        }
                                }
                        }
+                       var cursorPos = 
this._map.project(this._visibleCursor.getNorthWest());
+                       cursorPos = cursorPos.divideBy(this._tileSize);
+                       toRequest.sort(function(x, y) {return 
x.coords.distanceTo(cursorPos) - y.coords.distanceTo(cursorPos)});
+                       for (var i = 0; i < toRequest.length; i++) {
+                               this.sendMessage(toRequest[i].msg, 
toRequest[i].key);
+                       }
                        for (key in this._tileCache) {
                                // compute the rectangle that each tile covers 
in the document based
                                // on the zoom level
_______________________________________________
Libreoffice-commits mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/libreoffice-commits

Reply via email to