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