start to make line stipple themeable

This commit is contained in:
Hannes Janetzek 2013-02-23 02:02:11 +01:00
parent 87ea877705
commit d91ad535a2
7 changed files with 246 additions and 182 deletions

View File

@ -23,6 +23,7 @@ import org.oscim.renderer.layer.Layer;
import org.oscim.renderer.layer.Layers; import org.oscim.renderer.layer.Layers;
import org.oscim.renderer.layer.LineLayer; import org.oscim.renderer.layer.LineLayer;
import org.oscim.renderer.layer.LineTexLayer; import org.oscim.renderer.layer.LineTexLayer;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.utils.GlUtils; import org.oscim.utils.GlUtils;
import android.opengl.GLES20; import android.opengl.GLES20;
@ -45,15 +46,16 @@ public class LineTexRenderer {
private static int hTexColor; private static int hTexColor;
private static int hBgColor; private static int hBgColor;
private static int hScale; private static int hScale;
private static int hPatternScale;
private static int hWidth; private static int hWidth;
private static int mIndicesBufferID; private static int mIndicesBufferID;
private static int mVertexFlipID; private static int mVertexFlipID;
// draw up to 100 quads in one round // batch up up to 100 quads in one draw call
private static int maxQuads = 100; private static int maxQuads = 100;
private static int maxIndices = maxQuads * 6; private static int maxIndices = maxQuads * 6;
private static int mTexID; private static int[] mTexID;
public static void init() { public static void init() {
shader = GlUtils.createProgram(vertexShader, fragmentShader); shader = GlUtils.createProgram(vertexShader, fragmentShader);
@ -66,6 +68,7 @@ public class LineTexRenderer {
hTexColor = GLES20.glGetUniformLocation(shader, "u_color"); hTexColor = GLES20.glGetUniformLocation(shader, "u_color");
hBgColor = GLES20.glGetUniformLocation(shader, "u_bgcolor"); hBgColor = GLES20.glGetUniformLocation(shader, "u_bgcolor");
hScale = GLES20.glGetUniformLocation(shader, "u_scale"); hScale = GLES20.glGetUniformLocation(shader, "u_scale");
hPatternScale = GLES20.glGetUniformLocation(shader, "u_pscale");
hWidth = GLES20.glGetUniformLocation(shader, "u_width"); hWidth = GLES20.glGetUniformLocation(shader, "u_width");
hVertexPosition0 = GLES20.glGetAttribLocation(shader, "a_pos0"); hVertexPosition0 = GLES20.glGetAttribLocation(shader, "a_pos0");
@ -115,14 +118,13 @@ public class LineTexRenderer {
GLES20.GL_STATIC_DRAW); GLES20.GL_STATIC_DRAW);
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, 0);
mTexID = new int[10];
byte[] stipple = new byte[2]; byte[] stipple = new byte[2];
stipple[0] = 8; stipple[0] = 32;
stipple[1] = 8; stipple[1] = 32;
//stipple[2] = 16;
//stipple[3] = 48;
mTexID = GlUtils.loadStippleTexture(stipple);
mTexID[0] = GlUtils.loadStippleTexture(stipple);
} }
private final static int STRIDE = 12; private final static int STRIDE = 12;
@ -144,12 +146,7 @@ public class LineTexRenderer {
GLES20.glUniformMatrix4fv(hMatrix, 1, false, matrix, 0); GLES20.glUniformMatrix4fv(hMatrix, 1, false, matrix, 0);
GLES20.glUniform4f(hTexColor, 1.0f, 1.0f, 1.0f, 1.0f);
//aa9988
GLES20.glUniform4f(hBgColor, 0x99 / 255f, 0x96 / 255f, 0x93 / 255f, 0.95f);
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexID);
GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER, GLES20.glBindBuffer(GLES20.GL_ELEMENT_ARRAY_BUFFER,
mIndicesBufferID); mIndicesBufferID);
@ -160,21 +157,37 @@ public class LineTexRenderer {
GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, layers.vbo.id); GLES20.glBindBuffer(GLES20.GL_ARRAY_BUFFER, layers.vbo.id);
int offset = layers.texLineOffset;
float s = pos.scale / div; float s = pos.scale / div;
GLES20.glBindTexture(GLES20.GL_TEXTURE_2D, mTexID[0]);
Layer l = curLayer; Layer l = curLayer;
while (l != null && l.type == Layer.TEXLINE) { while (l != null && l.type == Layer.TEXLINE) {
LineTexLayer ll = (LineTexLayer) l; LineTexLayer ll = (LineTexLayer) l;
//Line line = ll.line; Line line = ll.line;
if (line.stippleColor == null)
GLES20.glUniform4f(hTexColor, 1.0f, 1.0f, 1.0f, 1.0f);
else
GLES20.glUniform4fv(hTexColor, 1, line.stippleColor, 0);
GLES20.glUniform4fv(hBgColor, 1, line.color, 0);
//GLES20.glUniform4f(hBgColor, 0x99 / 255f, 0x96 / 255f, 0x93 / 255f, 0.95f);
// scale pattern to twice its size, then reset scale to 1. // scale pattern to twice its size, then reset scale to 1.
// (coord scale * pattern size) / scale // (coord scale * pattern size) / scale
GLES20.glUniform1f(hScale, (8 * 16) / Math.max((int)(s+0.25f), 1)); GLES20.glUniform1f(hPatternScale, (8 * (64 / line.stipple)) / Math.max((int) s, 1));
//float f = Math.max((int)(s), 1);
//Log.d(TAG, s + " : " + f);
//GLES20.glUniform1f(hPatternScale, (8 * line.stipple) / 1);
GLES20.glUniform1f(hScale, pos.scale);
GLES20.glUniform1f(hWidth, ll.width / s * COORD_SCALE_BY_DIR_SCALE); GLES20.glUniform1f(hWidth, ll.width / s * COORD_SCALE_BY_DIR_SCALE);
// add offset vertex
int vOffset = -STRIDE;
// first pass // first pass
int allIndices = (ll.evenQuads * 6); int allIndices = (ll.evenQuads * 6);
for (int i = 0; i < allIndices; i += maxIndices) { for (int i = 0; i < allIndices; i += maxIndices) {
@ -183,7 +196,7 @@ public class LineTexRenderer {
numIndices = maxIndices; numIndices = maxIndices;
// i / 6 * (24 shorts per block * 2 short bytes) // i / 6 * (24 shorts per block * 2 short bytes)
int add = offset + i * 8; int add = (l.offset + i * 8) + vOffset;;
GLES20.glVertexAttribPointer(hVertexPosition0, GLES20.glVertexAttribPointer(hVertexPosition0,
4, GLES20.GL_SHORT, false, STRIDE, 4, GLES20.GL_SHORT, false, STRIDE,
@ -212,7 +225,7 @@ public class LineTexRenderer {
if (numIndices > maxIndices) if (numIndices > maxIndices)
numIndices = maxIndices; numIndices = maxIndices;
// i / 6 * (24 shorts per block * 2 short bytes) // i / 6 * (24 shorts per block * 2 short bytes)
int add = offset + i * 8; int add = (l.offset + i * 8) + vOffset;
GLES20.glVertexAttribPointer(hVertexPosition0, GLES20.glVertexAttribPointer(hVertexPosition0,
4, GLES20.GL_SHORT, false, STRIDE, 4, GLES20.GL_SHORT, false, STRIDE,
@ -255,7 +268,7 @@ public class LineTexRenderer {
+ "precision mediump float;" + "precision mediump float;"
+ "uniform mat4 u_mvp;" + "uniform mat4 u_mvp;"
+ "uniform vec4 u_color;" + "uniform vec4 u_color;"
+ "uniform float u_scale;" + "uniform float u_pscale;"
+ "uniform float u_width;" + "uniform float u_width;"
+ "attribute vec4 a_pos0;" + "attribute vec4 a_pos0;"
+ "attribute vec4 a_pos1;" + "attribute vec4 a_pos1;"
@ -264,20 +277,41 @@ public class LineTexRenderer {
+ "attribute float a_flip;" + "attribute float a_flip;"
+ "varying vec2 v_st;" + "varying vec2 v_st;"
+ "void main() {" + "void main() {"
// coord scale 8 * pattern length 16 + " vec4 pos;"
//+ " float div = (8.0 * 16.0) / max(ceil(log(u_scale)),1.0);"
+ " float div = u_scale;"
+ " if (a_flip == 0.0){" + " if (a_flip == 0.0){"
+ " vec2 dir = u_width * a_pos0.zw;" + " vec2 dir = u_width * a_pos0.zw;"
+ " gl_Position = u_mvp * vec4(a_pos0.xy + dir, 0.0, 1.0);" + " pos = vec4(a_pos0.xy + dir, 0.0, 1.0);"
+ " v_st = vec2(a_len0.x/div, 1.0);" + " v_st = vec2(a_len0.x / u_pscale, 1.0);"
+ " }else {" + " } else {"
+ " vec2 dir = u_width * a_pos1.zw ;" + " vec2 dir = u_width * a_pos1.zw ;"
+ " gl_Position = u_mvp * vec4(a_pos1.xy - dir, 0.0, 1.0);" + " pos = vec4(a_pos1.xy - dir, 0.0, 1.0);"
+ " v_st = vec2(a_len1.x/div, -1.0);" + " v_st = vec2(a_len1.x / u_pscale, -1.0);"
+ " }" + " }"
+ " gl_Position = u_mvp * pos;"
+ "}"; + "}";
/*
final static String fragmentShader = ""
+ "#extension GL_OES_standard_derivatives : enable\n"
+ " precision mediump float;"
+ " uniform sampler2D tex;"
+ " uniform float u_scale;"
+ " uniform vec4 u_color;"
+ " uniform vec4 u_bgcolor;"
+ " varying vec2 v_st;"
+ " void main() {"
+ " float len = texture2D(tex, v_st).a;"
+ " float tex_w = abs(v_st.t);"
+ " vec2 st_width = fwidth(v_st);"
+ " float fuzz = max(st_width.s, st_width.t);"
//+ " float fuzz = fwidth(v_st.t);"
//+ " float line_w = 1.0 - smoothstep(1.0 - fuzz, 1.0, tex_w);"
//+ " float stipple_w = 1.0 - smoothstep(0.7 - fuzz, 0.7, tex_w);"
+ " float stipple_p = 1.0 - smoothstep(1.0 - fuzz, 1.0, length(vec2(len*u_scale, v_st.t)));"
+ " gl_FragColor = u_bgcolor * stipple_p;"
// + " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
+ "}"; //*/
//*
final static String fragmentShader = "" final static String fragmentShader = ""
+ "#extension GL_OES_standard_derivatives : enable\n" + "#extension GL_OES_standard_derivatives : enable\n"
+ "precision mediump float;" + "precision mediump float;"
@ -294,6 +328,6 @@ public class LineTexRenderer {
+ " float stipple_w = (1.0 - smoothstep(0.7 - fuzz, 0.7, tex_w));" + " float stipple_w = (1.0 - smoothstep(0.7 - fuzz, 0.7, tex_w));"
+ " float stipple_p = smoothstep(0.495, 0.505, len);" + " float stipple_p = smoothstep(0.495, 0.505, len);"
+ " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));" + " gl_FragColor = line_w * mix(u_bgcolor, u_color, min(stipple_w, stipple_p));"
+ "}"; + "}"; //*/
} }

View File

@ -150,9 +150,17 @@ public class Layers {
lineOffset = size * SHORT_BYTES; lineOffset = size * SHORT_BYTES;
size += addLayerItems(sbuf, baseLayers, Layer.LINE, 0); size += addLayerItems(sbuf, baseLayers, Layer.LINE, 0);
texLineOffset = size * SHORT_BYTES; texLineOffset = size * SHORT_BYTES;
size += addLayerItems(sbuf, baseLayers, Layer.TEXLINE, 0); for (Layer l = baseLayers; l != null; l= l.next){
if (l.type == Layer.TEXLINE){
// HACK, see LineTexLayer
//sbuf.position(sbuf.position() + 6);
addPoolItems(l, sbuf);
//l.offset -= 12;
}
}
//size += addLayerItems(sbuf, baseLayers, Layer.TEXLINE, 0);
for (Layer l = textureLayers; l != null; l = l.next) { for (Layer l = textureLayers; l != null; l = l.next) {
TextureLayer tl = (TextureLayer) l; TextureLayer tl = (TextureLayer) l;
@ -172,18 +180,10 @@ public class Layers {
VertexPoolItem last = null, items = null; VertexPoolItem last = null, items = null;
int size = 0; int size = 0;
// HACK, see LineTexLayer
boolean addOffset = (type == Layer.TEXLINE);
for (; l != null; l = l.next) { for (; l != null; l = l.next) {
if (l.type != type) if (l.type != type)
continue; continue;
if (addOffset){
sbuf.position(sbuf.position() + 6);
addOffset = false;
}
for (VertexPoolItem it = l.pool; it != null; it = it.next) { for (VertexPoolItem it = l.pool; it != null; it = it.next) {
if (it.next == null){ if (it.next == null){
size += it.used; size += it.used;
@ -199,6 +199,7 @@ public class Layers {
continue; continue;
l.offset = pos; l.offset = pos;
pos += l.verticesCnt; pos += l.verticesCnt;
last.next = items; last.next = items;

View File

@ -21,6 +21,8 @@ import org.oscim.theme.renderinstruction.Line;
/** /**
* Layer for textured or stippled lines * Layer for textured or stippled lines
*
* this would be all so much simpler with geometry shaders...
*/ */
public final class LineTexLayer extends Layer { public final class LineTexLayer extends Layer {
// Interleave two segment quads in one block to be able to use // Interleave two segment quads in one block to be able to use
@ -57,6 +59,11 @@ public final class LineTexLayer extends Layer {
// 2, 1, 3, // 2, 1, 3,
// 4, 5, 6, // 4, 5, 6,
// 6, 5, 7, // 6, 5, 7,
//
// BIG NOTE: renderer assumes to be able to offset vertex array position
// so that in the first pass 'pos1' offset will be < 0 if no data precedes
// - in our case there is always the polygon fill array at start
// - see addLine hack otherwise.
private static final float COORD_SCALE = GLRenderer.COORD_MULTIPLIER; private static final float COORD_SCALE = GLRenderer.COORD_MULTIPLIER;
// scale factor mapping extrusion vector to short values // scale factor mapping extrusion vector to short values
@ -84,15 +91,11 @@ public final class LineTexLayer extends Layer {
if (pool == null) { if (pool == null) {
curItem = pool = VertexPool.get(); curItem = pool = VertexPool.get();
// need to make sure there is one unused
// vertex in front for interleaving.
// HACK add this offset when compiling // HACK add one vertex offset when compiling
// otherwise one cant use the full // buffer otherwise one cant use the full
// VertexItem // VertexItem
//curItem.used = 6; //verticesCnt = 1;
verticesCnt = 1;
} }
VertexPoolItem si = curItem; VertexPoolItem si = curItem;
@ -207,14 +210,14 @@ public final class LineTexLayer extends Layer {
pos += length; pos += length;
} }
evenSegment = even;
// advance offset to last written position // advance offset to last written position
if (!even) if (!even)
opos += 12; opos += 12;
si.used = opos; si.used = opos;
curItem = si; curItem = si;
evenSegment = even;
} }
@Override @Override

View File

@ -18,8 +18,11 @@ import org.oscim.core.MapPosition;
import org.oscim.renderer.layer.Layer; import org.oscim.renderer.layer.Layer;
import org.oscim.renderer.layer.LineTexLayer; import org.oscim.renderer.layer.LineTexLayer;
import org.oscim.renderer.layer.TextItem; import org.oscim.renderer.layer.TextItem;
import org.oscim.theme.renderinstruction.Line;
import org.oscim.view.MapView; import org.oscim.view.MapView;
import android.graphics.Color;
public class TestOverlay extends BasicOverlay { public class TestOverlay extends BasicOverlay {
TextItem labels; TextItem labels;
@ -47,7 +50,8 @@ public class TestOverlay extends BasicOverlay {
LineTexLayer lt = (LineTexLayer) layers.getLayer(2, Layer.TEXLINE); LineTexLayer lt = (LineTexLayer) layers.getLayer(2, Layer.TEXLINE);
lt.width = 4; lt.line = new Line(Color.BLUE, 1.0f, 8);
lt.width = 8;
lt.addLine(points, null); lt.addLine(points, null);
float[] points2 = { float[] points2 = {
@ -57,7 +61,9 @@ public class TestOverlay extends BasicOverlay {
-200, 200, -200, 200,
-200, -200 -200, -200
}; };
lt = (LineTexLayer) layers.getLayer(3, Layer.TEXLINE);
lt.line = new Line(Color.BLUE, 1.0f, 16);
lt.width = 8;
lt.addLine(points2, null); lt.addLine(points2, null);
// //

View File

@ -47,24 +47,40 @@ public final class Line extends RenderInstruction {
*/ */
public static Line create(Line line, String elementName, Attributes attributes, public static Line create(Line line, String elementName, Attributes attributes,
int level, boolean isOutline) { int level, boolean isOutline) {
String src = null;
int stroke = Color.BLACK; // Style name
float strokeWidth = 0; String style = null;
int stipple = 0; // Bitmap
Cap strokeLinecap = Cap.ROUND; //String src = null;
float width = 0;
Cap cap = Cap.ROUND;
// Extras
int fade = -1; int fade = -1;
boolean fixed = false; boolean fixed = false;
String style = null;
float blur = 0; float blur = 0;
float min = 0; float min = 0;
// Stipple
int stipple = 0;
float stippleWidth = 0;
float[] color = null;
float[] stippleColor = null;
if (line != null) { if (line != null) {
color = line.color;
fixed = line.fixed; fixed = line.fixed;
fade = line.fade; fade = line.fade;
strokeLinecap = line.cap; cap = line.cap;
blur = line.blur; blur = line.blur;
min = line.min; min = line.min;
stipple = line.stipple;
stippleColor = line.stippleColor;
stippleWidth = line.stippleWidth;
} }
for (int i = 0; i < attributes.getLength(); ++i) { for (int i = 0; i < attributes.getLength(); ++i) {
String name = attributes.getLocalName(i); String name = attributes.getLocalName(i);
String value = attributes.getValue(i); String value = attributes.getValue(i);
@ -72,21 +88,27 @@ public final class Line extends RenderInstruction {
if ("name".equals(name)) if ("name".equals(name))
style = value; style = value;
else if ("src".equals(name)) { else if ("src".equals(name)) {
src = value; //src = value;
} else if ("stroke".equals(name)) { } else if ("stroke".equals(name)) {
stroke = Color.parseColor(value); int stroke = Color.parseColor(value);
color = GlUtils.colorToFloatP(stroke);
} else if ("width".equals(name)) { } else if ("width".equals(name)) {
strokeWidth = Float.parseFloat(value); width = Float.parseFloat(value);
} else if ("cap".equals(name)) {
cap = Cap.valueOf(value.toUpperCase(Locale.ENGLISH));
} else if ("fixed".equals(name)) {
fixed = Boolean.parseBoolean(value);
} else if ("stipple".equals(name)) { } else if ("stipple".equals(name)) {
stipple = Integer.parseInt(value); stipple = Integer.parseInt(value);
} else if ("cap".equals(name)) { } else if ("stipple-stroke".equals(name)) {
strokeLinecap = Cap.valueOf(value.toUpperCase(Locale.ENGLISH)); int stroke = Color.parseColor(value);
stippleColor = GlUtils.colorToFloatP(stroke);
} else if ("stipple-width".equals(name)) {
stippleWidth = Float.parseFloat(value);
} else if ("fade".equals(name)) { } else if ("fade".equals(name)) {
fade = Integer.parseInt(value); fade = Integer.parseInt(value);
} else if ("min".equals(name)) { } else if ("min".equals(name)) {
min = Float.parseFloat(value); min = Float.parseFloat(value);
} else if ("fixed".equals(name)) {
fixed = Boolean.parseBoolean(value);
} else if ("blur".equals(name)) { } else if ("blur".equals(name)) {
blur = Float.parseFloat(value); blur = Float.parseFloat(value);
} else if ("from".equals(name)) { } else if ("from".equals(name)) {
@ -95,38 +117,27 @@ public final class Line extends RenderInstruction {
} }
} }
if (stipple != 0) // hint that sth is missing
strokeLinecap = Cap.BUTT; if (color == null)
color = GlUtils.colorToFloatP(Color.RED);
if (stipple != 0 && stippleColor == null)
stippleColor = GlUtils.colorToFloatP(Color.GREEN);
// inherit properties from 'line'
if (line != null) { if (line != null) {
// use stroke width relative to 'line'
width = line.width + width;
if (width <= 0)
width = 1;
strokeWidth = line.width + strokeWidth; } else if (!isOutline) {
if (strokeWidth <= 0) validate(width);
strokeWidth = 1;
return new Line(line, style, src, stroke, strokeWidth, stipple,
strokeLinecap, level, fixed, fade, blur, isOutline, min);
} }
if (!isOutline) return new Line(level, style, color, width, cap, fixed,
validate(strokeWidth); stipple, stippleColor, stippleWidth,
fade, blur, isOutline, min);
return new Line(style, src, stroke, strokeWidth, stipple, strokeLinecap,
level, fixed, fade, blur, isOutline, min);
}
public Line(int stroke, float width, Cap cap) {
this.level = 0;
this.blur = 0;
this.cap = cap;
this.outline = false;
this.style = "";
this.width = width;
this.fixed = true;
this.fade = -1;
this.stipple = 2;
this.min = 0;
color = GlUtils.colorToFloatP(stroke);
} }
private static void validate(float strokeWidth) { private static void validate(float strokeWidth) {
@ -147,59 +158,28 @@ public final class Line extends RenderInstruction {
private final int level; private final int level;
public final float width;
// public final boolean round;
public final float color[];
public final boolean outline;
public final boolean fixed;
public final int fade;
public final String style; public final String style;
public final float width;
public final float[] color;
public final Cap cap; public final Cap cap;
public final boolean outline;
public final boolean fixed;
public final int fade;
public final float blur; public final float blur;
public final int stipple;
public final float min; public final float min;
/** public final int stipple;
* @param style public final float[] stippleColor;
* ... public final float stippleWidth;
* @param src
* ...
* @param stroke
* ...
* @param strokeWidth
* ...
* @param stipple
* ...
* @param strokeLinecap
* ...
* @param level
* ...
* @param fixed
* ...
* @param fade
* ...
* @param blur
* ...
* @param isOutline
* ...
* @param min ...
*/
private Line(String style, String src, int stroke, float strokeWidth,
int stipple, Cap strokeLinecap, int level, boolean fixed,
int fade, float blur, boolean isOutline, float min) {
super();
private Line(int level, String style, float[] stroke, float width,
Cap cap, boolean fixed,
int stipple, float[] stippleColor, float stippleWidth,
int fade, float blur, boolean isOutline, float min) {
this.level = level;
this.style = style; this.style = style;
this.outline = isOutline;
// paint = new Paint(Paint.ANTI_ALIAS_FLAG); // paint = new Paint(Paint.ANTI_ALIAS_FLAG);
// //
@ -213,51 +193,55 @@ public final class Line extends RenderInstruction {
// if (strokeDasharray != null) { // if (strokeDasharray != null) {
// paint.setPathEffect(new DashPathEffect(strokeDasharray, 0)); // paint.setPathEffect(new DashPathEffect(strokeDasharray, 0));
// } // }
// paint.setStrokeCap(strokeLinecap);
// round = (strokeLinecap == Cap.ROUND); this.cap = cap;
this.color = stroke;
this.cap = strokeLinecap; this.width = width;
color = GlUtils.colorToFloatP(stroke);
this.width = strokeWidth;
this.level = level;
this.outline = isOutline;
this.fixed = fixed; this.fixed = fixed;
this.stipple = stipple;
this.stippleColor = stippleColor;
this.stippleWidth = stippleWidth;
this.blur = blur; this.blur = blur;
this.fade = fade; this.fade = fade;
this.stipple = stipple;
this.min = min; this.min = min;
} }
public Line(int stroke, float width, Cap cap) {
this.level = 0;
this.blur = 0;
this.cap = cap;
this.outline = false;
this.style = "";
this.width = width;
this.fixed = true;
this.fade = -1;
this.stipple = 0;
this.stippleColor = null;
this.stippleWidth = 0;
this.min = 0;
this.color = GlUtils.colorToFloatP(stroke);
}
private Line(Line line, String style, String src, int stroke, float strokeWidth, public Line(int stroke, float width, int stipple) {
int stipple, Cap strokeLinecap, int level, boolean fixed, this.level = 0;
int fade, float blur, boolean isOutline, float min) { this.blur = 0;
super(); this.cap = Cap.BUTT;
this.outline = false;
this.style = style; this.style = "";
this.width = width;
// round = (strokeLinecap == Cap.ROUND); this.fixed = true;
this.fade = -1;
color = line.color;
this.width = strokeWidth;
this.level = level;
this.outline = isOutline;
this.fixed = fixed;
this.fade = fade;
this.cap = strokeLinecap;
this.blur = blur;
this.stipple = stipple; this.stipple = stipple;
this.min = min; this.stippleColor = null;
this.stippleWidth = 0;
this.min = 0;
color = GlUtils.colorToFloatP(stroke);
} }
@Override @Override
public void renderWay(IRenderCallback renderCallback, Tag[] tags) { public void renderWay(IRenderCallback renderCallback, Tag[] tags) {
// renderCallback.renderWay(mPaint, mLevel, mColor, mStrokeWidth,
// mRound, mOutline);
renderCallback.renderWay(this, level); renderCallback.renderWay(this, level);
} }
@ -266,7 +250,5 @@ public final class Line extends RenderInstruction {
// paint.setStrokeWidth(strokeWidth * scaleFactor); // paint.setStrokeWidth(strokeWidth * scaleFactor);
// } // }
public int getLevel() {
return this.level;
}
} }

View File

@ -56,7 +56,12 @@
<style-line name="highway-service" from="residential" width="-0.6" /> <style-line name="highway-service" from="residential" width="-0.6" />
<!-- track|footway|path|cycleway --> <!-- track|footway|path|cycleway -->
<style-line name="footway" stroke="#c1bcb6" width="1.2" cap="butt" fixed="true"/> <style-line name="footway" stroke="#aaffffff" width="1.8" cap="butt" fixed="true"
stipple="16" stipple-width="0.6" stipple-stroke="#cd7750"/>
<style-line name="highway:cycleway" from="footway" width="0.1" stipple-stroke="#4040ee"/>
<style-line name="highway:track" from="footway" width="0.1" stipple="10" stipple-stroke="#c3bb88"/>
<style-line name="highway:path" from="footway" width="0.1" stipple="10" stipple-stroke="#837b58"/>
<!-- <style-line name="footway:z16" from="footway" width="-0.95" fixed="false" fade="-1"/>--> <!-- <style-line name="footway:z16" from="footway" width="-0.95" fixed="false" fade="-1"/>-->
<style-line name="footway:z17" stroke="#faf8f5" width="0.3"/> <style-line name="footway:z17" stroke="#faf8f5" width="0.3"/>
@ -377,10 +382,22 @@
</rule> </rule>
<rule e="way" k="*" v="*" zoom-min="14"> <rule e="way" k="*" v="*" zoom-min="14">
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="16"> <rule e="way" k="*" v="footway" zoom-max="16">
<use-line name="footway"/> <use-line name="footway"/>
</rule> </rule>
<rule e="way" k="*" v="cycleway" zoom-max="16">
<use-line name="highway:cycleway"/>
</rule>
<rule e="way" k="*" v="track" zoom-max="16">
<use-line name="highway:track"/>
</rule>
<rule e="way" k="*" v="path" zoom-max="16">
<use-line name="highway:path"/>
</rule>
<rule e="way" k="*" v="bridleway"> <rule e="way" k="*" v="bridleway">
<use-line name="bridleway"/> <use-line name="bridleway"/>
</rule> </rule>
@ -604,10 +621,22 @@
</rule> </rule>
<rule e="way" k="*" v="*" zoom-min="14"> <rule e="way" k="*" v="*" zoom-min="14">
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="16"> <rule e="way" k="*" v="footway" zoom-max="16">
<use-line name="footway"/> <use-line name="footway"/>
</rule> </rule>
<rule e="way" k="*" v="cycleway" zoom-max="16">
<use-line name="highway:cycleway"/>
</rule>
<rule e="way" k="*" v="track" zoom-max="16">
<use-line name="highway:track"/>
</rule>
<rule e="way" k="*" v="path" zoom-max="16">
<use-line name="highway:path"/>
</rule>
<rule e="way" k="*" v="bridleway"> <rule e="way" k="*" v="bridleway">
<use-line name="bridleway"/> <use-line name="bridleway"/>
</rule> </rule>
@ -704,10 +733,18 @@
</rule> </rule>
<rule e="way" k="*" v="*" zoom-min="14"> <rule e="way" k="*" v="*" zoom-min="14">
<rule e="way" k="*" v="track|footway|path|cycleway" zoom-max="15"> <rule e="way" k="*" v="footway" zoom-max="15">
<use-line name="footway"/> <use-line name="footway"/>
</rule> </rule>
<rule e="way" k="*" v="cycleway" zoom-max="16">
<use-line name="highway:cycleway"/>
</rule>
<rule e="way" k="*" v="track" zoom-max="16">
<use-line name="highway:track"/>
</rule>
<rule e="way" k="*" v="path" zoom-max="16">
<use-line name="highway:path"/>
</rule>
<rule e="way" k="*" v="bridleway"> <rule e="way" k="*" v="bridleway">
<use-line name="bridleway"/> <use-line name="bridleway"/>
</rule> </rule>
@ -882,7 +919,8 @@
</rule> </rule>
<rule e="way" k="railway" v="rail|turntable" zoom-min="15"> <rule e="way" k="railway" v="rail|turntable" zoom-min="15">
<line stroke="#ddaa9988" width="2.0" cap="butt" fixed="true" fade="12" stipple="1"/> <line stroke="#ddaa9988" width="2.0" cap="butt" fixed="true" fade="12"
stipple="4" stipple-width="0.7" stipple-stroke="#ffffff"/>
</rule> </rule>
<!-- <rule e="way" k="railway" v="rail" zoom-max="14" zoom-min="13"> <!-- <rule e="way" k="railway" v="rail" zoom-max="14" zoom-min="13">

View File

@ -113,8 +113,8 @@ public class GlUtils {
} }
return loadTexture(pixel, sum, 1, GLES20.GL_ALPHA, return loadTexture(pixel, sum, 1, GLES20.GL_ALPHA,
GLES20.GL_LINEAR, GLES20.GL_LINEAR, //GLES20.GL_LINEAR, GLES20.GL_LINEAR,
//GLES20.GL_NEAREST, GLES20.GL_NEAREST, GLES20.GL_NEAREST, GLES20.GL_NEAREST,
GLES20.GL_REPEAT, GLES20.GL_REPEAT); GLES20.GL_REPEAT, GLES20.GL_REPEAT);
} }