diff options
author | Chris Loer <chris.loer@gmail.com> | 2017-05-17 21:40:57 -0700 |
---|---|---|
committer | Ansis Brammanis <brammanis@gmail.com> | 2017-07-11 09:10:23 -0700 |
commit | 8f5e0b66ab13cff7d35ed46afaddbdca9ab1993f (patch) | |
tree | 49b45a6327092a9affa9fd4fd1b3f2764df4b180 /src/mbgl/programs | |
parent | 59df3a90f41461562a80688337ec53687e341124 (diff) | |
download | qtlocation-mapboxgl-8f5e0b66ab13cff7d35ed46afaddbdca9ab1993f.tar.gz |
[core] Pass pitch-scaling vertex attributes and uniforms to shaders.
Diffstat (limited to 'src/mbgl/programs')
-rw-r--r-- | src/mbgl/programs/attributes.hpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/collision_box_program.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/programs/collision_box_program.hpp | 12 | ||||
-rw-r--r-- | src/mbgl/programs/symbol_program.cpp | 6 | ||||
-rw-r--r-- | src/mbgl/programs/symbol_program.hpp | 21 | ||||
-rw-r--r-- | src/mbgl/programs/uniforms.hpp | 2 |
6 files changed, 36 insertions, 9 deletions
diff --git a/src/mbgl/programs/attributes.hpp b/src/mbgl/programs/attributes.hpp index 8f2751080f..f39af2deec 100644 --- a/src/mbgl/programs/attributes.hpp +++ b/src/mbgl/programs/attributes.hpp @@ -23,6 +23,8 @@ inline uint16_t packUint8Pair(T a, T b) { MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_pos); MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_extrude); MBGL_DEFINE_ATTRIBUTE(int16_t, 4, a_pos_offset); +MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_label_pos); +MBGL_DEFINE_ATTRIBUTE(int16_t, 2, a_anchor_pos); MBGL_DEFINE_ATTRIBUTE(uint16_t, 2, a_texture_pos); MBGL_DEFINE_ATTRIBUTE(int16_t, 3, a_normal); MBGL_DEFINE_ATTRIBUTE(uint16_t, 1, a_edgedistance); diff --git a/src/mbgl/programs/collision_box_program.cpp b/src/mbgl/programs/collision_box_program.cpp index a3dc01ebe4..57107db75d 100644 --- a/src/mbgl/programs/collision_box_program.cpp +++ b/src/mbgl/programs/collision_box_program.cpp @@ -2,6 +2,6 @@ namespace mbgl { -static_assert(sizeof(CollisionBoxProgram::LayoutVertex) == 10, "expected CollisionBoxVertex size"); +static_assert(sizeof(CollisionBoxProgram::LayoutVertex) == 14, "expected CollisionBoxVertex size"); } // namespace mbgl diff --git a/src/mbgl/programs/collision_box_program.hpp b/src/mbgl/programs/collision_box_program.hpp index 160fd42814..3b4260bb78 100644 --- a/src/mbgl/programs/collision_box_program.hpp +++ b/src/mbgl/programs/collision_box_program.hpp @@ -18,6 +18,7 @@ MBGL_DEFINE_UNIFORM_SCALAR(float, u_maxzoom); using CollisionBoxAttributes = gl::Attributes< attributes::a_pos, + attributes::a_anchor_pos, attributes::a_extrude, attributes::a_data<uint8_t, 2>>; @@ -29,19 +30,26 @@ class CollisionBoxProgram : public Program< uniforms::u_matrix, uniforms::u_scale, uniforms::u_zoom, - uniforms::u_maxzoom>, + uniforms::u_maxzoom, + uniforms::u_collision_y_stretch, + uniforms::u_camera_to_center_distance, + uniforms::u_pitch>, style::Properties<>> { public: using Program::Program; - static LayoutVertex vertex(Point<float> a, Point<float> o, float maxzoom, float placementZoom) { + static LayoutVertex vertex(Point<float> a, Point<float> anchor, Point<float> o, float maxzoom, float placementZoom) { return LayoutVertex { {{ static_cast<int16_t>(a.x), static_cast<int16_t>(a.y) }}, {{ + static_cast<int16_t>(anchor.x), + static_cast<int16_t>(anchor.y) + }}, + {{ static_cast<int16_t>(::round(o.x)), static_cast<int16_t>(::round(o.y)) }}, diff --git a/src/mbgl/programs/symbol_program.cpp b/src/mbgl/programs/symbol_program.cpp index 789eed0dd8..1b5a7d9bff 100644 --- a/src/mbgl/programs/symbol_program.cpp +++ b/src/mbgl/programs/symbol_program.cpp @@ -10,7 +10,7 @@ namespace mbgl { using namespace style; -static_assert(sizeof(SymbolLayoutVertex) == 16, "expected SymbolLayoutVertex size"); +static_assert(sizeof(SymbolLayoutVertex) == 20, "expected SymbolLayoutVertex size"); std::unique_ptr<SymbolSizeBinder> SymbolSizeBinder::create(const float tileZoom, const style::DataDrivenPropertyValue<float>& sizeProperty, @@ -59,6 +59,9 @@ Values makeValues(const bool isText, uniforms::u_fadetexture::Value{ 1 }, uniforms::u_is_text::Value{ isText }, uniforms::u_collision_y_stretch::Value{ tile.tile.yStretch() }, + uniforms::u_camera_to_center_distance::Value{ state.getCameraToCenterDistance() }, + uniforms::u_pitch::Value{ state.getPitch() }, + uniforms::u_max_camera_distance::Value{ 10.0f }, std::forward<Args>(args)... }; } @@ -103,7 +106,6 @@ typename SymbolSDFProgram<PaintProperties>::UniformValues SymbolSDFProgram<Paint tile, state, uniforms::u_gamma_scale::Value{ gammaScale }, - uniforms::u_pitch::Value{ state.getPitch() }, uniforms::u_bearing::Value{ -1.0f * state.getAngle() }, uniforms::u_aspect_ratio::Value{ (state.getSize().width * 1.0f) / (state.getSize().height * 1.0f) }, uniforms::u_pitch_with_map::Value{ values.pitchAlignment == AlignmentType::Map }, diff --git a/src/mbgl/programs/symbol_program.hpp b/src/mbgl/programs/symbol_program.hpp index d1a6b4b994..c38ed04a1e 100644 --- a/src/mbgl/programs/symbol_program.hpp +++ b/src/mbgl/programs/symbol_program.hpp @@ -42,15 +42,17 @@ MBGL_DEFINE_UNIFORM_SCALAR(bool, u_is_size_feature_constant); MBGL_DEFINE_UNIFORM_SCALAR(float, u_size_t); MBGL_DEFINE_UNIFORM_SCALAR(float, u_size); MBGL_DEFINE_UNIFORM_SCALAR(float, u_layout_size); -MBGL_DEFINE_UNIFORM_SCALAR(float, u_collision_y_stretch); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_max_camera_distance); } // namespace uniforms struct SymbolLayoutAttributes : gl::Attributes< attributes::a_pos_offset, + attributes::a_label_pos, attributes::a_data<uint16_t, 4>> { static Vertex vertex(Point<float> a, Point<float> o, + Point<float> labelAnchor, uint16_t tx, uint16_t ty, float minzoom, @@ -66,6 +68,10 @@ struct SymbolLayoutAttributes : gl::Attributes< static_cast<int16_t>(::round(o.y * 64)) }}, {{ + static_cast<int16_t>(labelAnchor.x), + static_cast<int16_t>(labelAnchor.y) + }}, + {{ tx, ty, mbgl::attributes::packUint8Pair( @@ -391,7 +397,10 @@ class SymbolIconProgram : public SymbolProgram< uniforms::u_texture, uniforms::u_fadetexture, uniforms::u_is_text, - uniforms::u_collision_y_stretch>, + uniforms::u_collision_y_stretch, + uniforms::u_camera_to_center_distance, + uniforms::u_pitch, + uniforms::u_max_camera_distance>, style::IconPaintProperties> { public: @@ -425,8 +434,10 @@ class SymbolSDFProgram : public SymbolProgram< uniforms::u_fadetexture, uniforms::u_is_text, uniforms::u_collision_y_stretch, - uniforms::u_gamma_scale, + uniforms::u_camera_to_center_distance, uniforms::u_pitch, + uniforms::u_max_camera_distance, + uniforms::u_gamma_scale, uniforms::u_bearing, uniforms::u_aspect_ratio, uniforms::u_pitch_with_map, @@ -447,8 +458,10 @@ public: uniforms::u_fadetexture, uniforms::u_is_text, uniforms::u_collision_y_stretch, - uniforms::u_gamma_scale, + uniforms::u_camera_to_center_distance, uniforms::u_pitch, + uniforms::u_max_camera_distance, + uniforms::u_gamma_scale, uniforms::u_bearing, uniforms::u_aspect_ratio, uniforms::u_pitch_with_map, diff --git a/src/mbgl/programs/uniforms.hpp b/src/mbgl/programs/uniforms.hpp index c8f8684ba1..8d606dcf08 100644 --- a/src/mbgl/programs/uniforms.hpp +++ b/src/mbgl/programs/uniforms.hpp @@ -14,6 +14,8 @@ MBGL_DEFINE_UNIFORM_SCALAR(Color, u_color); MBGL_DEFINE_UNIFORM_SCALAR(float, u_blur); MBGL_DEFINE_UNIFORM_SCALAR(float, u_zoom); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_collision_y_stretch); +MBGL_DEFINE_UNIFORM_SCALAR(float, u_camera_to_center_distance); MBGL_DEFINE_UNIFORM_SCALAR(float, u_pitch); MBGL_DEFINE_UNIFORM_SCALAR(float, u_bearing); MBGL_DEFINE_UNIFORM_SCALAR(float, u_radius); |