refactor: RenderLayer does not need to hold reference to MapView
This commit is contained in:
parent
9f5a89b610
commit
07db32f394
@ -107,7 +107,7 @@ public class GdxMap implements ApplicationListener {
|
||||
|
||||
if (tileGrid)
|
||||
mMapView.getLayerManager().add(new GenericOverlay(mMapView,
|
||||
new GridRenderLayer(mMapView)));
|
||||
new GridRenderLayer()));
|
||||
}
|
||||
|
||||
// Stage ui;
|
||||
@ -276,7 +276,7 @@ public class GdxMap implements ApplicationListener {
|
||||
|
||||
case Input.Keys.G:
|
||||
if (mGridLayer == null) {
|
||||
mGridLayer = new GenericOverlay(mMapView, new GridRenderLayer(mMapView));
|
||||
mGridLayer = new GenericOverlay(mMapView, new GridRenderLayer());
|
||||
mGridLayer.setEnabled(true);
|
||||
mMapView.getLayerManager().add(mGridLayer);
|
||||
} else {
|
||||
|
@ -131,10 +131,10 @@ class TextRenderLayer extends BasicRenderLayer {
|
||||
private float mSquareRadius;
|
||||
private int mRelabelCnt;
|
||||
private final TileRenderLayer mTileLayer;
|
||||
private final MapView mMapView;
|
||||
|
||||
public TextRenderLayer(MapView mapView, TileRenderLayer baseLayer) {
|
||||
super(mapView);
|
||||
|
||||
mMapView = mapView;
|
||||
mMapViewPosition = mapView.getMapViewPosition();
|
||||
mTileLayer = baseLayer;
|
||||
mTileSet = new TileSet();
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
package org.oscim.layers.overlay;
|
||||
|
||||
import org.oscim.backend.Log;
|
||||
import org.oscim.backend.input.MotionEvent;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.renderer.GLRenderer.Matrices;
|
||||
@ -22,19 +21,17 @@ import org.oscim.renderer.layers.ExtrusionRenderLayer;
|
||||
import org.oscim.utils.FastMath;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
//import android.os.CountDownTimer;
|
||||
|
||||
/**
|
||||
* @author Hannes Janetzek
|
||||
*/
|
||||
public class BuildingOverlay extends Overlay {
|
||||
private final static String TAG = BuildingOverlay.class.getName();
|
||||
//private final static String TAG = BuildingOverlay.class.getName();
|
||||
|
||||
final ExtrusionRenderLayer mExtLayer;
|
||||
|
||||
public BuildingOverlay(MapView mapView, org.oscim.layers.tile.TileRenderLayer tileRenderLayer) {
|
||||
super(mapView);
|
||||
mExtLayer = new ExtrusionRenderLayer(mapView, tileRenderLayer) {
|
||||
mExtLayer = new ExtrusionRenderLayer(tileRenderLayer) {
|
||||
private long mStartTime;
|
||||
|
||||
@Override
|
||||
|
@ -77,8 +77,7 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
|
||||
private final SymbolLayer mSymbolLayer;
|
||||
private final float[] mBox = new float[8];
|
||||
|
||||
public ItemOverlay(MapView mapView) {
|
||||
super(mapView);
|
||||
public ItemOverlay() {
|
||||
mSymbolLayer = new SymbolLayer();
|
||||
}
|
||||
|
||||
@ -221,7 +220,7 @@ public abstract class ItemizedOverlay<Item extends OverlayItem> extends Overlay
|
||||
|
||||
//this.mDefaultMarker = OverlayMarker.makeMarker(pDefaultMarker, null);
|
||||
mDefaultMarker = defaultMarker;
|
||||
mLayer = new ItemOverlay(mapView);
|
||||
mLayer = new ItemOverlay();
|
||||
}
|
||||
|
||||
private final PointD mMapPoint = new PointD();
|
||||
|
@ -58,8 +58,7 @@ public class PathOverlay extends Layer {
|
||||
// limit coords
|
||||
private final int max = 2048;
|
||||
|
||||
public RenderPath(MapView mapView) {
|
||||
super(mapView);
|
||||
public RenderPath() {
|
||||
mClipper = new LineClipper(-max, -max, max, max, true);
|
||||
mPPoints = new float[1];
|
||||
layers.addLineLayer(0, mLineStyle);
|
||||
@ -242,7 +241,7 @@ public class PathOverlay extends Layer {
|
||||
|
||||
this.mPoints = new ArrayList<GeoPoint>();
|
||||
|
||||
mLayer = new RenderPath(mapView);
|
||||
mLayer = new RenderPath();
|
||||
}
|
||||
|
||||
public PathOverlay(MapView mapView, int lineColor) {
|
||||
|
@ -55,7 +55,7 @@ public abstract class TileLayer<T extends TileLoader> extends Layer {
|
||||
|
||||
// RenderLayer is working in GL Thread and actually
|
||||
// drawing loaded tiles to screen.
|
||||
mLayer = mRenderLayer = new TileRenderLayer(mapView, mTileManager);
|
||||
mLayer = mRenderLayer = new TileRenderLayer(mTileManager);
|
||||
}
|
||||
|
||||
abstract protected T createLoader(TileManager tm);
|
||||
|
@ -25,7 +25,6 @@ import org.oscim.renderer.GLRenderer;
|
||||
import org.oscim.renderer.GLRenderer.Matrices;
|
||||
import org.oscim.renderer.RenderLayer;
|
||||
import org.oscim.utils.ScanBox;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
public class TileRenderLayer extends RenderLayer {
|
||||
private final static String TAG = TileRenderLayer.class.getName();
|
||||
@ -33,8 +32,7 @@ public class TileRenderLayer extends RenderLayer {
|
||||
private final TileManager mTileManager;
|
||||
private int mUploadSerial;
|
||||
|
||||
public TileRenderLayer(MapView mapView, TileManager tileManager) {
|
||||
super(mapView);
|
||||
public TileRenderLayer(TileManager tileManager) {
|
||||
mTileManager = tileManager;
|
||||
mUploadSerial = 0;
|
||||
}
|
||||
|
@ -14,14 +14,12 @@
|
||||
*/
|
||||
package org.oscim.renderer;
|
||||
|
||||
import org.oscim.view.MapView;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.renderer.GLRenderer.Matrices;
|
||||
|
||||
public abstract class RenderLayer {
|
||||
|
||||
protected final MapView mMapView;
|
||||
/**
|
||||
* Use mMapPosition.copy(position) to keep the position for which
|
||||
* the Overlay is _compiled_. NOTE: required by setMatrix utility
|
||||
@ -35,8 +33,7 @@ public abstract class RenderLayer {
|
||||
/** flag to set when layer is ready for rendering */
|
||||
public boolean isReady;
|
||||
|
||||
public RenderLayer(MapView mapView) {
|
||||
mMapView = mapView;
|
||||
public RenderLayer() {
|
||||
mMapPosition = new MapPosition();
|
||||
}
|
||||
|
||||
|
@ -29,7 +29,6 @@ import org.oscim.renderer.sublayers.LineTexRenderer;
|
||||
import org.oscim.renderer.sublayers.PolygonRenderer;
|
||||
import org.oscim.renderer.sublayers.TextureRenderer;
|
||||
import org.oscim.utils.FastMath;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
/**
|
||||
* Base class to use the renderer.sublayers for drawing
|
||||
@ -38,8 +37,7 @@ public abstract class BasicRenderLayer extends RenderLayer {
|
||||
|
||||
public final Layers layers;
|
||||
|
||||
public BasicRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
public BasicRenderLayer() {
|
||||
layers = new Layers();
|
||||
}
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
package org.oscim.renderer.layers;
|
||||
|
||||
import org.oscim.view.MapView;
|
||||
import org.oscim.backend.canvas.Bitmap;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.renderer.GLRenderer.Matrices;
|
||||
@ -36,10 +35,6 @@ public class BitmapRenderLayer extends BasicRenderLayer {
|
||||
private boolean initialized;
|
||||
private boolean mUpdateBitmap;
|
||||
|
||||
public BitmapRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param bitmap
|
||||
* with dimension being power of two
|
||||
|
@ -39,6 +39,8 @@ public class CustomRenderLayer extends RenderLayer {
|
||||
|
||||
private static final GL20 GL = GLAdapter.get();
|
||||
|
||||
private final MapView mMapView;
|
||||
|
||||
private int mProgramObject;
|
||||
private int hVertexPosition;
|
||||
private int hMatrixPosition;
|
||||
@ -53,7 +55,7 @@ public class CustomRenderLayer extends RenderLayer {
|
||||
private boolean mInitialized;
|
||||
|
||||
public CustomRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
mMapView = mapView;
|
||||
}
|
||||
|
||||
// ---------- everything below runs in GLRender Thread ----------
|
||||
|
@ -27,7 +27,6 @@ import org.oscim.renderer.GLState;
|
||||
import org.oscim.renderer.RenderLayer;
|
||||
import org.oscim.utils.FastMath;
|
||||
import org.oscim.utils.GlUtils;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
|
||||
/*
|
||||
@ -51,10 +50,6 @@ public class CustomRenderLayer2 extends RenderLayer {
|
||||
private boolean mInitialized;
|
||||
private BufferObject mVBO;
|
||||
|
||||
public CustomRenderLayer2(MapView mapView) {
|
||||
super(mapView);
|
||||
}
|
||||
|
||||
int mZoom = -1;
|
||||
float mCellScale = 60 * GLRenderer.COORD_SCALE;
|
||||
|
||||
|
@ -28,7 +28,6 @@ import org.oscim.renderer.GLState;
|
||||
import org.oscim.renderer.RenderLayer;
|
||||
import org.oscim.renderer.sublayers.ExtrusionLayer;
|
||||
import org.oscim.utils.GlUtils;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
public class ExtrusionRenderLayer extends RenderLayer {
|
||||
private final static String TAG = ExtrusionRenderLayer.class.getName();
|
||||
@ -39,9 +38,7 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
||||
|
||||
protected float mAlpha = 1;
|
||||
|
||||
public ExtrusionRenderLayer(MapView mapView,
|
||||
org.oscim.layers.tile.TileRenderLayer tileRenderLayer) {
|
||||
super(mapView);
|
||||
public ExtrusionRenderLayer(TileRenderLayer tileRenderLayer) {
|
||||
mTileLayer = tileRenderLayer;
|
||||
mTileSet = new TileSet();
|
||||
}
|
||||
@ -92,8 +89,7 @@ public class ExtrusionRenderLayer extends RenderLayer {
|
||||
|
||||
@Override
|
||||
public void update(MapPosition pos, boolean changed, Matrices matrices) {
|
||||
|
||||
mMapView.getMapViewPosition().getMapPosition(mMapPosition);
|
||||
mMapPosition.copy(pos);
|
||||
|
||||
if (!initialized && !initShader())
|
||||
return;
|
||||
|
@ -25,7 +25,6 @@ import org.oscim.renderer.sublayers.TextItem;
|
||||
import org.oscim.renderer.sublayers.TextLayer;
|
||||
import org.oscim.theme.renderinstruction.Line;
|
||||
import org.oscim.theme.renderinstruction.Text;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
public class GridRenderLayer extends BasicRenderLayer {
|
||||
// private final static String TILE_FORMAT = "%d/%d/%d";
|
||||
@ -38,8 +37,7 @@ public class GridRenderLayer extends BasicRenderLayer {
|
||||
|
||||
private int mCurX, mCurY, mCurZ;
|
||||
|
||||
public GridRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
public GridRenderLayer() {
|
||||
|
||||
int size = Tile.SIZE;
|
||||
|
||||
|
@ -157,10 +157,10 @@ public class TextRenderLayer extends BasicRenderLayer {
|
||||
private float mSquareRadius;
|
||||
private int mRelabelCnt;
|
||||
private final TileRenderLayer mTileLayer;
|
||||
private final MapView mMapView;
|
||||
|
||||
public TextRenderLayer(MapView mapView, TileRenderLayer baseLayer) {
|
||||
super(mapView);
|
||||
|
||||
mMapView = mapView;
|
||||
mMapViewPosition = mapView.getMapViewPosition();
|
||||
mTileLayer = baseLayer;
|
||||
mTileSet = new TileSet();
|
||||
|
@ -2,7 +2,7 @@ package org.oscim.renderer.layers.test;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
import org.oscim.view.MapView;
|
||||
import org.oscim.backend.Log;
|
||||
import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.backend.canvas.Paint.Cap;
|
||||
import org.oscim.core.MapPosition;
|
||||
@ -17,12 +17,9 @@ import org.oscim.renderer.sublayers.TextLayer;
|
||||
import org.oscim.theme.renderinstruction.Line;
|
||||
import org.oscim.theme.renderinstruction.Text;
|
||||
|
||||
import org.oscim.backend.Log;
|
||||
|
||||
public class AtlasRenderLayer extends BasicRenderLayer {
|
||||
|
||||
public AtlasRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
public AtlasRenderLayer() {
|
||||
|
||||
TextureAtlas mAtlas = TextureAtlas.create(2048, 2048, 1);
|
||||
|
||||
|
@ -18,13 +18,8 @@ package org.oscim.renderer.layers.test;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.renderer.GLRenderer.Matrices;
|
||||
import org.oscim.renderer.RenderLayer;
|
||||
import org.oscim.view.MapView;
|
||||
public class ModelRenderLayer extends RenderLayer{
|
||||
|
||||
public ModelRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(MapPosition pos, boolean changed, Matrices m) {
|
||||
}
|
||||
|
@ -22,13 +22,11 @@ import org.oscim.renderer.GLRenderer.Matrices;
|
||||
import org.oscim.renderer.layers.BasicRenderLayer;
|
||||
import org.oscim.renderer.sublayers.SymbolItem;
|
||||
import org.oscim.renderer.sublayers.SymbolLayer;
|
||||
import org.oscim.view.MapView;
|
||||
|
||||
public class SymbolRenderLayer extends BasicRenderLayer {
|
||||
boolean initialize = true;
|
||||
|
||||
public SymbolRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
public SymbolRenderLayer() {
|
||||
SymbolLayer l = new SymbolLayer();
|
||||
layers.textureLayers = l;
|
||||
|
||||
|
@ -14,7 +14,6 @@
|
||||
*/
|
||||
package org.oscim.renderer.layers.test;
|
||||
|
||||
import org.oscim.view.MapView;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.renderer.GLRenderer.Matrices;
|
||||
import org.oscim.renderer.layers.BasicRenderLayer;
|
||||
@ -28,8 +27,7 @@ public class TestRenderLayer extends BasicRenderLayer {
|
||||
|
||||
private boolean first = true;
|
||||
|
||||
public TestRenderLayer(MapView mapView) {
|
||||
super(mapView);
|
||||
public TestRenderLayer() {
|
||||
|
||||
// draw a rectangle
|
||||
//LineLayer ll = (LineLayer) layers.getLayer(1, Layer.LINE);
|
||||
|
Loading…
x
Reference in New Issue
Block a user