start render early

This commit is contained in:
Hannes Janetzek
2013-02-01 04:31:39 +01:00
parent a8c2f72a35
commit 019c39d8b8
10 changed files with 58 additions and 35 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -106,7 +106,7 @@ public class GridOverlay extends BasicOverlay {
void timerFinished() {
Log.d("...", "timer finish!");
finished = true;
mMapView.redrawMap();
mMapView.redrawMap(true);
}
@Override

View File

@@ -68,7 +68,7 @@ public class TextOverlay extends BasicOverlay {
mRun = false;
updateLabels();
mMapView.redrawMap();
mMapView.redrawMap(false);
}
@Override

View File

@@ -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) {