refactor for readability

This commit is contained in:
Hannes Janetzek 2012-09-26 21:16:11 +02:00
parent 4fafce24b8
commit 7b247f3af3

View File

@ -109,10 +109,15 @@ class LineRenderer {
// line scale factor (for non fixed lines) // line scale factor (for non fixed lines)
float lineScale = FloatMath.sqrt(s); float lineScale = FloatMath.sqrt(s);
float blurScale = pixel;
boolean blur = false; boolean blur = false;
// dont increase scale when max is reached
boolean strokeMaxZoom = zoom > TileGenerator.STROKE_MAX_ZOOM_LEVEL;
float width = 1;
LineLayer l = layer; LineLayer l = layer;
for (; l != null && l.layer < next; l = l.next) { for (; l != null && l.layer < next; l = l.next) {
Line line = l.line; Line line = l.line;
if (line.fade != -1 && line.fade > zoom) if (line.fade != -1 && line.fade > zoom)
continue; continue;
@ -124,7 +129,7 @@ class LineRenderer {
GlUtils.setColor(hLineColor[mode], line.color, alpha); GlUtils.setColor(hLineColor[mode], line.color, alpha);
if (blur) { if (blur && line.blur == 0) {
GLES20.glUniform1f(hLineScale[mode], pixel); GLES20.glUniform1f(hLineScale[mode], pixel);
blur = false; blur = false;
} }
@ -132,38 +137,43 @@ class LineRenderer {
if (l.isOutline) { if (l.isOutline) {
for (LineLayer o = l.outlines; o != null; o = o.outlines) { for (LineLayer o = l.outlines; o != null; o = o.outlines) {
if (o.line.fixed || strokeMaxZoom) {
width = (l.width + o.width) / s;
} else {
width = l.width / s + o.width / lineScale;
}
GLES20.glUniform1f(hLineWidth[mode], width);
if (line.blur != 0) { if (line.blur != 0) {
GLES20.glUniform1f(hLineScale[mode], (l.width + o.width) / s blurScale = (l.width + o.width) / s - (line.blur / s);
- (line.blur / s)); GLES20.glUniform1f(hLineScale[mode], blurScale);
blur = true; blur = true;
} }
if (zoom > TileGenerator.STROKE_MAX_ZOOM_LEVEL)
GLES20.glUniform1f(hLineWidth[mode], (l.width + o.width) / s);
else
GLES20.glUniform1f(hLineWidth[mode], l.width / s + o.width
/ lineScale);
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, o.offset, o.verticesCnt); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, o.offset, o.verticesCnt);
} }
} } else {
else {
if (line.blur != 0) {
GLES20.glUniform1f(hLineScale[mode], (l.width / lineScale)
* line.blur);
blur = true;
}
if (line.fixed || zoom > TileGenerator.STROKE_MAX_ZOOM_LEVEL) { if (line.fixed || strokeMaxZoom) {
// invert scaling of extrusion vectors so that line width // invert scaling of extrusion vectors so that line width
// stays the same. // stays the same.
GLES20.glUniform1f(hLineWidth[mode], l.width / s); width = l.width / s;
} else { } else {
GLES20.glUniform1f(hLineWidth[mode], l.width / lineScale); width = l.width / lineScale;
}
GLES20.glUniform1f(hLineWidth[mode], width);
if (line.blur != 0) {
blurScale = (l.width / lineScale) * line.blur;
GLES20.glUniform1f(hLineScale[mode], blurScale);
blur = true;
} }
GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, l.offset, l.verticesCnt); GLES20.glDrawArrays(GLES20.GL_TRIANGLE_STRIP, l.offset, l.verticesCnt);
} }
} }
GLES20.glDisableVertexAttribArray(hLineVertexPosition[mode]); GLES20.glDisableVertexAttribArray(hLineVertexPosition[mode]);