add base layer 'faded' option for MapLens

This commit is contained in:
Hannes Janetzek 2013-04-23 22:39:41 +02:00
parent 54035374bd
commit b92d939dfb
2 changed files with 19 additions and 9 deletions

View File

@ -37,6 +37,12 @@ public class TileRenderLayer extends RenderOverlay {
mBoxCoords = new float[8];
}
boolean mFaded;
public void setFaded(boolean faded){
mFaded = faded;
}
@Override
public void update(MapPosition curPos, boolean positionChanged, boolean tilesChanged,
Matrices matrices) {
@ -81,7 +87,7 @@ public class TileRenderLayer extends RenderOverlay {
tilesChanged |= (uploadCnt > 0);
TileRenderer.draw(tiles, tileCnt, curPos, matrices);
TileRenderer.draw(tiles, tileCnt, curPos, matrices, mFaded);
}
@Override

View File

@ -50,12 +50,14 @@ public class TileRenderer {
private static int mDrawSerial = 0;
private static Matrices mMatrices;
private static boolean mFaded;
private static final Matrix4 mProjMatrix = new Matrix4();
static void draw(MapTile[] tiles, int tileCnt, MapPosition pos, Matrices m) {
static void draw(MapTile[] tiles, int tileCnt, MapPosition pos, Matrices m, boolean fade) {
mDrawCnt = 0;
mMatrices = m;
mFaded = fade;
mProjMatrix.copy(m.viewproj);
// discard z projection from tilt
@ -76,7 +78,7 @@ public class TileRenderer {
drawTile(t, pos);
}
double scale = pos.getZoomScale();
double scale = pos.getZoomScale();
// Draw parent or children as proxy for visibile tiles that dont
// have data yet. Proxies are clipped to the region where nothing
@ -84,7 +86,7 @@ public class TileRenderer {
// TODO draw proxies for placeholder
for (int i = 0; i < tileCnt; i++) {
MapTile t = tiles[i];
if (t.isVisible && (t.state != STATE_READY) && (t.holder == null)){
if (t.isVisible && (t.state != STATE_READY) && (t.holder == null)) {
boolean preferParent = (scale > 1.5) || (pos.zoomLevel - t.zoomLevel < 0);
drawProxyTile(t, pos, true, preferParent);
}
@ -108,7 +110,6 @@ public class TileRenderer {
mMatrices = null;
}
private static void drawTile(MapTile tile, MapPosition pos) {
// draw parents only once
if (tile.lastDraw == mDrawSerial)
@ -139,7 +140,7 @@ public class TileRenderer {
float y = (float) ((tile.y - pos.y) * curScale);
Matrices m = mMatrices;
m.mvp.setTransScale(x, y, (float)(scale / GLRenderer.COORD_SCALE));
m.mvp.setTransScale(x, y, (float) (scale / GLRenderer.COORD_SCALE));
m.mvp.multiplyMM(mProjMatrix, m.mvp);
@ -185,8 +186,10 @@ public class TileRenderer {
}
// clear clip-region and could also draw 'fade-effect'
//PolygonRenderer.drawOver(m, true, 0x22000000);
PolygonRenderer.drawOver(m, false, 0);
if (mFaded)
PolygonRenderer.drawOver(m, true, 0x22000000);
else
PolygonRenderer.drawOver(m, false, 0);
}
private static int drawProxyChild(MapTile tile, MapPosition pos) {
@ -206,7 +209,8 @@ public class TileRenderer {
}
// just FIXME!
private static void drawProxyTile(MapTile tile, MapPosition pos, boolean parent, boolean preferParent) {
private static void drawProxyTile(MapTile tile, MapPosition pos, boolean parent,
boolean preferParent) {
QuadTree<MapTile> r = tile.rel;
MapTile proxy;