RenderBuckets: constant TILE_FILL_VERTICES (#715)
This commit is contained in:
@@ -23,11 +23,7 @@ import org.oscim.backend.canvas.Color;
|
|||||||
import org.oscim.core.GeometryBuffer;
|
import org.oscim.core.GeometryBuffer;
|
||||||
import org.oscim.core.MapPosition;
|
import org.oscim.core.MapPosition;
|
||||||
import org.oscim.core.Tile;
|
import org.oscim.core.Tile;
|
||||||
import org.oscim.renderer.GLMatrix;
|
import org.oscim.renderer.*;
|
||||||
import org.oscim.renderer.GLShader;
|
|
||||||
import org.oscim.renderer.GLState;
|
|
||||||
import org.oscim.renderer.GLUtils;
|
|
||||||
import org.oscim.renderer.GLViewport;
|
|
||||||
import org.oscim.theme.styles.AreaStyle;
|
import org.oscim.theme.styles.AreaStyle;
|
||||||
import org.oscim.utils.ArrayUtils;
|
import org.oscim.utils.ArrayUtils;
|
||||||
import org.oscim.utils.geom.LineClipper;
|
import org.oscim.utils.geom.LineClipper;
|
||||||
@@ -173,6 +169,9 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Draw tile filling quad.
|
||||||
|
*/
|
||||||
private static void fillPolygons(GLViewport v, int start, int end,
|
private static void fillPolygons(GLViewport v, int start, int end,
|
||||||
MapPosition pos, float div) {
|
MapPosition pos, float div) {
|
||||||
|
|
||||||
@@ -228,7 +227,7 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
gl.stencilFunc(GL.EQUAL, 0xff, CLIP_BIT | 1 << i);
|
gl.stencilFunc(GL.EQUAL, 0xff, CLIP_BIT | 1 << i);
|
||||||
|
|
||||||
/* draw tile fill coordinates */
|
/* draw tile fill coordinates */
|
||||||
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
|
gl.drawArrays(GL.TRIANGLE_STRIP, 0, RenderBuckets.TILE_FILL_VERTICES);
|
||||||
|
|
||||||
if (a.strokeWidth <= 0)
|
if (a.strokeWidth <= 0)
|
||||||
continue;
|
continue;
|
||||||
@@ -470,7 +469,7 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
gl.stencilOp(GL.KEEP, GL.KEEP, GL.REPLACE);
|
gl.stencilOp(GL.KEEP, GL.KEEP, GL.REPLACE);
|
||||||
|
|
||||||
/* draw a quad for the tile region */
|
/* draw a quad for the tile region */
|
||||||
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
|
gl.drawArrays(GL.TRIANGLE_STRIP, 0, RenderBuckets.TILE_FILL_VERTICES);
|
||||||
|
|
||||||
if (clipMode == CLIP_DEPTH) {
|
if (clipMode == CLIP_DEPTH) {
|
||||||
/* dont modify depth buffer */
|
/* dont modify depth buffer */
|
||||||
@@ -499,7 +498,7 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
gl.stencilOp(GL.KEEP, GL.KEEP, GL.REPLACE);
|
gl.stencilOp(GL.KEEP, GL.KEEP, GL.REPLACE);
|
||||||
|
|
||||||
/* draw a quad for the tile region */
|
/* draw a quad for the tile region */
|
||||||
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
|
gl.drawArrays(GL.TRIANGLE_STRIP, 0, RenderBuckets.TILE_FILL_VERTICES);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -532,7 +531,7 @@ public final class PolygonBucket extends RenderBucket {
|
|||||||
/* zero out area to draw to */
|
/* zero out area to draw to */
|
||||||
gl.stencilOp(GL.KEEP, GL.KEEP, GL.ZERO);
|
gl.stencilOp(GL.KEEP, GL.KEEP, GL.ZERO);
|
||||||
|
|
||||||
gl.drawArrays(GL.TRIANGLE_STRIP, 0, 4);
|
gl.drawArrays(GL.TRIANGLE_STRIP, 0, RenderBuckets.TILE_FILL_VERTICES);
|
||||||
|
|
||||||
if (color == 0)
|
if (color == 0)
|
||||||
gl.colorMask(true, true, true, true);
|
gl.colorMask(true, true, true, true);
|
||||||
|
|||||||
@@ -30,12 +30,7 @@ import org.slf4j.LoggerFactory;
|
|||||||
import java.nio.ShortBuffer;
|
import java.nio.ShortBuffer;
|
||||||
|
|
||||||
import static org.oscim.renderer.MapRenderer.COORD_SCALE;
|
import static org.oscim.renderer.MapRenderer.COORD_SCALE;
|
||||||
import static org.oscim.renderer.bucket.RenderBucket.CIRCLE;
|
import static org.oscim.renderer.bucket.RenderBucket.*;
|
||||||
import static org.oscim.renderer.bucket.RenderBucket.HAIRLINE;
|
|
||||||
import static org.oscim.renderer.bucket.RenderBucket.LINE;
|
|
||||||
import static org.oscim.renderer.bucket.RenderBucket.MESH;
|
|
||||||
import static org.oscim.renderer.bucket.RenderBucket.POLYGON;
|
|
||||||
import static org.oscim.renderer.bucket.RenderBucket.TEXLINE;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is primarily intended for rendering the vector elements of a
|
* This class is primarily intended for rendering the vector elements of a
|
||||||
@@ -62,12 +57,17 @@ public class RenderBuckets extends TileData {
|
|||||||
public static final int SHORT_BYTES = 2;
|
public static final int SHORT_BYTES = 2;
|
||||||
// public static final int INT_BYTES = 4;
|
// public static final int INT_BYTES = 4;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Number of vertices to fill a tile (represented by a quad).
|
||||||
|
*/
|
||||||
|
public static final int TILE_FILL_VERTICES = 4;
|
||||||
|
|
||||||
private RenderBucket buckets;
|
private RenderBucket buckets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* VBO holds all vertex data to draw lines and polygons after compilation.
|
* VBO holds all vertex data to draw lines and polygons after compilation.
|
||||||
* Layout:
|
* Layout:
|
||||||
* 16 bytes fill coordinates,
|
* 16 bytes fill coordinates ({@link #TILE_FILL_VERTICES} * {@link #SHORT_BYTES} * coordsPerVertex),
|
||||||
* n bytes polygon vertices,
|
* n bytes polygon vertices,
|
||||||
* m bytes lines vertices
|
* m bytes lines vertices
|
||||||
* ...
|
* ...
|
||||||
@@ -344,6 +344,12 @@ public class RenderBuckets extends TileData {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Compile different types of buckets in one {@link #vbo VBO}.
|
||||||
|
*
|
||||||
|
* @param addFill fill tile (add {@link #TILE_FILL_VERTICES 4} vertices).
|
||||||
|
* @return true if compilation succeeded.
|
||||||
|
*/
|
||||||
public boolean compile(boolean addFill) {
|
public boolean compile(boolean addFill) {
|
||||||
|
|
||||||
int vboSize = countVboSize();
|
int vboSize = countVboSize();
|
||||||
@@ -355,12 +361,12 @@ public class RenderBuckets extends TileData {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (addFill)
|
if (addFill)
|
||||||
vboSize += 8;
|
vboSize += TILE_FILL_VERTICES * 2;
|
||||||
|
|
||||||
ShortBuffer vboData = MapRenderer.getShortBuffer(vboSize);
|
ShortBuffer vboData = MapRenderer.getShortBuffer(vboSize);
|
||||||
|
|
||||||
if (addFill)
|
if (addFill)
|
||||||
vboData.put(fillShortCoords, 0, 8);
|
vboData.put(fillShortCoords, 0, TILE_FILL_VERTICES * 2);
|
||||||
|
|
||||||
ShortBuffer iboData = null;
|
ShortBuffer iboData = null;
|
||||||
|
|
||||||
@@ -369,7 +375,7 @@ public class RenderBuckets extends TileData {
|
|||||||
iboData = MapRenderer.getShortBuffer(iboSize);
|
iboData = MapRenderer.getShortBuffer(iboSize);
|
||||||
}
|
}
|
||||||
|
|
||||||
int pos = addFill ? 4 : 0;
|
int pos = addFill ? TILE_FILL_VERTICES : 0;
|
||||||
|
|
||||||
for (RenderBucket l = buckets; l != null; l = l.next) {
|
for (RenderBucket l = buckets; l != null; l = l.next) {
|
||||||
if (l.type == POLYGON) {
|
if (l.type == POLYGON) {
|
||||||
|
|||||||
Reference in New Issue
Block a user