diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2015-01-08 14:40:19 -0500 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2015-01-08 14:40:19 -0500 |
commit | 166a3e21fac8632cdf5afdf4d38bf429e45dc699 (patch) | |
tree | 80260b8dca96a33da51a2e5eb2cef8677b7edbe4 /src | |
parent | 59b51f0a9f7062ef4087217149dd30e4f3e941d7 (diff) | |
download | qtlocation-mapboxgl-166a3e21fac8632cdf5afdf4d38bf429e45dc699.tar.gz |
rephrase line uniform calculations to match js
js: 359a576471e20373333cae80a5eccda95ee4cdc2
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/renderer/painter_line.cpp | 20 |
1 files changed, 16 insertions, 4 deletions
diff --git a/src/mbgl/renderer/painter_line.cpp b/src/mbgl/renderer/painter_line.cpp index a25942b2dc..71364f40c4 100644 --- a/src/mbgl/renderer/painter_line.cpp +++ b/src/mbgl/renderer/painter_line.cpp @@ -15,13 +15,25 @@ void Painter::renderLine(LineBucket& bucket, util::ptr<StyleLayer> layer_desc, c const LineProperties &properties = layer_desc->getProperties<LineProperties>(); + // the distance over which the line edge fades out. + // Retina devices need a smaller distance to avoid aliasing. float antialiasing = 1 / state.getPixelRatio(); - float width = properties.width; - float offset = properties.gap_width == 0 ? 0 : (properties.gap_width + width) / 2; + float blur = properties.blur + antialiasing; + float edgeWidth = properties.width / 2.0; + float inset = -1; + float offset = 0; + float shift = 0; + + if (properties.gap_width != 0) { + inset = properties.gap_width / 2.0 + antialiasing * 0.5; + edgeWidth = properties.width; + + // shift outer lines half a pixel towards the middle to eliminate the crack + offset = inset - antialiasing / 2.0; + } - float inset = std::fmin((std::fmax(-1, offset - width / 2 - antialiasing / 2) + 1), 16.0f); - float outset = std::fmin(offset + width / 2 + antialiasing / 2, 16.0f); + float outset = offset + edgeWidth + antialiasing / 2.0 + shift; Color color = properties.color; color[0] *= properties.opacity; |