start render early
This commit is contained in:
parent
a8c2f72a35
commit
019c39d8b8
@ -302,7 +302,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
@Override
|
||||
public void onDrawFrame(GL10 glUnused) {
|
||||
long start = SystemClock.uptimeMillis();
|
||||
long wait = 20 - (start - lastDraw);
|
||||
long wait = 30 - (start - lastDraw);
|
||||
if (wait > 5) {
|
||||
//Log.d(TAG, "wait " + wait);
|
||||
SystemClock.sleep(wait);
|
||||
@ -549,7 +549,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
GLES20.glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
|
||||
|
||||
if (!mNewSurface) {
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -569,7 +569,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
||||
|
||||
GLState.init();
|
||||
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -207,15 +207,15 @@ public class TileManager {
|
||||
float[] coords = mTileCoords;
|
||||
changedPos = mMapViewPosition.getMapPosition(mapPosition, coords);
|
||||
|
||||
if (!changedPos) {
|
||||
mMapView.render();
|
||||
if (changedPos) {
|
||||
//mMapView.render();
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
|
||||
float s = Tile.TILE_SIZE;
|
||||
// load some tiles more than currently visible
|
||||
// TODO limit how many more...
|
||||
float scale = mapPosition.scale * 0.75f;
|
||||
float scale = mapPosition.scale * 0.8f;
|
||||
float px = (float) mapPosition.x;
|
||||
float py = (float) mapPosition.y;
|
||||
|
||||
@ -223,15 +223,15 @@ public class TileManager {
|
||||
int zdir = 0;
|
||||
|
||||
for (int i = 0; i < 8; i += 2) {
|
||||
coords[i + 0] = (px + coords[i + 0] / scale) / s;
|
||||
coords[i + 1] = (py + coords[i + 1] / scale) / s;
|
||||
coords[i + 0] = (px + coords[i + 0] / scale) / Tile.TILE_SIZE;
|
||||
coords[i + 1] = (py + coords[i + 1] / scale) / Tile.TILE_SIZE;
|
||||
}
|
||||
|
||||
boolean changed = updateVisibleList(mapPosition, zdir);
|
||||
|
||||
mMapView.render();
|
||||
|
||||
if (changed) {
|
||||
mMapView.render();
|
||||
|
||||
int remove = mTilesCount - GLRenderer.CACHE_TILES;
|
||||
if (remove > CACHE_THRESHOLD)
|
||||
limitCache(mapPosition, remove);
|
||||
@ -337,9 +337,6 @@ public class TileManager {
|
||||
|
||||
mUpdateCnt++;
|
||||
}
|
||||
|
||||
// Log.d(TAG, "tiles: " + mTilesCount + " " + BufferObject.counter
|
||||
// + " sum:" + (mTilesCount + BufferObject.counter));
|
||||
}
|
||||
|
||||
if (mJobs.size() > 0) {
|
||||
@ -606,13 +603,14 @@ public class TileManager {
|
||||
}
|
||||
|
||||
if (tile.vbo != null) {
|
||||
// BAD Things(tm) happend...
|
||||
Log.d(TAG, "tile loaded before " + tile);
|
||||
// BAD Things(tm) happend: tile is already loaded
|
||||
Log.d(TAG, "BUG: tile loaded before " + tile);
|
||||
return true;
|
||||
}
|
||||
|
||||
tile.state = STATE_NEW_DATA;
|
||||
|
||||
//if (tile.isVisible)
|
||||
mMapView.render();
|
||||
|
||||
synchronized (mTilesLoaded) {
|
||||
|
@ -106,7 +106,7 @@ public class GridOverlay extends BasicOverlay {
|
||||
void timerFinished() {
|
||||
Log.d("...", "timer finish!");
|
||||
finished = true;
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -68,7 +68,7 @@ public class TextOverlay extends BasicOverlay {
|
||||
|
||||
mRun = false;
|
||||
updateLabels();
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(false);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -15,6 +15,8 @@
|
||||
|
||||
package org.oscim.renderer.overlays;
|
||||
|
||||
import java.util.HashMap;
|
||||
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.generator.JobTile;
|
||||
@ -66,7 +68,7 @@ public class TextOverlayExp extends BasicOverlay {
|
||||
|
||||
mRun = false;
|
||||
if (updateLabels())
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(false);
|
||||
else
|
||||
mRun = true;
|
||||
}
|
||||
@ -90,6 +92,25 @@ public class TextOverlayExp extends BasicOverlay {
|
||||
mThread.start();
|
||||
}
|
||||
|
||||
private HashMap<TextItem, PlacementItem> mItemMap;
|
||||
|
||||
class PlacementItem extends TextItem {
|
||||
int tileX;
|
||||
int tileY;
|
||||
|
||||
boolean isTileNeighbour(PlacementItem other) {
|
||||
int dx = other.tileX - tileX;
|
||||
if (dx > 1 || dx < -1)
|
||||
return false;
|
||||
|
||||
int dy = other.tileY - tileY;
|
||||
if (dy > 1 || dy < -1)
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private TextItem mPool;
|
||||
|
||||
private byte checkOverlap(TextLayer tl, TextItem ti) {
|
||||
|
@ -30,7 +30,7 @@ public class Compass {
|
||||
|
||||
if (mMapView != null) {
|
||||
mMapView.getMapPosition().setRotation(-mAngle);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -274,11 +274,15 @@ public class MapView extends RelativeLayout {
|
||||
|
||||
/**
|
||||
* Calculates all necessary tiles and adds jobs accordingly.
|
||||
* @param changedPos TODO
|
||||
*/
|
||||
public void redrawMap() {
|
||||
public void redrawMap(boolean changedPos) {
|
||||
if (mPausing || this.getWidth() == 0 || this.getHeight() == 0)
|
||||
return;
|
||||
|
||||
if (changedPos)
|
||||
render();
|
||||
|
||||
if (AndroidUtils.currentThreadIsUiThread()) {
|
||||
boolean changed = mMapViewPosition.getMapPosition(mMapPosition, null);
|
||||
|
||||
@ -583,7 +587,7 @@ public class MapView extends RelativeLayout {
|
||||
+ " lat: " + mapPosition.lat
|
||||
+ " lon: " + mapPosition.lon);
|
||||
mMapViewPosition.setMapCenter(mapPosition);
|
||||
redrawMap();
|
||||
redrawMap(true);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -48,7 +48,7 @@ public class MapViewPosition {
|
||||
public final static int MAX_ZOOMLEVEL = 17;
|
||||
public final static int MIN_ZOOMLEVEL = 2;
|
||||
|
||||
private final static float MAX_ANGLE = 50;
|
||||
private final static float MAX_ANGLE = 55;
|
||||
|
||||
private final MapView mMapView;
|
||||
|
||||
@ -697,12 +697,12 @@ public class MapViewPosition {
|
||||
double mx = (mStartX + (mEndX - mStartX) * (1.0 - adv));
|
||||
double my = (mStartY + (mEndY - mStartY) * (1.0 - adv));
|
||||
setMapPosition(mx, my);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
void onFinish() {
|
||||
setMapPosition(mEndX, mEndY);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
static class AnimationHandler extends Handler {
|
||||
|
@ -161,7 +161,7 @@ public class MapZoomControls {
|
||||
}
|
||||
|
||||
mapViewPosition.setZoomLevel((byte) z);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -174,7 +174,7 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
// double-tap + hold
|
||||
if (mLongPress) {
|
||||
mMapPosition.scaleMap(1 - moveY / 100, 0, 0);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -198,10 +198,10 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
if (!mBeginRotate && !mBeginScale) {
|
||||
/* our naive gesture detector for rotation and tilt.. */
|
||||
|
||||
if (Math.abs(rad) < 0.25 || Math.abs(rad) > Math.PI - 0.25) {
|
||||
if (Math.abs(rad) < 0.30 || Math.abs(rad) > Math.PI - 0.30) {
|
||||
mBeginTilt = true;
|
||||
if (mMapPosition.tilt(moveY / 4)) {
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -229,7 +229,7 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
|
||||
mMapPosition.rotateMap((float) Math.toDegrees(rad - mAngle), x, y);
|
||||
mAngle = rad;
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -338,7 +338,7 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
|
||||
if (moveX >= 1 || moveY >= 1 || moveX <= -1 || moveY <= -1) {
|
||||
mMapPosition.moveMap(moveX, moveY);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
mScrollX = mScroller.getCurrX();
|
||||
mScrollY = mScroller.getCurrY();
|
||||
}
|
||||
@ -358,7 +358,7 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
|
||||
if (mMulti == 0) {
|
||||
mMapPosition.moveMap(-distanceX, -distanceY);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -447,7 +447,7 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
|
||||
if (scale > 1) {
|
||||
mMapPosition.scaleMap(scale, mScrollX / adv, mScrollY / adv);
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
}
|
||||
|
||||
return true;
|
||||
@ -505,7 +505,7 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
}
|
||||
|
||||
if (mBeginScale && mMapPosition.scaleMap(scale, mFocusX, mFocusY))
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -581,7 +581,7 @@ final class TouchHandler implements OnGestureListener, OnScaleGestureListener, O
|
||||
mMapPosition.scaleMap(1 + scale, mFocusX, mFocusY);
|
||||
}
|
||||
|
||||
mMapView.redrawMap();
|
||||
mMapView.redrawMap(true);
|
||||
|
||||
if (tick == 0)
|
||||
mTimer = null;
|
||||
|
Loading…
x
Reference in New Issue
Block a user