File tree Expand file tree Collapse file tree 1 file changed +18
-9
lines changed
Expand file tree Collapse file tree 1 file changed +18
-9
lines changed Original file line number Diff line number Diff line change @@ -48,17 +48,26 @@ const priorityCallback = ( a, b ) => {
4848
4949} ;
5050
51- /**
52- * Function for sorting the evicted LRU items. We should evict the shallowest depth first.
53- * @param {Tile } tile
54- * @returns number
55- */
51+ // lru cache unload callback that takes two tiles to compare
5652const lruPriorityCallback = ( a , b ) => {
5753
58- const aVal = 1 / ( a . __depthFromRenderedParent + 1 ) ;
59- const bVal = 1 / ( b . __depthFromRenderedParent + 1 ) ;
60- if ( aVal < bVal ) return - 1 ;
61- if ( aVal > bVal ) return 1 ;
54+ if ( a . __depthFromRenderedParent !== b . __depthFromRenderedParent ) {
55+
56+ // dispose of deeper tiles first
57+ return a . __depthFromRenderedParent > b . __depthFromRenderedParent ? 1 : - 1 ;
58+
59+ } else if ( a . __lastFrameVisited !== b . __lastFrameVisited ) {
60+
61+ // dispose of least recent tiles first
62+ return a . __lastFrameVisited > b . __lastFrameVisited ? - 1 : 1 ;
63+
64+ } else if ( a . __externalTileSet !== b . __externalTileSet ) {
65+
66+ // dispose of external tile sets last
67+ return a . __externalTileSet ? - 1 : 1 ;
68+
69+ }
70+
6271 return 0 ;
6372
6473} ;
You can’t perform that action at this time.
0 commit comments