From 300ebbfe82e4514547ef8cc4d04ac107df9015cf Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 11 May 2017 11:49:18 -0700 Subject: [PATCH 1/4] Tracking tile loading separately from tile drawing --- src/tiledimage.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index f4178c8d..3914b206 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -146,7 +146,8 @@ $.TiledImage = function( options ) { //internal state properties viewer: null, tilesMatrix: {}, // A '3d' dictionary [level][x][y] --> Tile. - coverage: {}, // A '3d' dictionary [level][x][y] --> Boolean. + coverage: {}, // A '3d' dictionary [level][x][y] --> Boolean; shows what areas have been drawn. + loadingCoverage: {}, // A '3d' dictionary [level][x][y] --> Boolean; shows what areas are loaded or are being loaded/blended. lastDrawn: [], // An unordered list of Tiles drawn last frame. lastResetTime: 0, // Last time for which the tiledImage was reset. _midDraw: false, // Is the tiledImage currently updating the viewport? @@ -1122,6 +1123,7 @@ function updateLevel(tiledImage, haveDrawn, drawLevel, level, levelOpacity, } resetCoverage(tiledImage.coverage, level); + resetCoverage(tiledImage.loadingCoverage, level); //OK, a new drawing so do your calculations var cornerTiles = tiledImage._getCornerTiles(level, topLeftBound, bottomRightBound); @@ -1216,6 +1218,9 @@ function updateTile( tiledImage, haveDrawn, drawLevel, x, y, level, levelOpacity setCoverage( tiledImage.coverage, level, x, y, false ); + var loadingCoverage = tile.loaded || tile.loading || isCovered(tiledImage.loadingCoverage, level, x, y); + setCoverage(tiledImage.loadingCoverage, level, x, y, loadingCoverage); + if ( !tile.exists ) { return best; } @@ -1269,7 +1274,7 @@ function updateTile( tiledImage, haveDrawn, drawLevel, x, y, level, levelOpacity } else if ( tile.loading ) { // the tile is already in the download queue tiledImage._tilesLoading++; - } else { + } else if (!loadingCoverage) { best = compareTiles( best, tile ); } From 03e43998eb0cec7831fc520e5557d823b289ea76 Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Mon, 15 May 2017 10:51:17 -0700 Subject: [PATCH 2/4] Fixed problem with subsequent zooms not loading tiles --- src/tiledimage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tiledimage.js b/src/tiledimage.js index 3914b206..42b15d99 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -925,6 +925,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag _updateViewport: function() { this._needsDraw = false; this._tilesLoading = 0; + this.loadingCoverage = {}; // Reset tile's internal drawn state while (this.lastDrawn.length > 0) { From 283b2974dde179a66986681bbd50f2ea6ebc68ec Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Thu, 18 May 2017 11:19:06 -0700 Subject: [PATCH 3/4] Debugging code --- src/tiledimage.js | 1 + 1 file changed, 1 insertion(+) diff --git a/src/tiledimage.js b/src/tiledimage.js index 42b15d99..0b3c0a4e 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1018,6 +1018,7 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag // Load the new 'best' tile if (bestTile && !bestTile.context2D) { + $.console.log('loading tile, level: ' + bestTile.level + ', x: ' + bestTile.x + ', y: ' + bestTile.y); loadTile(this, bestTile, currentTime); this._needsDraw = true; this._setFullyLoaded(false); From 6600aca3e4188677d2b7ef434dd8358de9e90edd Mon Sep 17 00:00:00 2001 From: Ian Gilman Date: Tue, 11 Jul 2017 13:41:40 -0700 Subject: [PATCH 4/4] Removing debug code --- src/tiledimage.js | 1 - 1 file changed, 1 deletion(-) diff --git a/src/tiledimage.js b/src/tiledimage.js index 12de4b5c..83543acd 100644 --- a/src/tiledimage.js +++ b/src/tiledimage.js @@ -1054,7 +1054,6 @@ $.extend($.TiledImage.prototype, $.EventSource.prototype, /** @lends OpenSeadrag // Load the new 'best' tile if (bestTile && !bestTile.context2D) { - $.console.log('loading tile, level: ' + bestTile.level + ', x: ' + bestTile.x + ', y: ' + bestTile.y); loadTile(this, bestTile, currentTime); this._needsDraw = true; this._setFullyLoaded(false);