workaround OpenJDK quirks - bytecode missing an implicit cast

This commit is contained in:
Hannes Janetzek 2013-11-30 05:55:36 +01:00
parent ae414292c1
commit 4eae1575a3
6 changed files with 48 additions and 44 deletions

View File

@ -18,8 +18,6 @@ import java.nio.ShortBuffer;
import org.oscim.backend.GL20; import org.oscim.backend.GL20;
import org.oscim.backend.GLAdapter; import org.oscim.backend.GLAdapter;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.oscim.backend.canvas.Paint.Cap; import org.oscim.backend.canvas.Paint.Cap;
import org.oscim.core.GeometryBuffer; import org.oscim.core.GeometryBuffer;
import org.oscim.core.MapPosition; import org.oscim.core.MapPosition;
@ -30,6 +28,8 @@ import org.oscim.renderer.MapRenderer;
import org.oscim.renderer.MapRenderer.Matrices; import org.oscim.renderer.MapRenderer.Matrices;
import org.oscim.theme.renderinstruction.Line; import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.FastMath; import org.oscim.utils.FastMath;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/** /**
*/ */
@ -109,8 +109,10 @@ public final class LineLayer extends RenderElement {
else if (line.cap == Cap.SQUARE) else if (line.cap == Cap.SQUARE)
squared = true; squared = true;
if (vertexItems == null) if (vertexItems == null) {
curItem = vertexItems = VertexItem.pool.get(); vertexItems = VertexItem.pool.get();
curItem = vertexItems;
}
VertexItem si = curItem; VertexItem si = curItem;
short v[] = si.vertices; short v[] = si.vertices;
@ -204,7 +206,7 @@ public final class LineLayer extends RenderElement {
boolean outside = (x < tmin || x > tmax || y < tmin || y > tmax); boolean outside = (x < tmin || x > tmax || y < tmin || y > tmax);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -222,7 +224,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = dy; v[opos++] = dy;
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -233,7 +235,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = dy; v[opos++] = dy;
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -247,7 +249,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = (short) (2 | ddy & DIR_MASK); v[opos++] = (short) (2 | ddy & DIR_MASK);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -262,7 +264,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = (short) (1 | ddy & DIR_MASK); v[opos++] = (short) (1 | ddy & DIR_MASK);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -302,7 +304,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = dy; v[opos++] = dy;
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -313,7 +315,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = dy; v[opos++] = dy;
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -395,7 +397,7 @@ public final class LineLayer extends RenderElement {
ddy = -ddy; ddy = -ddy;
} }
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -406,7 +408,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = (short) (1 | ddy & DIR_MASK); v[opos++] = (short) (1 | ddy & DIR_MASK);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -430,8 +432,7 @@ public final class LineLayer extends RenderElement {
outside = (x < tmin || x > tmax || y < tmin || y > tmax); outside = (x < tmin || x > tmax || y < tmin || y > tmax);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
si = si.next;
opos = 0; opos = 0;
v = si.vertices; v = si.vertices;
} }
@ -454,7 +455,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = (short) (1 | ddy & DIR_MASK); v[opos++] = (short) (1 | ddy & DIR_MASK);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -465,7 +466,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = (short) (1 | -ddy & DIR_MASK); v[opos++] = (short) (1 | -ddy & DIR_MASK);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -483,7 +484,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = dy; v[opos++] = dy;
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -500,7 +501,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = dy; v[opos++] = dy;
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -531,7 +532,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = (short) (1 | (flip ? -ddy : ddy) & DIR_MASK); v[opos++] = (short) (1 | (flip ? -ddy : ddy) & DIR_MASK);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }
@ -548,7 +549,7 @@ public final class LineLayer extends RenderElement {
v[opos++] = dy; v[opos++] = dy;
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }

View File

