remove tilesChanged parameter of RenderLayer.update as there is no more global tile layer
- fix PathOverlay update
This commit is contained in:
parent
28ecec811a
commit
8bea920253
@ -20,8 +20,8 @@ import static org.oscim.layers.tile.MapTile.STATE_READY;
|
|||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.renderer.BufferObject;
|
import org.oscim.renderer.BufferObject;
|
||||||
import org.oscim.renderer.GLRenderer;
|
import org.oscim.renderer.GLRenderer;
|
||||||
import org.oscim.renderer.RenderLayer;
|
|
||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
import org.oscim.renderer.GLRenderer.Matrices;
|
||||||
|
import org.oscim.renderer.RenderLayer;
|
||||||
import org.oscim.utils.ScanBox;
|
import org.oscim.utils.ScanBox;
|
||||||
import org.oscim.view.MapView;
|
import org.oscim.view.MapView;
|
||||||
|
|
||||||
@ -44,11 +44,10 @@ public class TileRenderLayer extends RenderLayer {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged,
|
public void update(MapPosition pos, boolean positionChanged, Matrices m) {
|
||||||
Matrices matrices) {
|
|
||||||
int serial = 0;
|
int serial = 0;
|
||||||
|
|
||||||
mMapPosition.copy(curPos);
|
mMapPosition.copy(pos);
|
||||||
|
|
||||||
if (mDrawTiles != null)
|
if (mDrawTiles != null)
|
||||||
serial = mDrawTiles.getSerial();
|
serial = mDrawTiles.getSerial();
|
||||||
@ -85,9 +84,9 @@ public class TileRenderLayer extends RenderLayer {
|
|||||||
/* prepare tile for rendering */
|
/* prepare tile for rendering */
|
||||||
int uploadCnt = compileTileLayers(tiles, tileCnt);
|
int uploadCnt = compileTileLayers(tiles, tileCnt);
|
||||||
|
|
||||||
tilesChanged |= (uploadCnt > 0);
|
//tilesChanged |= (uploadCnt > 0);
|
||||||
|
|
||||||
TileRenderer.draw(tiles, tileCnt, curPos, matrices, mFaded);
|
TileRenderer.draw(tiles, tileCnt, pos, m, mFaded);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@ -88,18 +88,16 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
|
|||||||
|
|
||||||
// note: this is called from GL-Thread. so check your syncs!
|
// note: this is called from GL-Thread. so check your syncs!
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update(MapPosition curPos,
|
public synchronized void update(MapPosition pos, boolean changed, Matrices m) {
|
||||||
boolean positionChanged,
|
|
||||||
boolean tilesChanged, Matrices matrices) {
|
|
||||||
|
|
||||||
if (!positionChanged && !mUpdate)
|
if (!changed && !mUpdate)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
mUpdate = false;
|
mUpdate = false;
|
||||||
|
|
||||||
double mx = curPos.x;
|
double mx = pos.x;
|
||||||
double my = curPos.y;
|
double my = pos.y;
|
||||||
double scale = Tile.SIZE * curPos.scale;
|
double scale = Tile.SIZE * pos.scale;
|
||||||
|
|
||||||
int changesInvisible = 0;
|
int changesInvisible = 0;
|
||||||
int changedVisible = 0;
|
int changedVisible = 0;
|
||||||
@ -146,7 +144,7 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
|
|||||||
|
|
||||||
// keep position for current state
|
// keep position for current state
|
||||||
// updateMapPosition();
|
// updateMapPosition();
|
||||||
mMapPosition.copy(curPos);
|
mMapPosition.copy(pos);
|
||||||
|
|
||||||
layers.clear();
|
layers.clear();
|
||||||
|
|
||||||
|
|||||||
@ -69,13 +69,20 @@ public class PathOverlay extends Layer {
|
|||||||
mMapPoint = new PointD();
|
mMapPoint = new PointD();
|
||||||
MAX_SCALE = (1 << MAX_ZOOM) * Tile.SIZE;
|
MAX_SCALE = (1 << MAX_ZOOM) * Tile.SIZE;
|
||||||
}
|
}
|
||||||
|
private final int mCurX = -1;
|
||||||
|
private final int mCurY = -1;
|
||||||
|
private final int mCurZ = -1;
|
||||||
|
|
||||||
// note: this is called from GL-Thread. so check your syncs!
|
// note: this is called from GL-Thread. so check your syncs!
|
||||||
// TODO use an Overlay-Thread to build up layers (like for Labeling)
|
// TODO use an Overlay-Thread to build up layers (like for Labeling)
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update(MapPosition curPos,
|
public synchronized void update(MapPosition pos, boolean changed, Matrices m) {
|
||||||
boolean positionChanged,
|
int tz = 1 << pos.zoomLevel;
|
||||||
boolean tilesChanged, Matrices matrices) {
|
int tx = (int) (pos.x * tz);
|
||||||
|
int ty = (int) (pos.y * tz);
|
||||||
|
|
||||||
|
// update layers when map moved by at least one tile
|
||||||
|
boolean tilesChanged = (tx != mCurX || ty != mCurY || tz != mCurZ);
|
||||||
|
|
||||||
if (!tilesChanged && !mUpdatePoints)
|
if (!tilesChanged && !mUpdatePoints)
|
||||||
return;
|
return;
|
||||||
@ -122,13 +129,11 @@ public class PathOverlay extends Layer {
|
|||||||
// Hack: reset verticesCnt to reuse layer
|
// Hack: reset verticesCnt to reuse layer
|
||||||
ll.verticesCnt = 0;
|
ll.verticesCnt = 0;
|
||||||
|
|
||||||
int x, y, prevX, prevY;
|
int z = pos.zoomLevel;
|
||||||
|
|
||||||
int z = curPos.zoomLevel;
|
|
||||||
float div = FastMath.pow(z - MAX_ZOOM);
|
float div = FastMath.pow(z - MAX_ZOOM);
|
||||||
|
|
||||||
int mx = (int) (curPos.x * (Tile.SIZE << z));
|
int mx = (int) (pos.x * (Tile.SIZE << z));
|
||||||
int my = (int) (curPos.y * (Tile.SIZE << z));
|
int my = (int) (pos.y * (Tile.SIZE << z));
|
||||||
|
|
||||||
int j = 0;
|
int j = 0;
|
||||||
|
|
||||||
@ -136,8 +141,8 @@ public class PathOverlay extends Layer {
|
|||||||
int flip = 0;
|
int flip = 0;
|
||||||
int flipMax = Tile.SIZE << (z - 1);
|
int flipMax = Tile.SIZE << (z - 1);
|
||||||
|
|
||||||
x = (int)(mPreprojected[j++] * div) - mx;
|
int x = (int)(mPreprojected[j++] * div) - mx;
|
||||||
y = (int)(mPreprojected[j++] * div) - my;
|
int y = (int)(mPreprojected[j++] * div) - my;
|
||||||
|
|
||||||
if (x > flipMax) {
|
if (x > flipMax) {
|
||||||
x -= (flipMax * 2);
|
x -= (flipMax * 2);
|
||||||
@ -151,8 +156,8 @@ public class PathOverlay extends Layer {
|
|||||||
|
|
||||||
int i = addPoint(projected, 0, x, y);
|
int i = addPoint(projected, 0, x, y);
|
||||||
|
|
||||||
prevX = x;
|
int prevX = x;
|
||||||
prevY = y;
|
int prevY = y;
|
||||||
|
|
||||||
for (; j < size; j += 2) {
|
for (; j < size; j += 2) {
|
||||||
x = (int)(mPreprojected[j + 0] * div) - mx;
|
x = (int)(mPreprojected[j + 0] * div) - mx;
|
||||||
@ -206,7 +211,7 @@ public class PathOverlay extends Layer {
|
|||||||
ll.addLine(projected, i, false);
|
ll.addLine(projected, i, false);
|
||||||
|
|
||||||
// keep position to render relative to current state
|
// keep position to render relative to current state
|
||||||
mMapPosition.copy(curPos);
|
mMapPosition.copy(pos);
|
||||||
|
|
||||||
// items are placed relative to scale 1
|
// items are placed relative to scale 1
|
||||||
mMapPosition.scale = 1 << z;
|
mMapPosition.scale = 1 << z;
|
||||||
|
|||||||
@ -242,7 +242,6 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
| GLES20.GL_DEPTH_BUFFER_BIT
|
| GLES20.GL_DEPTH_BUFFER_BIT
|
||||||
| GLES20.GL_STENCIL_BUFFER_BIT);
|
| GLES20.GL_STENCIL_BUFFER_BIT);
|
||||||
|
|
||||||
boolean tilesChanged = false;
|
|
||||||
boolean positionChanged = false;
|
boolean positionChanged = false;
|
||||||
|
|
||||||
// get current MapPosition, set mBoxCoords (mapping of screen to model
|
// get current MapPosition, set mBoxCoords (mapping of screen to model
|
||||||
@ -269,7 +268,7 @@ public class GLRenderer implements GLSurfaceView.Renderer {
|
|||||||
RenderLayer[] overlays = mMapView.getLayerManager().getRenderLayers();
|
RenderLayer[] overlays = mMapView.getLayerManager().getRenderLayers();
|
||||||
|
|
||||||
for (int i = 0, n = overlays.length; i < n; i++)
|
for (int i = 0, n = overlays.length; i < n; i++)
|
||||||
overlays[i].update(mMapPosition, positionChanged, tilesChanged, mMatrices);
|
overlays[i].update(mMapPosition, positionChanged, mMatrices);
|
||||||
|
|
||||||
/* draw layers */
|
/* draw layers */
|
||||||
for (int i = 0, n = overlays.length; i < n; i++) {
|
for (int i = 0, n = overlays.length; i < n; i++) {
|
||||||
|
|||||||
@ -38,33 +38,30 @@ public abstract class RenderLayer {
|
|||||||
|
|
||||||
// /////////////// called from GLRender Thread ////////////////////////
|
// /////////////// called from GLRender Thread ////////////////////////
|
||||||
/**
|
/**
|
||||||
* called 1. by GLRenderer. Set 'newData' true when 'compile()' should be
|
* Called first by GLRenderer: Set 'newData' true when 'compile()' should be
|
||||||
* called
|
* called before next 'render()'
|
||||||
* before next 'render()'
|
|
||||||
*
|
*
|
||||||
* @param curPos TODO
|
* @param curPos TODO
|
||||||
* @param positionChanged
|
* @param positionChanged
|
||||||
* true when MapPosition has changed
|
* true when MapPosition has changed
|
||||||
* @param tilesChanged
|
|
||||||
* true when current tiles changed
|
|
||||||
* @param matrices TODO
|
* @param matrices TODO
|
||||||
*/
|
*/
|
||||||
public abstract void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged,
|
public abstract void update(MapPosition curPos, boolean positionChanged,
|
||||||
Matrices matrices);
|
Matrices matrices);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called 2. compile everything for drawing
|
* 2: Compile everything for drawing
|
||||||
* Set 'isReady' true when things are ready for 'render()'
|
* Set 'isReady' true when things are ready for 'render()'
|
||||||
*/
|
*/
|
||||||
public abstract void compile();
|
public abstract void compile();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* called 3. draw overlay
|
* 3: Draw layer
|
||||||
*
|
*
|
||||||
* @param pos
|
* @param pos
|
||||||
* current MapPosition
|
* Current MapPosition
|
||||||
* @param m
|
* @param m
|
||||||
* current render matrices + matrix for temporary use
|
* Current render matrices + matrix for temporary use
|
||||||
*/
|
*/
|
||||||
public abstract void render(MapPosition pos, Matrices m);
|
public abstract void render(MapPosition pos, Matrices m);
|
||||||
|
|
||||||
|
|||||||
@ -116,8 +116,7 @@ public class AtlasTest extends BasicOverlay {
|
|||||||
boolean initial = true;
|
boolean initial = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(MapPosition pos, boolean positionChanged,
|
public void update(MapPosition pos, boolean changed, Matrices m) {
|
||||||
boolean tilesChanged, Matrices m) {
|
|
||||||
|
|
||||||
if (initial) {
|
if (initial) {
|
||||||
mMapPosition.copy(pos);
|
mMapPosition.copy(pos);
|
||||||
|
|||||||
@ -55,7 +55,7 @@ public class CustomOverlay extends RenderLayer {
|
|||||||
|
|
||||||
// ---------- everything below runs in GLRender Thread ----------
|
// ---------- everything below runs in GLRender Thread ----------
|
||||||
@Override
|
@Override
|
||||||
public void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged, Matrices matrices) {
|
public void update(MapPosition pos, boolean changed, Matrices matrices) {
|
||||||
if (!mInitialized) {
|
if (!mInitialized) {
|
||||||
if (!init())
|
if (!init())
|
||||||
return;
|
return;
|
||||||
@ -66,7 +66,7 @@ public class CustomOverlay extends RenderLayer {
|
|||||||
newData = true;
|
newData = true;
|
||||||
|
|
||||||
// fix current MapPosition
|
// fix current MapPosition
|
||||||
mMapPosition.copy(curPos);
|
mMapPosition.copy(pos);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -21,13 +21,12 @@ import java.nio.ShortBuffer;
|
|||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.layers.tile.MapTile;
|
import org.oscim.layers.tile.MapTile;
|
||||||
import org.oscim.layers.tile.MapTile;
|
|
||||||
import org.oscim.layers.tile.TileRenderLayer;
|
import org.oscim.layers.tile.TileRenderLayer;
|
||||||
import org.oscim.layers.tile.TileSet;
|
import org.oscim.layers.tile.TileSet;
|
||||||
import org.oscim.renderer.GLRenderer;
|
import org.oscim.renderer.GLRenderer;
|
||||||
import org.oscim.renderer.RenderLayer;
|
|
||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
import org.oscim.renderer.GLRenderer.Matrices;
|
||||||
import org.oscim.renderer.GLState;
|
import org.oscim.renderer.GLState;
|
||||||
|
import org.oscim.renderer.RenderLayer;
|
||||||
import org.oscim.renderer.layer.ExtrusionLayer;
|
import org.oscim.renderer.layer.ExtrusionLayer;
|
||||||
import org.oscim.utils.GlUtils;
|
import org.oscim.utils.GlUtils;
|
||||||
import org.oscim.view.MapView;
|
import org.oscim.view.MapView;
|
||||||
@ -66,8 +65,7 @@ public class ExtrusionOverlay extends RenderLayer {
|
|||||||
private int mTileCnt;
|
private int mTileCnt;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void update(MapPosition curPos, boolean positionChanged,
|
public void update(MapPosition pos, boolean changed, Matrices matrices) {
|
||||||
boolean tilesChanged, Matrices matrices) {
|
|
||||||
|
|
||||||
mMapView.getMapViewPosition().getMapPosition(mMapPosition);
|
mMapView.getMapViewPosition().getMapPosition(mMapPosition);
|
||||||
|
|
||||||
@ -103,7 +101,7 @@ public class ExtrusionOverlay extends RenderLayer {
|
|||||||
|
|
||||||
MapTile[] tiles = mTileSet.tiles;
|
MapTile[] tiles = mTileSet.tiles;
|
||||||
// FIXME just release tiles in this case
|
// FIXME just release tiles in this case
|
||||||
if (mAlpha == 0 || curPos.zoomLevel < 16) {
|
if (mAlpha == 0 || pos.zoomLevel < 16) {
|
||||||
isReady = false;
|
isReady = false;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -113,7 +111,7 @@ public class ExtrusionOverlay extends RenderLayer {
|
|||||||
mTiles = new MapTile[mTileSet.cnt * 4];
|
mTiles = new MapTile[mTileSet.cnt * 4];
|
||||||
|
|
||||||
ExtrusionLayer el;
|
ExtrusionLayer el;
|
||||||
if (curPos.zoomLevel >= 17) {
|
if (pos.zoomLevel >= 17) {
|
||||||
for (int i = 0; i < mTileSet.cnt; i++) {
|
for (int i = 0; i < mTileSet.cnt; i++) {
|
||||||
if (!tiles[i].isVisible)
|
if (!tiles[i].isVisible)
|
||||||
continue;
|
continue;
|
||||||
@ -139,7 +137,7 @@ public class ExtrusionOverlay extends RenderLayer {
|
|||||||
if (el.compiled)
|
if (el.compiled)
|
||||||
mTiles[ready++] = tiles[i];
|
mTiles[ready++] = tiles[i];
|
||||||
}
|
}
|
||||||
} else if (curPos.zoomLevel == 16) {
|
} else if (pos.zoomLevel == 16) {
|
||||||
for (int i = 0; i < mTileSet.cnt; i++) {
|
for (int i = 0; i < mTileSet.cnt; i++) {
|
||||||
if (!tiles[i].isVisible)
|
if (!tiles[i].isVisible)
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
@ -104,8 +104,7 @@ public class GridOverlay extends BasicOverlay {
|
|||||||
private int mCurZ = -1;
|
private int mCurZ = -1;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update(MapPosition curPos, boolean positionChanged,
|
public synchronized void update(MapPosition curPos, boolean changed, Matrices m) {
|
||||||
boolean tilesChanged, Matrices matrices) {
|
|
||||||
|
|
||||||
int z = 1 << curPos.zoomLevel;
|
int z = 1 << curPos.zoomLevel;
|
||||||
int x = (int) (curPos.x * z);
|
int x = (int) (curPos.x * z);
|
||||||
|
|||||||
@ -122,7 +122,7 @@ public class TestOverlay extends BasicOverlay {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update(MapPosition curPos, boolean positionChanged,
|
public synchronized void update(MapPosition curPos, boolean positionChanged,
|
||||||
boolean tilesChanged, Matrices matrices) {
|
Matrices matrices) {
|
||||||
// keep position constant (or update layer relative to new position)
|
// keep position constant (or update layer relative to new position)
|
||||||
//mMapPosition.copy(curPos);
|
//mMapPosition.copy(curPos);
|
||||||
|
|
||||||
|
|||||||
@ -678,7 +678,7 @@ private final static String TAG = TextOverlay.class.getName();
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public synchronized void update(MapPosition curPos, boolean positionChanged,
|
public synchronized void update(MapPosition curPos, boolean positionChanged,
|
||||||
boolean tilesChanged, Matrices matrices) {
|
Matrices matrices) {
|
||||||
|
|
||||||
if (mNextLayer != null) {
|
if (mNextLayer != null) {
|
||||||
// keep text layer, not recrating its canvas each time
|
// keep text layer, not recrating its canvas each time
|
||||||
@ -703,7 +703,7 @@ private final static String TAG = TextOverlay.class.getName();
|
|||||||
|
|
||||||
this.newData = true;
|
this.newData = true;
|
||||||
|
|
||||||
if (!(positionChanged || tilesChanged))
|
if (!positionChanged)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@ -1,45 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013 Hannes Janetzek
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify it under the
|
|
||||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
|
||||||
* Foundation, either version 3 of the License, or (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
||||||
* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
|
|
||||||
* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Lesser General Public License along with
|
|
||||||
* this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
package org.oscim.renderer.overlays;
|
|
||||||
|
|
||||||
import org.oscim.core.MapPosition;
|
|
||||||
import org.oscim.renderer.RenderLayer;
|
|
||||||
import org.oscim.renderer.GLRenderer.Matrices;
|
|
||||||
import org.oscim.view.MapView;
|
|
||||||
|
|
||||||
public class ViewOverlay extends RenderLayer {
|
|
||||||
|
|
||||||
|
|
||||||
public ViewOverlay(MapView mapView) {
|
|
||||||
super(mapView);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged,
|
|
||||||
Matrices matrices) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void compile() {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void render(MapPosition pos, Matrices m) {
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
Loading…
x
Reference in New Issue
Block a user