summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/renderer/buckets/circle_bucket.cpp7
-rw-r--r--src/mbgl/renderer/buckets/fill_bucket.cpp8
-rw-r--r--src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp7
-rw-r--r--src/mbgl/renderer/buckets/line_bucket.cpp8
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp4
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.hpp4
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.hpp4
7 files changed, 18 insertions, 24 deletions
diff --git a/src/mbgl/renderer/buckets/circle_bucket.cpp b/src/mbgl/renderer/buckets/circle_bucket.cpp
index 7e08b3c96b..51da3eb892 100644
--- a/src/mbgl/renderer/buckets/circle_bucket.cpp
+++ b/src/mbgl/renderer/buckets/circle_bucket.cpp
@@ -104,12 +104,7 @@ static float get(const RenderCircleLayer& layer, const std::map<std::string, Cir
}
float CircleBucket::getQueryRadius(const RenderLayer& layer) const {
- if (!layer.is<RenderCircleLayer>()) {
- return 0;
- }
-
- auto circleLayer = layer.as<RenderCircleLayer>();
-
+ const RenderCircleLayer* circleLayer = toRenderCircleLayer(&layer);
float radius = get<CircleRadius>(*circleLayer, paintPropertyBinders);
float stroke = get<CircleStrokeWidth>(*circleLayer, paintPropertyBinders);
auto translate = circleLayer->evaluated.get<CircleTranslate>();
diff --git a/src/mbgl/renderer/buckets/fill_bucket.cpp b/src/mbgl/renderer/buckets/fill_bucket.cpp
index 3b1b7ec00f..043882f138 100644
--- a/src/mbgl/renderer/buckets/fill_bucket.cpp
+++ b/src/mbgl/renderer/buckets/fill_bucket.cpp
@@ -137,13 +137,9 @@ bool FillBucket::hasData() const {
}
float FillBucket::getQueryRadius(const RenderLayer& layer) const {
- if (!layer.is<RenderFillLayer>()) {
- return 0;
- }
-
- const std::array<float, 2>& translate = layer.as<RenderFillLayer>()->evaluated.get<FillTranslate>();
+ const RenderFillLayer* fillLayer = toRenderFillLayer(&layer);
+ const std::array<float, 2>& translate = fillLayer->evaluated.get<FillTranslate>();
return util::length(translate[0], translate[1]);
-
}
} // namespace mbgl
diff --git a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp
index fb491e0db2..177c6e0c23 100644
--- a/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp
+++ b/src/mbgl/renderer/buckets/fill_extrusion_bucket.cpp
@@ -181,11 +181,8 @@ bool FillExtrusionBucket::hasData() const {
}
float FillExtrusionBucket::getQueryRadius(const RenderLayer& layer) const {
- if (!layer.is<RenderFillExtrusionLayer>()) {
- return 0;
- }
-
- const std::array<float, 2>& translate = layer.as<RenderFillExtrusionLayer>()->evaluated.get<FillExtrusionTranslate>();
+ const RenderFillExtrusionLayer* fillExtrusionLayer = toRenderFillExtrusionLayer(&layer);
+ const std::array<float, 2>& translate = fillExtrusionLayer->evaluated.get<FillExtrusionTranslate>();
return util::length(translate[0], translate[1]);
}
diff --git a/src/mbgl/renderer/buckets/line_bucket.cpp b/src/mbgl/renderer/buckets/line_bucket.cpp
index 2efb60c9ac..ace6c8bfae 100644
--- a/src/mbgl/renderer/buckets/line_bucket.cpp
+++ b/src/mbgl/renderer/buckets/line_bucket.cpp
@@ -545,16 +545,10 @@ float LineBucket::getLineWidth(const RenderLineLayer& layer) const {
}
float LineBucket::getQueryRadius(const RenderLayer& layer) const {
- if (!layer.is<RenderLineLayer>()) {
- return 0;
- }
-
- auto lineLayer = layer.as<RenderLineLayer>();
-
+ const RenderLineLayer* lineLayer = toRenderLineLayer(&layer);
const std::array<float, 2>& translate = lineLayer->evaluated.get<LineTranslate>();
float offset = get<LineOffset>(*lineLayer, paintPropertyBinders);
return getLineWidth(*lineLayer) / 2.0 + std::abs(offset) + util::length(translate[0], translate[1]);
}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp
index b9684b73f6..a7d128dc08 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.hpp
@@ -56,4 +56,8 @@ inline bool RenderLayer::is<RenderFillExtrusionLayer>() const {
return type == style::LayerType::FillExtrusion;
}
+inline const RenderFillExtrusionLayer* toRenderFillExtrusionLayer(const RenderLayer* layer) {
+ return static_cast<const RenderFillExtrusionLayer*>(layer);
+}
+
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_fill_layer.hpp b/src/mbgl/renderer/layers/render_fill_layer.hpp
index 41926e1305..48168a6234 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.hpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.hpp
@@ -51,4 +51,8 @@ inline bool RenderLayer::is<RenderFillLayer>() const {
return type == style::LayerType::Fill;
}
+inline const RenderFillLayer* toRenderFillLayer(const RenderLayer* layer) {
+ return static_cast<const RenderFillLayer*>(layer);
+}
+
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_line_layer.hpp b/src/mbgl/renderer/layers/render_line_layer.hpp
index 1b26419238..737aa2e5bc 100644
--- a/src/mbgl/renderer/layers/render_line_layer.hpp
+++ b/src/mbgl/renderer/layers/render_line_layer.hpp
@@ -71,4 +71,8 @@ inline bool RenderLayer::is<RenderLineLayer>() const {
return type == style::LayerType::Line;
}
+inline const RenderLineLayer* toRenderLineLayer(const RenderLayer* layer) {
+ return static_cast<const RenderLineLayer*>(layer);
+}
+
} // namespace mbgl