Find file History
monsieurtanuki and spyhunter99 Just removed `MapTile`, using `MapTileIndex` instead (#908)
* Displayed tiles are now safely stored in memory
We could even have a cache capacity of 0!

How do we do that?
* just before drawing the tiles, we list them
* using that list, we specifically ask the cache not to remove the LRU tile if it's among the displayed tiles

Isn't using the LRU enough?
* apparently not (cf. #846)
* neither theoretically (cf. `MapTileApproximater` potential side effects)

New classes:
* `MapTileIndex`: computes a map tile index as `long` to/from zoom/x/y
* `MapTileIndexTest`: unit tests related to `MapTileIndex`
* `MapTileList`: an optimized list of map tile indices
* `MapTileListTest`: unit tests related to `MapTileList`

Impacted classes:
* `DefaultOverlayManager`: called at the very start of `onDraw` the new method `TilesOverlay.protectDisplayedTilesForCache` in order to ensure that tiles to be displayed won't be erased from memory
* LRUMapTileCache` : added a `MapTileList` in the constructor and as member in order to store the displayed tiles' indices; edited method `removeEldestEntry` in order not to remove the displayed tiles
* `MapTileCache`: added a `MapTileList` member and its getter, as a container of all tiles currently (to be) displayed
* `MapTileProviderBase`: added method `getCacheMapTileList` in order to provide the `TilesOverlay` with the memory cache `MapTileList`
* `MinimapOverlay`: overrode and used new method `TilesOverlay.setViewPort`
* `TilesOverlay`: created method `protectDisplayedTilesForCache`, that populates the tile provider's memory cache with the list of displayed tiles, to be used just before the actual tile drawing; created method `setViewPort`, to be used when preparing the tile cache and when drawing the tiles; created inner class `CacheTileLooper` to collect all tiles' indices and created a final instance of it.
* `TileSystem`: made `public` static member `primaryKeyMaxZoomLevel` as the maximum zoom level `tolerable for map tile indices as `long`

* Just removed `MapTile`, using `MapTileIndex` instead.

Warning: contains rather medieval refactoring.

This was not my initial goal.
My initial goal was performances, and obviously we'll be better off with a `long` than with a instantiated `Object` like `MapTile`.
Next step: fixing the "slight pause" issue from there.

To be continued, therefore...

Removed class:
* `MapTile`

And I'm afraid I cannot list all the classes I changed.

* Github conflict desperate move

* Github tango session

* "Hysteresis" memory tile cache

Now we keep in memory only:
* the currently displayed tiles
* and their equivalent on zoom levels +-1

Impacted classes:
* `LRUMapTileCache`: deprecated the whole class as it's not an LRU cache anymore
* `MapTileCache`: moved code from `LRUMapTileCache`; changed the memory cache to `HashMap`; deprecated the concept of "capacity"; create method `garbageCollection` that removed all the unnecessary tiles
* `MapTileIndex`: set `mMaxZoomLevel` as public
* `MapTileList`: created method `populateFrom` in order to compute the corresponding "hysteresis" map tile list zoom +-1
* `MapTileListTest`: create method `testPopulateFrom` for direct unit test purpose; created helper methods `populateSet` and `check`
* `MapTileProviderArray`: refactored `mWorking` as `HashSet`; added an async `ExecutorService`; create methods `asyncTileLookup` and `syncTileLookup` in order to deal with async tile lookup calls
* `MapTileProviderBase`: gently refactored
* `TilesOverlay`: refined `CacheTileLooper`

* Added async garbage collecting and stronger code, concurrency-wise

Impacted classes:
* `BitmapPool`: created public method `asyncRecycle` and private method `syncRecycle` in order to unify the bitmap recycling and make it async; refactored the singleton implementation
* `MapTileCache`: added some coments; made methods `garbageCollection` and `clear` stronger regarding concurrency issues; now using the new `BitmapPool.asyncRecycle` method; created helper method `populateSyncCachedTiles`
* `MapTileDownloader`: now using the new `BitmapPool.asyncRecycle` method
* `MapTileList`: added constructor with initial capacity
* `MapTileProviderArray`: moved `clearTileCache` call to `MapTileProviderBase.detach`
* `MapTileProviderBase`: moved `clearTileCache` call from `MapTileProviderArray.detach`; now using the new `BitmapPool.asyncRecycle` method
* `Marker`: now using the new `BitmapPool.asyncRecycle` method
* `TilesOverlay`: now using the new `BitmapPool.asyncRecycle` method; fixed a typo in a comment

Deprecated (and soon to be removed) class:
* `LRUMapTileCache`

* Fixed a world replication side effect

Impacted classes:
* `MapTileIndex`: created methods `checkValues` and `throwIllegalValue` in order to be more strict regarding input values
* `TileLooper`: fixed tile index computation in the loop regardless of world replication
* `TilesOverlay`: unified the settings of horizontal / vertical wrap enabled members; gently refactored

* Fixed unit tests and added zoom check for tile index

Impacted class:
* `MapTileIndex`: added a check for the zoom
* `OpenStreetMapTileProviderDirectTest`: fixed tile values for unit tests

* MapTileCache: reintroduced the concept of "capacity"

New class:
* `MapTileCacheTest`: unit tests for `MapTileCache`

Impacted class:
* `MapTileCache`: reintroduced the concept of "capacity" and edited `garbageCollection` accordingly; added method `getSize`

* #812 applying updates to the sql tile writer which appears to have improved performance when inserting tiles

* Splitting in two the read access to tiles: (fast&sync) / (slow&async)

See comments on `MapTileProviderBase.getMapTileSecondChance` for more details.

Impacted classes:
* `GeoPackageFeatureTileProvider`: minimum impact of new `TileLooper` parameter in `getMapTile` and new method `getMapTileSecondChance`
* `MapTileList`: new method `toArray`
* `MapTileProviderArray`: removed now useless `ExecutorService mExecutor` member and `asyncTileLookup`method; impacted new `TileLooper` parameter in `getMapTile` and new method `getMapTileSecondChance` - letting fast code in `getMapTile` and moving slower code to `getMapTileSecondChance`; renamed `syncTileLookup` as `getMapTileSecondChance`
* `MapTileProviderBase`: added parameter `TileLooper` in `getMapTile`; added method `getMapTileSecondChance`
* `TileLooper`: added member `mMissedTiles` typically to store the tiles that couldn't be dealt with quickly; added related `getMissedTiles` getter method; added method `missed(map tile index)` in order to populate `mMissedTiles`
* `TilesOverlay`: impacted new `TileLooper` parameter in `getMapTile` and new method `getMapTileSecondChance`; overrode `finaliseLoop` in order to load async'ly all missed tiles

* Github salsa

* Rolling back most of previous push

The async way doesn't seem that good.

Impacted classes:
* `GeoPackageFeatureTileProvider`: removed `TileLooper` parameter from `getMapTile` and removed method `getMapTileSecondChance`
* `MapTileProviderArray`: removed `TileLooper` parameter from `getMapTile` and removed method `getMapTileSecondChance`
* `MapTileProviderBase`: removed `TileLooper` parameter from `getMapTile` and removed method `getMapTileSecondChance`
* `TileLooper`: removed member `mMissedTiles` and related `getMissedTiles` getter method; removed method `missed(map tile index)`
* `TilesOverlay`: impacted removal of parameter `TileLooper` in `getMapTile` and of method `getMapTileSecondChance`; removed the notion of "missed tiles" from `finaliseLoop`

* GoogleTilesOverlay mini-fix

* OpenStreetMapTileProviderDirectTest tiny-fix

* Update
Latest commit b54d749 Feb 17, 2018