Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

[core] Double maximum label width by reducing glyph precision. #11508

Merged
merged 1 commit into from
Mar 22, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/mbgl/programs/symbol_program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,8 @@ struct SymbolLayoutAttributes : gl::Attributes<
{{
static_cast<int16_t>(labelAnchor.x),
static_cast<int16_t>(labelAnchor.y),
static_cast<int16_t>(::round(o.x * 64)), // use 1/64 pixels for placement
static_cast<int16_t>(::round((o.y + glyphOffsetY) * 64))
static_cast<int16_t>(::round(o.x * 32)), // use 1/32 pixels for placement
static_cast<int16_t>(::round((o.y + glyphOffsetY) * 32))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this seems to differ from the JS version, but it's not a new difference https://github.com/mapbox/mapbox-gl-js/pull/6375/files#diff-c3312919f069eefcab838ca0389b355aR108 – I think what's happening is you add the offset before oy is passed to the js addVertex function so they are in fact the same, but just flagging to making sure

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

}},
{{
tx,
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/shaders/symbol_icon.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ void main() {
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);

vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 64.0 * fontScale), 0.0, 1.0);
gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);

v_tex = a_tex / u_texsize;
vec2 fade_opacity = unpack_opacity(a_fade_opacity);
Expand Down
2 changes: 1 addition & 1 deletion src/mbgl/shaders/symbol_sdf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ void main() {
mat2 rotation_matrix = mat2(angle_cos, -1.0 * angle_sin, angle_sin, angle_cos);

vec4 projected_pos = u_label_plane_matrix * vec4(a_projected_pos.xy, 0.0, 1.0);
gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 64.0 * fontScale), 0.0, 1.0);
gl_Position = u_gl_coord_matrix * vec4(projected_pos.xy / projected_pos.w + rotation_matrix * (a_offset / 32.0 * fontScale), 0.0, 1.0);
float gamma_scale = gl_Position.w;

vec2 tex = a_tex / u_texsize;
Expand Down