add BufferObject.isMaxFill(), used to reduce number of in-memory tiles
This commit is contained in:
parent
af37be4502
commit
e35f39c9f4
@ -219,4 +219,8 @@ public final class BufferObject {
|
|||||||
createBuffers(GL20.GL_ARRAY_BUFFER, num);
|
createBuffers(GL20.GL_ARRAY_BUFFER, num);
|
||||||
counter[0] += num;
|
counter[0] += num;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static boolean isMaxFill() {
|
||||||
|
return mBufferMemoryUsage > LIMIT_BUFFERS;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ import org.oscim.core.MapPosition;
|
|||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.map.Map;
|
import org.oscim.map.Map;
|
||||||
import org.oscim.map.Viewport;
|
import org.oscim.map.Viewport;
|
||||||
|
import org.oscim.renderer.BufferObject;
|
||||||
import org.oscim.renderer.MapRenderer;
|
import org.oscim.renderer.MapRenderer;
|
||||||
import org.oscim.utils.FastMath;
|
import org.oscim.utils.FastMath;
|
||||||
import org.oscim.utils.ScanBox;
|
import org.oscim.utils.ScanBox;
|
||||||
@ -37,6 +38,8 @@ public class TileManager {
|
|||||||
static final String TAG = TileManager.class.getName();
|
static final String TAG = TileManager.class.getName();
|
||||||
|
|
||||||
private int mCacheLimit;
|
private int mCacheLimit;
|
||||||
|
private int mCacheReduce;
|
||||||
|
|
||||||
private int mMinZoom;
|
private int mMinZoom;
|
||||||
private int mMaxZoom;
|
private int mMaxZoom;
|
||||||
|
|
||||||
@ -107,14 +110,12 @@ public class TileManager {
|
|||||||
|
|
||||||
private final float[] mMapPlane = new float[8];
|
private final float[] mMapPlane = new float[8];
|
||||||
|
|
||||||
//private final TileLayer<?> mTileLayer;
|
|
||||||
|
|
||||||
public TileManager(Map map, int minZoom, int maxZoom, int cacheLimit) {
|
public TileManager(Map map, int minZoom, int maxZoom, int cacheLimit) {
|
||||||
mMap = map;
|
mMap = map;
|
||||||
//mTileLayer = tileLayer;
|
|
||||||
mMaxZoom = maxZoom;
|
mMaxZoom = maxZoom;
|
||||||
mMinZoom = minZoom;
|
mMinZoom = minZoom;
|
||||||
mCacheLimit = cacheLimit;
|
mCacheLimit = cacheLimit;
|
||||||
|
mCacheReduce = 0;
|
||||||
|
|
||||||
mViewport = map.getViewport();
|
mViewport = map.getViewport();
|
||||||
|
|
||||||
@ -269,8 +270,16 @@ public class TileManager {
|
|||||||
|
|
||||||
mJobs.clear();
|
mJobs.clear();
|
||||||
|
|
||||||
|
if (mCacheReduce < mCacheLimit / 2) {
|
||||||
|
if (BufferObject.isMaxFill()) {
|
||||||
|
mCacheReduce += 10;
|
||||||
|
Log.d(TAG, "reduce tile cache " + (mCacheLimit - mCacheReduce));
|
||||||
|
} else
|
||||||
|
mCacheReduce = 0;
|
||||||
|
}
|
||||||
|
|
||||||
/* limit cache items */
|
/* limit cache items */
|
||||||
int remove = mTilesCount - mCacheLimit;
|
int remove = mTilesCount - (mCacheLimit - mCacheReduce);
|
||||||
|
|
||||||
if (remove > CACHE_THRESHOLD ||
|
if (remove > CACHE_THRESHOLD ||
|
||||||
mTilesForUpload > MAX_TILES_IN_QUEUE)
|
mTilesForUpload > MAX_TILES_IN_QUEUE)
|
||||||
@ -473,12 +482,12 @@ public class TileManager {
|
|||||||
MapTile t = tiles[i];
|
MapTile t = tiles[i];
|
||||||
if (t.isLocked()) {
|
if (t.isLocked()) {
|
||||||
// dont remove tile used by GLRenderer, or somewhere else
|
// dont remove tile used by GLRenderer, or somewhere else
|
||||||
Log.d(TAG, "locked " + t
|
|
||||||
+ " " + t.distance
|
|
||||||
+ " " + (t.state == STATE_NEW_DATA)
|
|
||||||
+ " " + (t.state == STATE_LOADING)
|
|
||||||
+ " " + pos.zoomLevel);
|
|
||||||
// try again in next run.
|
// try again in next run.
|
||||||
|
//Log.d(TAG, "locked " + t
|
||||||
|
// + " " + t.distance
|
||||||
|
// + " " + (t.state == STATE_NEW_DATA)
|
||||||
|
// + " " + (t.state == STATE_LOADING)
|
||||||
|
// + " " + pos.zoomLevel);
|
||||||
} else if (t.state == STATE_LOADING) {
|
} else if (t.state == STATE_LOADING) {
|
||||||
// NOTE: when set loading to false the tile could be
|
// NOTE: when set loading to false the tile could be
|
||||||
// added to load queue again while still processed in
|
// added to load queue again while still processed in
|
||||||
|
Loading…
x
Reference in New Issue
Block a user