diff options
author | Ansis Brammanis <brammanis@gmail.com> | 2017-06-26 15:00:00 -0400 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2017-06-26 15:00:00 -0400 |
commit | d2df457879cc6b39e244ba1858623becec8ddd7d (patch) | |
tree | 72116bdf83b8b51043df913f67bbe7f5d64c2c92 | |
parent | f43b4c0a53271e2d3c70533068fc90d9c82743b6 (diff) | |
download | qtlocation-mapboxgl-d2df457879cc6b39e244ba1858623becec8ddd7d.tar.gz |
horizontal label fix
-rw-r--r-- | src/mbgl/programs/symbol_program.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/shaders/circle.cpp | 21 | ||||
-rw-r--r-- | src/mbgl/text/quads.cpp | 2 |
3 files changed, 16 insertions, 13 deletions
diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp index 2aee09fa7f..1c85be779b 100644 --- a/src/mbgl/programs/symbol_program.cpp +++ b/src/mbgl/programs/symbol_program.cpp @@ -112,9 +112,9 @@ typename SymbolSDFProgram<PaintProperties>::UniformValues SymbolSDFProgram<Paint const TransformState& state, const SymbolSDFPart part) { - const float gammaScale = values.pitchAlignment == AlignmentType::Map - ? std::cos(state.getPitch()) * state.getCameraToCenterDistance() - : 1.0; + const float gammaScale = (values.pitchAlignment == AlignmentType::Map + ? std::cos(state.getPitch()) + : 1.0) * state.getCameraToCenterDistance(); return makeValues<SymbolSDFProgram<PaintProperties>::UniformValues>( isText, diff --git a/src/mbgl/shaders/circle.cpp b/src/mbgl/shaders/circle.cpp index 8f61ce9dfd..081a21db5d 100644 --- a/src/mbgl/shaders/circle.cpp +++ b/src/mbgl/shaders/circle.cpp @@ -132,23 +132,24 @@ void main(void) { // unencode the extrusion vector that we snuck into the a_pos vector - v_extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); + vec2 extrude = vec2(mod(a_pos, 2.0) * 2.0 - 1.0); - vec2 extrude = v_extrude * (radius + stroke_width) * u_extrude_scale; // multiply a_pos by 0.5, since we had it * 2 in order to sneak // in extrusion data gl_Position = u_matrix * vec4(floor(a_pos * 0.5), 0, 1); if (u_scale_with_map) { - gl_Position.xy += extrude; + gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale; } else { - gl_Position.xy += extrude * gl_Position.w; + gl_Position.xy += extrude * (radius + stroke_width) * u_extrude_scale * gl_Position.w; } // This is a minimum blur distance that serves as a faux-antialiasing for // the circle. since blur is a ratio of the circle's size and the intent is // to keep the blur at roughly 1px, the two are inversely related. - v_antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width); + lowp float antialiasblur = 1.0 / DEVICE_PIXEL_RATIO / (radius + stroke_width); + + v_data = vec3(extrude.x, extrude.y, antialiasblur); } )MBGL_SHADER"; @@ -203,8 +204,7 @@ uniform lowp float u_stroke_opacity; #endif -varying vec2 v_extrude; -varying lowp float v_antialiasblur; +varying vec3 v_data; void main() { @@ -243,8 +243,11 @@ void main() { #endif - float extrude_length = length(v_extrude); - float antialiased_blur = -max(blur, v_antialiasblur); + vec2 extrude = v_data.xy; + float extrude_length = length(extrude); + + lowp float antialiasblur = v_data.z; + float antialiased_blur = -max(blur, antialiasblur); float opacity_t = smoothstep(0.0, antialiased_blur, extrude_length - 1.0); diff --git a/src/mbgl/text/quads.cpp b/src/mbgl/text/quads.cpp index b2ef063bd6..6a76600162 100644 --- a/src/mbgl/text/quads.cpp +++ b/src/mbgl/text/quads.cpp @@ -125,7 +125,7 @@ SymbolQuads getGlyphQuads(const Shaping& shapedText, const float x1 = glyph.metrics.left - rectBuffer - halfAdvance + builtInOffset.x; - const float y1 = glyph.metrics.top - rectBuffer + builtInOffset.y; + const float y1 = -glyph.metrics.top - rectBuffer + builtInOffset.y; const float x2 = x1 + rect.w; const float y2 = y1 + rect.h; |