RenderBuckets: constant TILE_FILL_VERTICES (#715)
This commit is contained in:
parent
df82ebfaa6
commit
431eadaa87
@ -23,11 +23,7 @@ import org.oscim.backend.canvas.Color;
|
||||
import org.oscim.core.GeometryBuffer;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.core.Tile;
|
||||
import org.oscim.renderer.GLMatrix;
|
||||
import org.oscim.renderer.GLShader;
|
||||
import org.oscim.renderer.GLState;
|
||||
import org.oscim.renderer.GLUtils;
|
||||
import org.oscim.renderer.GLViewport;
|
||||
import org.oscim.renderer.*;
|
||||
import org.oscim.theme.styles.AreaStyle;
|
||||
import org.oscim.utils.ArrayUtils;
|
||||
import org.oscim.utils.geom.LineClipper;
|
||||
@ -173,6 +169,9 @@ public final class PolygonBucket extends RenderBucket {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Draw tile filling quad.
|
||||
*/
|
||||
private static void fillPolygons(GLViewport v, int start, int end,
|
||||
MapPosition pos, float div) {
|
||||
|
||||
@ -228,7 +227,7 @@ public final class PolygonBucket extends RenderBucket {
|
||||
gl.stencilFunc(GL.EQUAL, 0xff, CLIP_BIT | 1 << i);
|
||||
|
||||
/* 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)
|
||||
continue;
|
||||
@ -470,7 +469,7 @@ public final class PolygonBucket extends RenderBucket {
|
||||
gl.stencilOp(GL.KEEP, GL.KEEP, GL.REPLACE);
|
||||
|
||||
/* 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) {
|
||||
/* dont modify depth buffer */
|
||||
@ -499,7 +498,7 @@ public final class PolygonBucket extends RenderBucket {
|
||||
gl.stencilOp(GL.KEEP, GL.KEEP, GL.REPLACE);
|
||||
|
||||
/* 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 */
|
||||
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)
|
||||
gl.colorMask(true, true, true, true);
|
||||
|
||||
@ -30,12 +30,7 @@ import org.slf4j.LoggerFactory;
|
||||
import java.nio.ShortBuffer;
|
||||
|
||||
import static org.oscim.renderer.MapRenderer.COORD_SCALE;
|
||||
import static org.oscim.renderer.bucket.RenderBucket.CIRCLE;
|
||||
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;
|
||||
import static org.oscim.renderer.bucket.RenderBucket.*;
|
||||
|
||||
/**
|
||||
* 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 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;
|
||||
|
||||
/**
|
||||
* VBO holds all vertex data to draw lines and polygons after compilation.
|
||||
* Layout:
|
||||
* 16 bytes fill coordinates,
|
||||
* 16 bytes fill coordinates ({@link #TILE_FILL_VERTICES} * {@link #SHORT_BYTES} * coordsPerVertex),
|
||||
* n bytes polygon 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) {
|
||||
|
||||
int vboSize = countVboSize();
|
||||
@ -355,12 +361,12 @@ public class RenderBuckets extends TileData {
|
||||
}
|
||||
|
||||
if (addFill)
|
||||
vboSize += 8;
|
||||
vboSize += TILE_FILL_VERTICES * 2;
|
||||
|
||||
ShortBuffer vboData = MapRenderer.getShortBuffer(vboSize);
|
||||
|
||||
if (addFill)
|
||||
vboData.put(fillShortCoords, 0, 8);
|
||||
vboData.put(fillShortCoords, 0, TILE_FILL_VERTICES * 2);
|
||||
|
||||
ShortBuffer iboData = null;
|
||||
|
||||
@ -369,7 +375,7 @@ public class RenderBuckets extends TileData {
|
||||
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) {
|
||||
if (l.type == POLYGON) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user