remove tilesChanged parameter of RenderLayer.update as there is no more global tile layer

- fix PathOverlay update
This commit is contained in:
Hannes Janetzek 2013-04-28 06:04:56 +02:00
parent 28ecec811a
commit 8bea920253
12 changed files with 49 additions and 100 deletions

View File

@ -20,8 +20,8 @@ import static org.oscim.layers.tile.MapTile.STATE_READY;
import org.oscim.core.MapPosition;
import org.oscim.renderer.BufferObject;
import org.oscim.renderer.GLRenderer;
import org.oscim.renderer.RenderLayer;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.RenderLayer;
import org.oscim.utils.ScanBox;
import org.oscim.view.MapView;
@ -44,11 +44,10 @@ public class TileRenderLayer extends RenderLayer {
}
@Override
public void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged,
Matrices matrices) {
public void update(MapPosition pos, boolean positionChanged, Matrices m) {
int serial = 0;
mMapPosition.copy(curPos);
mMapPosition.copy(pos);
if (mDrawTiles != null)
serial = mDrawTiles.getSerial();
@ -85,9 +84,9 @@ public class TileRenderLayer extends RenderLayer {
/* prepare tile for rendering */
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

View File

@ -88,18 +88,16 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
// note: this is called from GL-Thread. so check your syncs!
@Override
public synchronized void update(MapPosition curPos,
boolean positionChanged,
boolean tilesChanged, Matrices matrices) {
public synchronized void update(MapPosition pos, boolean changed, Matrices m) {
if (!positionChanged && !mUpdate)
if (!changed && !mUpdate)
return;
mUpdate = false;
double mx = curPos.x;
double my = curPos.y;
double scale = Tile.SIZE * curPos.scale;
double mx = pos.x;
double my = pos.y;
double scale = Tile.SIZE * pos.scale;
int changesInvisible = 0;
int changedVisible = 0;
@ -146,7 +144,7 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
// keep position for current state
// updateMapPosition();
mMapPosition.copy(curPos);
mMapPosition.copy(pos);
layers.clear();

View File

@ -69,13 +69,20 @@ public class PathOverlay extends Layer {
mMapPoint = new PointD();
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!
// TODO use an Overlay-Thread to build up layers (like for Labeling)
@Override
public synchronized void update(MapPosition curPos,
boolean positionChanged,
boolean tilesChanged, Matrices matrices) {
public synchronized void update(MapPosition pos, boolean changed, Matrices m) {
int tz = 1 << pos.zoomLevel;
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)
return;
@ -122,13 +129,11 @@ public class PathOverlay extends Layer {
// Hack: reset verticesCnt to reuse layer
ll.verticesCnt = 0;
int x, y, prevX, prevY;
int z = curPos.zoomLevel;
int z = pos.zoomLevel;
float div = FastMath.pow(z - MAX_ZOOM);
int mx = (int) (curPos.x * (Tile.SIZE << z));
int my = (int) (curPos.y * (Tile.SIZE << z));
int mx = (int) (pos.x * (Tile.SIZE << z));
int my = (int) (pos.y * (Tile.SIZE << z));
int j = 0;
@ -136,8 +141,8 @@ public class PathOverlay extends Layer {
int flip = 0;
int flipMax = Tile.SIZE << (z - 1);
x = (int)(mPreprojected[j++] * div) - mx;
y = (int)(mPreprojected[j++] * div) - my;
int x = (int)(mPreprojected[j++] * div) - mx;
int y = (int)(mPreprojected[j++] * div) - my;
if (x > flipMax) {
x -= (flipMax * 2);
@ -151,8 +156,8 @@ public class PathOverlay extends Layer {
int i = addPoint(projected, 0, x, y);
prevX = x;
prevY = y;
int prevX = x;
int prevY = y;
for (; j < size; j += 2) {
x = (int)(mPreprojected[j + 0] * div) - mx;
@ -206,7 +211,7 @@ public class PathOverlay extends Layer {
ll.addLine(projected, i, false);
// keep position to render relative to current state
mMapPosition.copy(curPos);
mMapPosition.copy(pos);
// items are placed relative to scale 1
mMapPosition.scale = 1 << z;

View File

@ -242,7 +242,6 @@ public class GLRenderer implements GLSurfaceView.Renderer {
| GLES20.GL_DEPTH_BUFFER_BIT
| GLES20.GL_STENCIL_BUFFER_BIT);
boolean tilesChanged = false;
boolean positionChanged = false;
// 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();
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 */
for (int i = 0, n = overlays.length; i < n; i++) {

View File

@ -38,33 +38,30 @@ public abstract class RenderLayer {
// /////////////// called from GLRender Thread ////////////////////////
/**
* called 1. by GLRenderer. Set 'newData' true when 'compile()' should be
* called
* before next 'render()'
* Called first by GLRenderer: Set 'newData' true when 'compile()' should be
* called before next 'render()'
*
* @param curPos TODO
* @param positionChanged
* true when MapPosition has changed
* @param tilesChanged
* true when current tiles changed
* @param matrices TODO
*/
public abstract void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged,
public abstract void update(MapPosition curPos, boolean positionChanged,
Matrices matrices);
/**
* called 2. compile everything for drawing
* 2: Compile everything for drawing
* Set 'isReady' true when things are ready for 'render()'
*/
public abstract void compile();
/**
* called 3. draw overlay
* 3: Draw layer
*
* @param pos
* current MapPosition
* Current MapPosition
* @param m
* current render matrices + matrix for temporary use
* Current render matrices + matrix for temporary use
*/
public abstract void render(MapPosition pos, Matrices m);

View File

@ -116,8 +116,7 @@ public class AtlasTest extends BasicOverlay {
boolean initial = true;
@Override
public void update(MapPosition pos, boolean positionChanged,
boolean tilesChanged, Matrices m) {
public void update(MapPosition pos, boolean changed, Matrices m) {
if (initial) {
mMapPosition.copy(pos);

View File

@ -55,7 +55,7 @@ public class CustomOverlay extends RenderLayer {
// ---------- everything below runs in GLRender Thread ----------
@Override
public void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged, Matrices matrices) {
public void update(MapPosition pos, boolean changed, Matrices matrices) {
if (!mInitialized) {
if (!init())
return;
@ -66,7 +66,7 @@ public class CustomOverlay extends RenderLayer {
newData = true;
// fix current MapPosition
mMapPosition.copy(curPos);
mMapPosition.copy(pos);
}
}

View File

@ -21,13 +21,12 @@ import java.nio.ShortBuffer;
import org.oscim.core.MapPosition;
import org.oscim.core.Tile;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.MapTile;
import org.oscim.layers.tile.TileRenderLayer;
import org.oscim.layers.tile.TileSet;
import org.oscim.renderer.GLRenderer;
import org.oscim.renderer.RenderLayer;
import org.oscim.renderer.GLRenderer.Matrices;
import org.oscim.renderer.GLState;
import org.oscim.renderer.RenderLayer;
import org.oscim.renderer.layer.ExtrusionLayer;
import org.oscim.utils.GlUtils;
import org.oscim.view.MapView;
@ -66,8 +65,7 @@ public class ExtrusionOverlay extends RenderLayer {
private int mTileCnt;
@Override
public void update(MapPosition curPos, boolean positionChanged,
boolean tilesChanged, Matrices matrices) {
public void update(MapPosition pos, boolean changed, Matrices matrices) {
mMapView.getMapViewPosition().getMapPosition(mMapPosition);
@ -103,7 +101,7 @@ public class ExtrusionOverlay extends RenderLayer {
MapTile[] tiles = mTileSet.tiles;
// FIXME just release tiles in this case
if (mAlpha == 0 || curPos.zoomLevel < 16) {
if (mAlpha == 0 || pos.zoomLevel < 16) {
isReady = false;
return;
}
@ -113,7 +111,7 @@ public class ExtrusionOverlay extends RenderLayer {
mTiles = new MapTile[mTileSet.cnt * 4];
ExtrusionLayer el;
if (curPos.zoomLevel >= 17) {
if (pos.zoomLevel >= 17) {
for (int i = 0; i < mTileSet.cnt; i++) {
if (!tiles[i].isVisible)
continue;
@ -139,7 +137,7 @@ public class ExtrusionOverlay extends RenderLayer {
if (el.compiled)
mTiles[ready++] = tiles[i];
}
} else if (curPos.zoomLevel == 16) {
} else if (pos.zoomLevel == 16) {
for (int i = 0; i < mTileSet.cnt; i++) {
if (!tiles[i].isVisible)
continue;

View File

@ -104,8 +104,7 @@ public class GridOverlay extends BasicOverlay {
private int mCurZ = -1;
@Override
public synchronized void update(MapPosition curPos, boolean positionChanged,
boolean tilesChanged, Matrices matrices) {
public synchronized void update(MapPosition curPos, boolean changed, Matrices m) {
int z = 1 << curPos.zoomLevel;
int x = (int) (curPos.x * z);

View File

@ -122,7 +122,7 @@ public class TestOverlay extends BasicOverlay {
@Override
public synchronized void update(MapPosition curPos, boolean positionChanged,
boolean tilesChanged, Matrices matrices) {
Matrices matrices) {
// keep position constant (or update layer relative to new position)
//mMapPosition.copy(curPos);

View File

@ -678,7 +678,7 @@ private final static String TAG = TextOverlay.class.getName();
@Override
public synchronized void update(MapPosition curPos, boolean positionChanged,
boolean tilesChanged, Matrices matrices) {
Matrices matrices) {
if (mNextLayer != null) {
// keep text layer, not recrating its canvas each time
@ -703,7 +703,7 @@ private final static String TAG = TextOverlay.class.getName();
this.newData = true;
if (!(positionChanged || tilesChanged))
if (!positionChanged)
return;
}

View File

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