diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2016-07-05 12:27:00 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2016-07-07 14:32:27 -0700 |
commit | c09fb0f5197be81cca8e925bcfd46c11b871b94e (patch) | |
tree | c4b6ea795e799121a49b68e273e360272be5db84 /src/mbgl | |
parent | c8e87128b1e9f1e49c486fa01533644cf14c78e8 (diff) | |
download | qtlocation-mapboxgl-c09fb0f5197be81cca8e925bcfd46c11b871b94e.tar.gz |
[core] Add support for circle-pitch-scale
Diffstat (limited to 'src/mbgl')
-rw-r--r-- | src/mbgl/renderer/painter_circle.cpp | 16 | ||||
-rw-r--r-- | src/mbgl/shader/circle_shader.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/layers/circle_layer.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/style/layers/circle_layer_properties.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/layers/circle_layer_properties.hpp | 1 | ||||
-rw-r--r-- | src/mbgl/style/property_evaluator.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/style/types.cpp | 5 |
7 files changed, 31 insertions, 4 deletions
diff --git a/src/mbgl/renderer/painter_circle.cpp b/src/mbgl/renderer/painter_circle.cpp index 5bc31f7f81..8e9f1909bb 100644 --- a/src/mbgl/renderer/painter_circle.cpp +++ b/src/mbgl/renderer/painter_circle.cpp @@ -32,10 +32,18 @@ void Painter::renderCircle(CircleBucket& bucket, config.program = circleShader.getID(); circleShader.u_matrix = vtxMatrix; - circleShader->u_extrude_scale = {{ - pixelsToGLUnits[0] * state.getAltitude(), - pixelsToGLUnits[1] * state.getAltitude() - }}; + + if (properties.circlePitchScale == CirclePitchScaleType::Map) { + circleShader.u_extrude_scale = {{ + pixelsToGLUnits[0] * state.getAltitude(), + pixelsToGLUnits[1] * state.getAltitude() + }}; + circleShader.u_scale_with_map = true; + } else { + circleShader.u_extrude_scale = pixelsToGLUnits; + circleShader.u_scale_with_map = false; + } + circleShader.u_devicepixelratio = frame.pixelRatio; circleShader.u_color = properties.circleColor; circleShader.u_radius = properties.circleRadius; diff --git a/src/mbgl/shader/circle_shader.hpp b/src/mbgl/shader/circle_shader.hpp index 34466ace04..c454fc1337 100644 --- a/src/mbgl/shader/circle_shader.hpp +++ b/src/mbgl/shader/circle_shader.hpp @@ -19,6 +19,7 @@ public: Uniform<GLfloat> u_radius = {"u_radius", *this}; Uniform<GLfloat> u_blur = {"u_blur", *this}; Uniform<GLfloat> u_opacity = {"u_opacity", *this}; + Uniform<GLint> u_scale_with_map = {"u_scale_with_map", *this}; }; } // namespace mbgl diff --git a/src/mbgl/style/layers/circle_layer.cpp b/src/mbgl/style/layers/circle_layer.cpp index a47d723548..96cc0b610c 100644 --- a/src/mbgl/style/layers/circle_layer.cpp +++ b/src/mbgl/style/layers/circle_layer.cpp @@ -109,5 +109,13 @@ void CircleLayer::setCircleTranslateAnchor(PropertyValue<TranslateAnchorType> va impl->paint.circleTranslateAnchor.set(value, klass); } +PropertyValue<CirclePitchScaleType> CircleLayer::getCirclePitchScale() const { + return impl->paint.circlePitchScale.get(); +} + +void CircleLayer::setCirclePitchScale(PropertyValue<CirclePitchScaleType> value, const optional<std::string>& klass) { + impl->paint.circlePitchScale.set(value, klass); +} + } // namespace style } // namespace mbgl diff --git a/src/mbgl/style/layers/circle_layer_properties.cpp b/src/mbgl/style/layers/circle_layer_properties.cpp index 045c73ba63..7243cf87f4 100644 --- a/src/mbgl/style/layers/circle_layer_properties.cpp +++ b/src/mbgl/style/layers/circle_layer_properties.cpp @@ -12,6 +12,7 @@ void CirclePaintProperties::cascade(const CascadeParameters& parameters) { circleOpacity.cascade(parameters); circleTranslate.cascade(parameters); circleTranslateAnchor.cascade(parameters); + circlePitchScale.cascade(parameters); } bool CirclePaintProperties::recalculate(const CalculationParameters& parameters) { @@ -23,6 +24,7 @@ bool CirclePaintProperties::recalculate(const CalculationParameters& parameters) hasTransitions |= circleOpacity.calculate(parameters); hasTransitions |= circleTranslate.calculate(parameters); hasTransitions |= circleTranslateAnchor.calculate(parameters); + hasTransitions |= circlePitchScale.calculate(parameters); return hasTransitions; } diff --git a/src/mbgl/style/layers/circle_layer_properties.hpp b/src/mbgl/style/layers/circle_layer_properties.hpp index 40d37dc392..227a67eb6b 100644 --- a/src/mbgl/style/layers/circle_layer_properties.hpp +++ b/src/mbgl/style/layers/circle_layer_properties.hpp @@ -23,6 +23,7 @@ public: PaintProperty<float> circleOpacity { 1 }; PaintProperty<std::array<float, 2>> circleTranslate { {{ 0, 0 }} }; PaintProperty<TranslateAnchorType> circleTranslateAnchor { TranslateAnchorType::Map }; + PaintProperty<CirclePitchScaleType> circlePitchScale { CirclePitchScaleType::Map }; }; } // namespace style diff --git a/src/mbgl/style/property_evaluator.cpp b/src/mbgl/style/property_evaluator.cpp index fd31451d72..abb3681efa 100644 --- a/src/mbgl/style/property_evaluator.cpp +++ b/src/mbgl/style/property_evaluator.cpp @@ -24,6 +24,7 @@ template <> std::array<float, 4> defaultStopsValue() { return {{ 0, 0, 0, 0 }}; template <> std::string defaultStopsValue() { return {}; } template <> TranslateAnchorType defaultStopsValue() { return {}; } template <> RotateAnchorType defaultStopsValue() { return {}; } +template <> CirclePitchScaleType defaultStopsValue() { return {}; } template <> LineCapType defaultStopsValue() { return {}; } template <> LineJoinType defaultStopsValue() { return {}; } template <> SymbolPlacementType defaultStopsValue() { return {}; } @@ -94,6 +95,7 @@ template class PropertyEvaluator<std::array<float, 4>>; template class PropertyEvaluator<std::string>; template class PropertyEvaluator<TranslateAnchorType>; template class PropertyEvaluator<RotateAnchorType>; +template class PropertyEvaluator<CirclePitchScaleType>; template class PropertyEvaluator<LineCapType>; template class PropertyEvaluator<LineJoinType>; template class PropertyEvaluator<SymbolPlacementType>; diff --git a/src/mbgl/style/types.cpp b/src/mbgl/style/types.cpp index 25a1753870..be0b217134 100644 --- a/src/mbgl/style/types.cpp +++ b/src/mbgl/style/types.cpp @@ -28,6 +28,11 @@ MBGL_DEFINE_ENUM(RotateAnchorType, { { RotateAnchorType::Viewport, "viewport" }, }); +MBGL_DEFINE_ENUM(CirclePitchScaleType, { + { CirclePitchScaleType::Map, "map" }, + { CirclePitchScaleType::Viewport, "viewport" }, +}); + MBGL_DEFINE_ENUM(LineCapType, { { LineCapType::Round, "round" }, { LineCapType::Butt, "butt" }, |