@ -107,8 +107,8 @@ public final class LineTexLayer extends RenderElement {
public void addLine(float[] points, short[] index) { public void addLine(float[] points, short[] index) {
if (vertexItems == null) { if (vertexItems == null) {
curItem = vertexItems = VertexItem.pool.get(); vertexItems = VertexItem.pool.get();
curItem = vertexItems;
// HACK add one vertex offset when compiling // HACK add one vertex offset when compiling
// buffer otherwise one cant use the full // buffer otherwise one cant use the full
// VertexItem (see Layers.compile) // VertexItem (see Layers.compile)
@ -187,7 +187,7 @@ public final class LineTexLayer extends RenderElement {
short dy = (short) (uy * DIR_SCALE); short dy = (short) (uy * DIR_SCALE);
if (opos == VertexItem.SIZE) { if (opos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
opos = 0; opos = 0;
} }

View File

@ -81,7 +81,7 @@ public final class PolygonLayer extends RenderElement {
int inPos = pos; int inPos = pos;
if (outPos == VertexItem.SIZE) { if (outPos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
outPos = 0; outPos = 0;
} }
@ -91,7 +91,7 @@ public final class PolygonLayer extends RenderElement {
for (int j = 0; j < length; j += 2) { for (int j = 0; j < length; j += 2) {
if (outPos == VertexItem.SIZE) { if (outPos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
outPos = 0; outPos = 0;
} }
@ -100,7 +100,7 @@ public final class PolygonLayer extends RenderElement {
} }
if (outPos == VertexItem.SIZE) { if (outPos == VertexItem.SIZE) {
si = si.next = VertexItem.pool.get(); si = VertexItem.pool.getNext(si);
v = si.vertices; v = si.vertices;
outPos = 0; outPos = 0;
} }

View File

@ -209,7 +209,7 @@ public final class TextLayer extends TextureLayer {
if (pos == VertexItem.SIZE) { if (pos == VertexItem.SIZE) {
vi.used = VertexItem.SIZE; vi.used = VertexItem.SIZE;
vi = vi.next = VertexItem.pool.get(); vi = VertexItem.pool.getNext(vi);
buf = vi.vertices; buf = vi.vertices;
pos = 0; pos = 0;
} }

View File

@ -21,7 +21,10 @@ public class VertexItem extends Inlist<VertexItem> {
private static final int MAX_POOL = 500; private static final int MAX_POOL = 500;
public final static SyncPool<VertexItem> pool = new SyncPool<VertexItem>(MAX_POOL) { public final static class Pool extends SyncPool<VertexItem> {
public Pool() {
super(MAX_POOL);
}
@Override @Override
protected VertexItem createItem() { protected VertexItem createItem() {
@ -33,7 +36,14 @@ public class VertexItem extends Inlist<VertexItem> {
it.used = 0; it.used = 0;
return true; return true;
} }
};
public VertexItem getNext(VertexItem it) {
it.next = get();
return it.next;
}
}
public final static Pool pool = new Pool();
public int getSize() { public int getSize() {
int size = used; int size = used;

View File

@ -46,10 +46,8 @@ public class Tessellator {
int cnt; int cnt;
int numIndices = 0; int numIndices = 0;
if (outTris.used == VertexItem.SIZE) { if (outTris.used == VertexItem.SIZE)
outTris.next = VertexItem.pool.get(); outTris = VertexItem.pool.getNext(outTris);
outTris = outTris.next;
}
while ((cnt = Tessellator.tessGetIndicesWO(ctx, while ((cnt = Tessellator.tessGetIndicesWO(ctx,
outTris.vertices, outTris.vertices,
@ -87,8 +85,7 @@ public class Tessellator {
numIndices += cnt; numIndices += cnt;
if (outTris.used == VertexItem.SIZE) { if (outTris.used == VertexItem.SIZE) {
outTris.next = VertexItem.pool.get(); outTris = VertexItem.pool.getNext(outTris);
outTris = outTris.next;
continue; continue;
} }
@ -208,8 +205,7 @@ public class Tessellator {
} }
if (outPoints.used == VertexItem.SIZE) { if (outPoints.used == VertexItem.SIZE) {
outPoints.next = VertexItem.pool.get(); outPoints = VertexItem.pool.getNext(outPoints);
outPoints = outPoints.next;
} }
int cnt; int cnt;
@ -221,8 +217,7 @@ public class Tessellator {
outPoints.used += cnt; outPoints.used += cnt;
if (outPoints.used == VertexItem.SIZE) { if (outPoints.used == VertexItem.SIZE) {
outPoints.next = VertexItem.pool.get(); outPoints = VertexItem.pool.getNext(outPoints);
outPoints = outPoints.next;
continue; continue;
} }
// no more points to get. // no more points to get.
@ -232,8 +227,7 @@ public class Tessellator {
int numIndices = 0; int numIndices = 0;
if (outTris.used == VertexItem.SIZE) { if (outTris.used == VertexItem.SIZE) {
outTris.next = VertexItem.pool.get(); outTris = VertexItem.pool.getNext(outTris);
outTris = outTris.next;
} }
while ((cnt = Tessellator.tessGetIndicesWO(ctx, while ((cnt = Tessellator.tessGetIndicesWO(ctx,
@ -247,8 +241,7 @@ public class Tessellator {
numIndices += cnt; numIndices += cnt;
if (outTris.used == VertexItem.SIZE) { if (outTris.used == VertexItem.SIZE) {
outTris.next = VertexItem.pool.get(); outTris = VertexItem.pool.getNext(outTris);
outTris = outTris.next;
continue; continue;
} }