cleanups + comments

This commit is contained in:
Hannes Janetzek 2013-02-06 11:06:47 +01:00
parent f2b7a9fdf8
commit fada95f380
11 changed files with 127 additions and 219 deletions

View File

@ -25,19 +25,23 @@ import org.oscim.utils.GlUtils;
import android.opengl.GLES20; import android.opengl.GLES20;
import android.opengl.Matrix; import android.opengl.Matrix;
import android.util.Log;
/** /**
* @author Hannes Janetzek * @author Hannes Janetzek
*/ */
public class BaseMap { public class BaseMap {
//private final static String TAG = BaseMap.class.getName(); private final static String TAG = BaseMap.class.getName();
private static float[] mMVPMatrix = new float[16];
private static float[] mVPMatrix = new float[16];
private static float[] mfProjMatrix = new float[16];
// used to increase polygon-offset for each tile drawn.
private static int mDrawCnt;
// used to not draw a tile twice per frame. // used to not draw a tile twice per frame.
private static int mDrawSerial = 0; private static int mDrawSerial = 0;
private static float[] mMVPMatrix = new float[16];
private static float[] mVPMatrix = new float[16];
private static float[] mfProjMatrix = new float[16];
static void setProjection(float[] projMatrix) { static void setProjection(float[] projMatrix) {
System.arraycopy(projMatrix, 0, mfProjMatrix, 0, 16); System.arraycopy(projMatrix, 0, mfProjMatrix, 0, 16);
@ -46,43 +50,45 @@ public class BaseMap {
mfProjMatrix[14] = 0; mfProjMatrix[14] = 0;
} }
private static int mDrawCnt;
static void draw(MapTile[] tiles, int tileCnt, MapPosition pos) { static void draw(MapTile[] tiles, int tileCnt, MapPosition pos) {
//long start = SystemClock.uptimeMillis();
Matrix.multiplyMM(mVPMatrix, 0, mfProjMatrix, 0, pos.viewMatrix, 0);
mDrawCnt = 0; mDrawCnt = 0;
Matrix.multiplyMM(mVPMatrix, 0, mfProjMatrix, 0, pos.viewMatrix, 0);
GLES20.glDepthFunc(GLES20.GL_LESS); GLES20.glDepthFunc(GLES20.GL_LESS);
// load texture for line caps
LineRenderer.beginLines(); LineRenderer.beginLines();
// Draw visible tiles
for (int i = 0; i < tileCnt; i++) { for (int i = 0; i < tileCnt; i++) {
MapTile t = tiles[i]; MapTile t = tiles[i];
if (t.isVisible && t.state == STATE_READY) if (t.isVisible && t.state == STATE_READY)
drawTile(t, pos); drawTile(t, pos);
} }
// proxies are clipped to the region where nothing was drawn to depth buffer. // Draw parent or children as proxy for visibile tiles that dont
// draw child or parent proxies. // have data yet. Proxies are clipped to the region where nothing
// TODO draw proxies for placeholder... // was drawn to depth buffer.
// TODO draw proxies for placeholder
for (int i = 0; i < tileCnt; i++) { for (int i = 0; i < tileCnt; i++) {
MapTile t = tiles[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))
drawProxyTile(t, pos, true); drawProxyTile(t, pos, true);
} }
// draw grandparents // Draw grandparents
for (int i = 0; i < tileCnt; i++) { for (int i = 0; i < tileCnt; i++) {
MapTile t = tiles[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))
drawProxyTile(t, pos, false); drawProxyTile(t, pos, false);
} }
LineRenderer.endLines(); // make sure stencil buffer write is disabled
glStencilMask(0x0); glStencilMask(0x00);
LineRenderer.endLines();
//long end = SystemClock.uptimeMillis();
//Log.d(TAG, "base took " + (end - start));
mDrawSerial++; mDrawSerial++;
} }
@ -93,23 +99,24 @@ public class BaseMap {
tile.lastDraw = mDrawSerial; tile.lastDraw = mDrawSerial;
float[] mvp = mMVPMatrix;
//setMatrix(mvp, tile, div, pos);
MapTile t = tile; MapTile t = tile;
if (t.holder != null) if (t.holder != null)
t = t.holder; t = t.holder;
if (t.layers == null || t.vbo == null) { if (t.layers == null || t.vbo == null) {
//Log.d(TAG, "missing data " + (t.layers == null) + " " + (t.vbo == null)); Log.d(TAG, "missing data " + (t.layers == null) + " " + (t.vbo == null));
return; return;
} }
// set Model matrix for tile
GLES20.glBindBuffer(GL_ARRAY_BUFFER, t.vbo.id);
// place tile relative to map position
float div = FastMath.pow(tile.zoomLevel - pos.zoomLevel); float div = FastMath.pow(tile.zoomLevel - pos.zoomLevel);
float x = (float) (tile.pixelX - pos.x * div); float x = (float) (tile.pixelX - pos.x * div);
float y = (float) (tile.pixelY - pos.y * div); float y = (float) (tile.pixelY - pos.y * div);
float scale = pos.scale / div; float scale = pos.scale / div;
float[] mvp = mMVPMatrix;
GlUtils.setTileMatrix(mvp, x, y, scale); GlUtils.setTileMatrix(mvp, x, y, scale);
// add view-projection matrix // add view-projection matrix
@ -120,12 +127,11 @@ public class BaseMap {
if (mDrawCnt > 20) if (mDrawCnt > 20)
mDrawCnt = 0; mDrawCnt = 0;
GLES20.glBindBuffer(GL_ARRAY_BUFFER, t.vbo.id);
boolean clipped = false;
// simple line shader does not take forward shortening into account // simple line shader does not take forward shortening into account
int simpleShader = (pos.tilt < 1 ? 1 : 0); int simpleShader = (pos.tilt < 1 ? 1 : 0);
boolean clipped = false;
for (Layer l = t.layers.layers; l != null;) { for (Layer l = t.layers.layers; l != null;) {
switch (l.type) { switch (l.type) {
case Layer.POLYGON: case Layer.POLYGON:

View File

@ -48,7 +48,6 @@ public final class BufferObject {
prev.next = bo.next; prev.next = bo.next;
bo.next = null; bo.next = null;
//Log.d(TAG, "requested: " + size + " got " + bo.size);
return bo; return bo;
} }
prev = bo; prev = bo;

View File

@ -42,12 +42,10 @@ public final class LineRenderer {
private final static String TAG = "LineRenderer"; private final static String TAG = "LineRenderer";
private static final int LINE_VERTICES_DATA_POS_OFFSET = 0; private static final int LINE_VERTICES_DATA_POS_OFFSET = 0;
//private static final int LINE_VERTICES_DATA_TEX_OFFSET = 4;
// shader handles // shader handles
private static int[] lineProgram = new int[2]; private static int[] lineProgram = new int[2];
private static int[] hLineVertexPosition = new int[2]; private static int[] hLineVertexPosition = new int[2];
//private static int[] hLineTexturePosition = new int[2];
private static int[] hLineColor = new int[2]; private static int[] hLineColor = new int[2];
private static int[] hLineMatrix = new int[2]; private static int[] hLineMatrix = new int[2];
private static int[] hLineScale = new int[2]; private static int[] hLineScale = new int[2];
@ -77,7 +75,6 @@ public final class LineRenderer {
hLineColor[i] = glGetUniformLocation(lineProgram[i], "u_color"); hLineColor[i] = glGetUniformLocation(lineProgram[i], "u_color");
hLineMode[i] = glGetUniformLocation(lineProgram[i], "u_mode"); hLineMode[i] = glGetUniformLocation(lineProgram[i], "u_mode");
hLineVertexPosition[i] = glGetAttribLocation(lineProgram[i], "a_pos"); hLineVertexPosition[i] = glGetAttribLocation(lineProgram[i], "a_pos");
//hLineTexturePosition[i] = glGetAttribLocation(lineProgram[i], "a_st");
} }
// create lookup table as texture for 'length(0..1,0..1)' // create lookup table as texture for 'length(0..1,0..1)'

View File

@ -21,36 +21,27 @@ import org.oscim.renderer.layer.TextItem;
public final class MapTile extends JobTile { public final class MapTile extends JobTile {
/** /**
* VBO layout: - 16 bytes fill coordinates, n bytes polygon vertices, m * VBO holds all vertex data to draw lines and polygons
* bytes lines vertices * layout:
* 16 bytes fill coordinates,
* n bytes polygon vertices,
* m bytes lines vertices
*/ */
BufferObject vbo; BufferObject vbo;
// TextTexture texture;
/** /**
* Tile data set by TileGenerator: * Tile data set by TileGenerator.
*/ */
public TextItem labels; public TextItem labels;
public Layers layers; public Layers layers;
/** /**
* tile has new data to upload to gl * Tile is in view region. Set by GLRenderer.
*/
//boolean newData;
/**
* tile is loaded and ready for drawing.
*/
//boolean isReady;
/**
* tile is in view region.
*/ */
public boolean isVisible; public boolean isVisible;
/** /**
* pointer to access relatives in QuadTree * Pointer to access relatives in QuadTree
*/ */
public QuadTree rel; public QuadTree rel;
@ -68,18 +59,20 @@ public final class MapTile extends JobTile {
public byte proxies; public byte proxies;
// check which labels were joined // check which labels were joined
public final static int JOIN_T = 1 << 0; // public final static int JOIN_T = 1 << 0;
public final static int JOIN_B = 1 << 1; // public final static int JOIN_B = 1 << 1;
public final static int JOIN_L = 1 << 2; // public final static int JOIN_L = 1 << 2;
public final static int JOIN_R = 1 << 3; // public final static int JOIN_R = 1 << 3;
public final static int JOINED = 15; // public final static int JOINED = 15;
public byte joined; // public byte joined;
// counting the tiles that use this tile as proxy // counting the tiles that use this tile as proxy
byte refs; byte refs;
// up to 255 Threads may lock a tile
byte locked; byte locked;
// used when this tile sits in fo another tile. // only used GLRenderer when this tile sits in for another tile.
// e.g. x:-1,y:0,z:1 for x:1,y:0 // e.g. x:-1,y:0,z:1 for x:1,y:0
MapTile holder; MapTile holder;

View File

@ -45,7 +45,7 @@ import org.oscim.utils.GlUtils;
import android.opengl.GLES20; import android.opengl.GLES20;
public final class PolygonRenderer { public final class PolygonRenderer {
private static final String TAG = PolygonRenderer.class.getName(); //private static final String TAG = PolygonRenderer.class.getName();
private static final int POLYGON_VERTICES_DATA_POS_OFFSET = 0; private static final int POLYGON_VERTICES_DATA_POS_OFFSET = 0;
private static final int STENCIL_BITS = 8; private static final int STENCIL_BITS = 8;
@ -374,31 +374,6 @@ public final class PolygonRenderer {
+ " gl_FragColor = u_color;" + " gl_FragColor = u_color;"
+ "}"; + "}";
private final static String polygonTexVertexShader = ""
+ "precision mediump float;"
+ "uniform mat4 u_mvp;"
+ "attribute vec4 a_pos;"
+ "varying vec2 v_st;"
+ "void main() {"
+ " if(gl_VertexID == 0)"
+ " v_st = vec2(0.0,0.0);"
+ " else if(gl_VertexID == 1)"
+ " v_st = vec2(1.0,0.0);"
+ " else if(gl_VertexID == 2)"
+ " v_st = vec2(1.0,1.0);"
+ " else if(gl_VertexID == 3)"
+ " v_st = vec2(0.0,1.0);"
+ " gl_Position = u_mvp * a_pos;"
+ "}";
private final static String polygonTexFragmentShader = ""
+ "precision mediump float;"
+ "uniform vec4 u_color;"
+ "uniform sampler2D tex;"
+ "varying vec2 v_st;"
+ "void main() {"
+ " gl_FragColor = u_color * texture2D(tex, v_st);"
+ "}";
private final static String polygonVertexShaderZ = "" private final static String polygonVertexShaderZ = ""
+ "precision highp float;" + "precision highp float;"
+ "uniform mat4 u_mvp;" + "uniform mat4 u_mvp;"
@ -422,4 +397,29 @@ public final class PolygonRenderer {
+ "else" + "else"
+ " gl_FragColor = vec4(0.0, z - 1.0, 0.0, 1.0)*0.8;" + " gl_FragColor = vec4(0.0, z - 1.0, 0.0, 1.0)*0.8;"
+ "}"; + "}";
// private final static String polygonTexVertexShader = ""
// + "precision mediump float;"
// + "uniform mat4 u_mvp;"
// + "attribute vec4 a_pos;"
// + "varying vec2 v_st;"
// + "void main() {"
// + " if(gl_VertexID == 0)"
// + " v_st = vec2(0.0,0.0);"
// + " else if(gl_VertexID == 1)"
// + " v_st = vec2(1.0,0.0);"
// + " else if(gl_VertexID == 2)"
// + " v_st = vec2(1.0,1.0);"
// + " else if(gl_VertexID == 3)"
// + " v_st = vec2(0.0,1.0);"
// + " gl_Position = u_mvp * a_pos;"
// + "}";
// private final static String polygonTexFragmentShader = ""
// + "precision mediump float;"
// + "uniform vec4 u_color;"
// + "uniform sampler2D tex;"
// + "varying vec2 v_st;"
// + "void main() {"
// + " gl_FragColor = u_color * texture2D(tex, v_st);"
// + "}";
} }

View File

@ -17,7 +17,7 @@ package org.oscim.renderer;
import android.util.Log; import android.util.Log;
public class QuadTree { public class QuadTree {
private static String TAG = "QuadTree"; private static String TAG = QuadTree.class.getName();
// pointer to tile 0/0/0 // pointer to tile 0/0/0
private static QuadTree root; private static QuadTree root;
@ -45,7 +45,7 @@ public class QuadTree {
static boolean remove(MapTile t) { static boolean remove(MapTile t) {
if (t.rel == null) { if (t.rel == null) {
// Bad Things(tm) happened // Bad Things(tm) happened
Log.d(TAG, "already removed " + t); Log.d(TAG, "BUG already removed " + t);
return true; return true;
} }

View File

@ -1,90 +0,0 @@
/*
* Copyright 2012 Hannes Janetzek
*
* This program is free software: you can redistribute it and/or modify it under the
* terms of the GNU Lesser General 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 License for more details.
*
* You should have received a copy of the GNU Lesser General License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/
package org.oscim.renderer;
public final class Shaders {
// final static String lineVertexZigZagShader = ""
// + "precision mediump float;"
// + "uniform mat4 mvp;"
// + "attribute vec4 a_pos1;"
// + "attribute vec2 a_st1;"
// + "attribute vec4 a_pos2;"
// + "attribute vec2 a_st2;"
// + "varying vec2 v_st;"
// + "uniform vec2 u_mode;"
// + "const float dscale = 1.0/1000.0;"
// + "void main() {"
// + "if (gl_VertexID & 1 == 0) {"
// + " vec2 dir = dscale * u_mode[1] * a_pos1.zw;"
// + " gl_Position = mvp * vec4(a_pos1.xy + dir, 0.0,1.0);"
// + " v_st = u_mode[1] * a_st1;"
// + "} else {"
// + " vec2 dir = dscale * u_mode[1] * a_pos2.zw;"
// + " gl_Position = mvp * vec4( a_pos1.xy, dir, 0.0,1.0);"
// + " v_st = u_mode[1] * vec2(-a_st2.s , a_st2.t);"
// + "}";
// final static String lineVertexShader = ""
// + "precision mediump float;"
// + "uniform mat4 mvp;"
// + "attribute vec4 a_position;"
// + "attribute vec2 a_st;"
// + "varying vec2 v_st;"
// + "uniform float u_width;"
// + "const float dscale = 8.0/1000.0;"
// + "void main() {"
// + " vec2 dir = dscale * u_width * a_position.zw;"
// + " gl_Position = mvp * vec4(a_position.xy + dir, 0.0,1.0);"
// + " v_st = u_width * a_st;"
// + "}";
// final static String lineFragmentShader = ""
// + "#extension GL_OES_standard_derivatives : enable\n"
// + "precision mediump float;"
// + "uniform float u_wscale;"
// + "uniform float u_width;"
// + "uniform int u_mode;"
// + "uniform vec4 u_color;"
// + "varying vec2 v_st;"
// + "void main() {"
// + " gl_FragColor = u_color * 0.5;"
// + "}";
// final static String buildingVertexShader = ""
// + "precision mediump float;"
// + "uniform mat4 u_mvp;"
// + "uniform vec4 u_color;"
// + "uniform int u_mode;"
// + "uniform float u_scale;"
// + "attribute vec4 a_position;"
// + "attribute float a_light;"
// + "varying vec4 color;"
// + "const float ff = 256.0;"
// + "const float ffff = 65536.0;"
// + "void main() {"
// + " gl_Position = u_mvp * vec4(a_position.xy, a_position.z/u_scale, 1.0);"
// + " if (u_mode == 0)"
// // roof / depth pass
// + " color = u_color;"
// + " else if (u_mode == 1)"
// // sides 1 - use 0xff00
// + " color = vec4(u_color.rgb * (a_light / ffff), 0.9);"
// + " else"
// // sides 2 - use 0x00ff
// + " color = vec4(u_color.rgb * fract(a_light/ff), 0.9);"
// + "}";
}

View File

@ -23,25 +23,32 @@ import android.opengl.GLUtils;
import android.util.Log; import android.util.Log;
public class TextureObject { public class TextureObject {
private final static String TAG = TextureObject.class.getName();
private static TextureObject pool; private static TextureObject pool;
private static int poolCount;
private static ArrayList<Bitmap> mBitmaps; private static ArrayList<Bitmap> mBitmaps;
// shared bitmap and canvas for default texture size
public final static int TEXTURE_WIDTH = 256; public final static int TEXTURE_WIDTH = 256;
public final static int TEXTURE_HEIGHT = 256; public final static int TEXTURE_HEIGHT = 256;
private static int mBitmapFormat; private static int mBitmapFormat;
private static int mBitmapType; private static int mBitmapType;
private static int objectCount = 10;
/**
* Get a TextureObject with Bitmap to draw to.
* 'uploadTexture()' uploads the Bitmap as texture.
*
* @return obtained TextureObject
*/
public static synchronized TextureObject get() { public static synchronized TextureObject get() {
TextureObject to; TextureObject to;
if (pool == null) { if (pool == null) {
objectCount += 1; poolCount += 1;
if (TextureRenderer.debug) if (TextureRenderer.debug)
Log.d("...", "textures: " + objectCount); Log.d(TAG, "textures: " + poolCount);
pool = new TextureObject(-1); pool = new TextureObject(-1);
} }
@ -54,7 +61,7 @@ public class TextureObject {
to.bitmap.eraseColor(Color.TRANSPARENT); to.bitmap.eraseColor(Color.TRANSPARENT);
if (TextureRenderer.debug) if (TextureRenderer.debug)
Log.d("...", "get texture " + to.id + " " + to.bitmap); Log.d(TAG, "get texture " + to.id + " " + to.bitmap);
return to; return to;
} }
@ -62,7 +69,7 @@ public class TextureObject {
public static synchronized void release(TextureObject to) { public static synchronized void release(TextureObject to) {
while (to != null) { while (to != null) {
if (TextureRenderer.debug) if (TextureRenderer.debug)
Log.d("...", "release texture " + to.id); Log.d(TAG, "release texture " + to.id);
TextureObject next = to.next; TextureObject next = to.next;
@ -78,9 +85,14 @@ public class TextureObject {
} }
} }
/**
* This function may only be used in GLRenderer Thread.
*
* @param to the TextureObjet to compile and upload
*/
public static synchronized void uploadTexture(TextureObject to) { public static synchronized void uploadTexture(TextureObject to) {
if (TextureRenderer.debug) if (TextureRenderer.debug)
Log.d("...", "upload texture " + to.id); Log.d(TAG, "upload texture " + to.id);
if (to.id < 0) { if (to.id < 0) {
int[] textureIds = new int[1]; int[] textureIds = new int[1];
@ -88,7 +100,7 @@ public class TextureObject {
to.id = textureIds[0]; to.id = textureIds[0];
initTexture(to.id); initTexture(to.id);
if (TextureRenderer.debug) if (TextureRenderer.debug)
Log.d("...", "new texture " + to.id); Log.d(TAG, "new texture " + to.id);
} }
uploadTexture(to, to.bitmap, mBitmapFormat, mBitmapType, uploadTexture(to, to.bitmap, mBitmapFormat, mBitmapType,
@ -102,7 +114,7 @@ public class TextureObject {
int format, int type, int w, int h) { int format, int type, int w, int h) {
if (to == null) { if (to == null) {
Log.d("...", "no texture!"); Log.d(TAG, "no texture!");
return; return;
} }
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, to.id); GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, to.id);
@ -130,15 +142,14 @@ public class TextureObject {
static void init(int num) { static void init(int num) {
pool = null; pool = null;
poolCount = num;
TextureObject to;
int[] textureIds = new int[num]; int[] textureIds = new int[num];
GLES20.glGenTextures(num, textureIds, 0); GLES20.glGenTextures(num, textureIds, 0);
for (int i = 1; i < num; i++) { for (int i = 1; i < num; i++) {
initTexture(textureIds[i]); initTexture(textureIds[i]);
to = new TextureObject(textureIds[i]); TextureObject to = new TextureObject(textureIds[i]);
to.next = pool; to.next = pool;
pool = to; pool = to;
@ -147,7 +158,8 @@ public class TextureObject {
mBitmaps = new ArrayList<Bitmap>(10); mBitmaps = new ArrayList<Bitmap>(10);
for (int i = 0; i < 4; i++) { for (int i = 0; i < 4; i++) {
Bitmap bitmap = Bitmap.createBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT, Bitmap bitmap = Bitmap.createBitmap(
TEXTURE_WIDTH, TEXTURE_HEIGHT,
Bitmap.Config.ARGB_8888); Bitmap.Config.ARGB_8888);
mBitmaps.add(bitmap); mBitmaps.add(bitmap);
@ -160,30 +172,31 @@ public class TextureObject {
private static Bitmap getBitmap() { private static Bitmap getBitmap() {
int size = mBitmaps.size(); int size = mBitmaps.size();
if (size == 0) { if (size == 0) {
for (int i = 0; i < 4; i++) { Bitmap bitmap = Bitmap.createBitmap(
Bitmap bitmap = Bitmap.createBitmap(TEXTURE_WIDTH, TEXTURE_HEIGHT, TEXTURE_WIDTH, TEXTURE_HEIGHT,
Bitmap.Config.ARGB_8888); Bitmap.Config.ARGB_8888);
mBitmaps.add(bitmap); return bitmap;
}
size = 4;
} }
return mBitmaps.remove(size - 1); return mBitmaps.remove(size - 1);
} }
// -----------------------
public TextureObject next; public TextureObject next;
public Bitmap bitmap; // texture ID
int id; int id;
int width; int width;
int height; int height;
// vertex offset from which this texture is referenced // vertex offset from which this texture is referenced
// or store texture id with vertex?
public short offset; public short offset;
public short vertices; public short vertices;
// temporary Bitmap
public Bitmap bitmap;
TextureObject(int id) { TextureObject(int id) {
this.id = id; this.id = id;
} }

View File

@ -17,7 +17,7 @@ package org.oscim.renderer.layer;
import android.util.Log; import android.util.Log;
public class VertexPool { public class VertexPool {
private static final int POOL_LIMIT = 6000; private static final int POOL_LIMIT = 5000;
static private VertexPoolItem pool = null; static private VertexPoolItem pool = null;
static private int count = 0; static private int count = 0;
@ -41,7 +41,7 @@ public class VertexPool {
public static synchronized VertexPoolItem get() { public static synchronized VertexPoolItem get() {
if (pool == null && count > 0) { if (pool == null && count > 0) {
Log.d("VertexPool", "XXX wrong count: " + count); Log.d("VertexPool", "BUG wrong count: " + count);
} }
if (pool == null) { if (pool == null) {
countAll++; countAll++;
@ -56,7 +56,7 @@ public class VertexPool {
for (VertexPoolItem tmp = pool; tmp != null; tmp = tmp.next) for (VertexPoolItem tmp = pool; tmp != null; tmp = tmp.next)
c++; c++;
Log.d("VertexPool", "XXX wrong count: " + count + " left" + c); Log.d("VertexPool", "BUG wrong count: " + count + " left" + c);
return new VertexPoolItem(); return new VertexPoolItem();
} }
@ -67,16 +67,10 @@ public class VertexPool {
return it; return it;
} }
// private static float load = 1.0f;
// private static int loadCount = 0;
public static synchronized void release(VertexPoolItem items) { public static synchronized void release(VertexPoolItem items) {
if (items == null) if (items == null)
return; return;
// int pall = countAll;
// int pcnt = count;
// limit pool items // limit pool items
if (countAll < POOL_LIMIT) { if (countAll < POOL_LIMIT) {
@ -84,8 +78,6 @@ public class VertexPool {
while (true) { while (true) {
count++; count++;
// load += (float) last.used / VertexPoolItem.SIZE;
// loadCount++;
if (last.next == null) if (last.next == null)
break; break;
@ -95,27 +87,17 @@ public class VertexPool {
last.next = pool; last.next = pool;
pool = items; pool = items;
// Log.d("Pool", "added: " + (count - pcnt) + " " + count + " " +
// countAll
// + " load: " + (load / loadCount));
} else { } else {
// int cleared = 0;
VertexPoolItem prev, tmp = items; VertexPoolItem prev, tmp = items;
while (tmp != null) { while (tmp != null) {
prev = tmp; prev = tmp;
tmp = tmp.next; tmp = tmp.next;
countAll--; countAll--;
// load += (float) prev.used / VertexPoolItem.SIZE;
// loadCount++;
prev.next = null; prev.next = null;
} }
// Log.d("Pool", "dropped: " + (pall - countAll) + " " + count + " "
// + countAll + " load: " + (load / loadCount));
} }
} }
} }

View File

@ -21,11 +21,18 @@ public class Point {
public float x; public float x;
public float y; public float y;
public Point() {
}
Point(float x, float y) { Point(float x, float y) {
this.x = x; this.x = x;
this.y = y; this.y = y;
} }
Point() { public void set(float x, float y) {
this.x = x;
this.y = y;
} }
} }

View File

@ -43,7 +43,7 @@ import android.util.Log;
public class MapViewPosition { public class MapViewPosition {
private static final String TAG = MapViewPosition.class.getSimpleName(); private static final String TAG = MapViewPosition.class.getName();
public final static int MAX_ZOOMLEVEL = 17; public final static int MAX_ZOOMLEVEL = 17;
public final static int MIN_ZOOMLEVEL = 2; public final static int MIN_ZOOMLEVEL = 2;
@ -315,7 +315,7 @@ public class MapViewPosition {
out.x = (int) (mPosX + mu[0] / mScale); out.x = (int) (mPosX + mu[0] / mScale);
out.y = (int) (mPosY + mu[1] / mScale); out.y = (int) (mPosY + mu[1] / mScale);
Log.d(">>>", "getScreenPointOnMap " + reuse); //Log.d(TAG, "getScreenPointOnMap " + reuse);
return out; return out;
} }
@ -340,7 +340,7 @@ public class MapViewPosition {
MercatorProjection.pixelYToLatitude(dy, mZoomLevel), MercatorProjection.pixelYToLatitude(dy, mZoomLevel),
MercatorProjection.pixelXToLongitude(dx, mZoomLevel)); MercatorProjection.pixelXToLongitude(dx, mZoomLevel));
Log.d(">>>", "fromScreenPixels " + p); //Log.d(TAG, "fromScreenPixels " + p);
return p; return p;
} }
@ -550,6 +550,7 @@ public class MapViewPosition {
*/ */
public synchronized void rotateMap(float angle, float cx, float cy) { public synchronized void rotateMap(float angle, float cx, float cy) {
moveMap(cx, cy); moveMap(cx, cy);
mRotation += angle; mRotation += angle;
updateMatrix(); updateMatrix();