summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2018-07-23 16:08:44 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2018-07-24 11:08:40 -0700
commit2bbc79206073d260863c887a95ee4ba25bc45910 (patch)
tree4478ba0db1d873ed35e80b7e342100d85728ed18 /src
parentcb714d57c5c5ad181aaf5e1690221da8d965682b (diff)
downloadqtlocation-mapboxgl-2bbc79206073d260863c887a95ee4ba25bc45910.tar.gz
[core] Check all bucket dynamic_casts
A mismatch can occur when a layer changes from one type to another.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/renderer/layers/render_circle_layer.cpp7
-rw-r--r--src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp16
-rw-r--r--src/mbgl/renderer/layers/render_fill_layer.cpp14
-rw-r--r--src/mbgl/renderer/layers/render_heatmap_layer.cpp7
-rw-r--r--src/mbgl/renderer/layers/render_hillshade_layer.cpp8
-rw-r--r--src/mbgl/renderer/layers/render_line_layer.cpp7
-rw-r--r--src/mbgl/renderer/layers/render_raster_layer.cpp7
-rw-r--r--src/mbgl/renderer/layers/render_symbol_layer.cpp7
-rw-r--r--src/mbgl/text/cross_tile_symbol_index.cpp9
-rw-r--r--src/mbgl/text/placement.cpp22
10 files changed, 70 insertions, 34 deletions
diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp
index b433a9d3fa..b1b4d22561 100644
--- a/src/mbgl/renderer/layers/render_circle_layer.cpp
+++ b/src/mbgl/renderer/layers/render_circle_layer.cpp
@@ -56,8 +56,11 @@ void RenderCircleLayer::render(PaintParameters& parameters, RenderSource*) {
const bool pitchWithMap = evaluated.get<CirclePitchAlignment>() == AlignmentType::Map;
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl)));
- CircleBucket& bucket = *reinterpret_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<CircleBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ CircleBucket& bucket = *bucket_;
const auto& paintPropertyBinders = bucket.paintPropertyBinders.at(getID());
diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
index d5282c9b0d..d37f6f528b 100644
--- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp
@@ -100,9 +100,11 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
if (evaluated.get<FillExtrusionPattern>().from.empty()) {
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)));
- FillExtrusionBucket& bucket =
- *reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ FillExtrusionBucket& bucket = *bucket_;
draw(
parameters.programs.fillExtrusion.get(evaluated),
@@ -129,9 +131,11 @@ void RenderFillExtrusionLayer::render(PaintParameters& parameters, RenderSource*
parameters.imageManager.bind(parameters.context, 0);
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl)));
- FillExtrusionBucket& bucket =
- *reinterpret_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<FillExtrusionBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ FillExtrusionBucket& bucket = *bucket_;
draw(
parameters.programs.fillExtrusionPattern.get(evaluated),
diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp
index c59ca6f906..cce4399262 100644
--- a/src/mbgl/renderer/layers/render_fill_layer.cpp
+++ b/src/mbgl/renderer/layers/render_fill_layer.cpp
@@ -61,8 +61,11 @@ bool RenderFillLayer::hasTransition() const {
void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
if (evaluated.get<FillPattern>().from.empty()) {
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
- FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ FillBucket& bucket = *bucket_;
auto draw = [&] (auto& program,
const auto& drawMode,
@@ -146,8 +149,11 @@ void RenderFillLayer::render(PaintParameters& parameters, RenderSource*) {
parameters.imageManager.bind(parameters.context, 0);
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl)));
- FillBucket& bucket = *reinterpret_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<FillBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ FillBucket& bucket = *bucket_;
auto draw = [&] (auto& program,
const auto& drawMode,
diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
index dec9edb318..d2c6f6d970 100644
--- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp
+++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp
@@ -83,8 +83,11 @@ void RenderHeatmapLayer::render(PaintParameters& parameters, RenderSource*) {
parameters.context.clear(Color{ 0.0f, 0.0f, 0.0f, 1.0f }, {}, {});
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl)));
- HeatmapBucket& bucket = *reinterpret_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<HeatmapBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ HeatmapBucket& bucket = *bucket_;
const auto extrudeScale = tile.id.pixelsToTileUnits(1, parameters.state.getZoom());
diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
index 411305edf4..0edc8737c1 100644
--- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp
+++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
@@ -114,8 +114,12 @@ void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src
matrix::translate(mat, mat, 0, -util::EXTENT, 0);
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<HillshadeBucket*>(tile.tile.getBucket(*baseImpl)));
- HillshadeBucket& bucket = *reinterpret_cast<HillshadeBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<HillshadeBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ HillshadeBucket& bucket = *bucket_;
+
if (!bucket.hasData()){
continue;
}
diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp
index 361ad0c76b..ea51705792 100644
--- a/src/mbgl/renderer/layers/render_line_layer.cpp
+++ b/src/mbgl/renderer/layers/render_line_layer.cpp
@@ -58,8 +58,11 @@ void RenderLineLayer::render(PaintParameters& parameters, RenderSource*) {
}
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<LineBucket*>(tile.tile.getBucket(*baseImpl)));
- LineBucket& bucket = *reinterpret_cast<LineBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<LineBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ LineBucket& bucket = *bucket_;
auto draw = [&] (auto& program, auto&& uniformValues) {
auto& programInstance = program.get(evaluated);
diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp
index f31f53481f..13f2f5e38c 100644
--- a/src/mbgl/renderer/layers/render_raster_layer.cpp
+++ b/src/mbgl/renderer/layers/render_raster_layer.cpp
@@ -142,8 +142,11 @@ void RenderRasterLayer::render(PaintParameters& parameters, RenderSource* source
}
} else {
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<RasterBucket*>(tile.tile.getBucket(*baseImpl)));
- RasterBucket& bucket = *reinterpret_cast<RasterBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<RasterBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ RasterBucket& bucket = *bucket_;
if (!bucket.hasData())
continue;
diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp
index 861112526b..d397ffd724 100644
--- a/src/mbgl/renderer/layers/render_symbol_layer.cpp
+++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp
@@ -75,8 +75,11 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
}
for (const RenderTile& tile : renderTiles) {
- assert(dynamic_cast<SymbolBucket*>(tile.tile.getBucket(*baseImpl)));
- SymbolBucket& bucket = *reinterpret_cast<SymbolBucket*>(tile.tile.getBucket(*baseImpl));
+ auto bucket_ = dynamic_cast<SymbolBucket*>(tile.tile.getBucket(*baseImpl));
+ if (!bucket_) {
+ continue;
+ }
+ SymbolBucket& bucket = *bucket_;
const auto& layout = bucket.layout;
diff --git a/src/mbgl/text/cross_tile_symbol_index.cpp b/src/mbgl/text/cross_tile_symbol_index.cpp
index 8df26ca117..58dcda46f5 100644
--- a/src/mbgl/text/cross_tile_symbol_index.cpp
+++ b/src/mbgl/text/cross_tile_symbol_index.cpp
@@ -178,9 +178,12 @@ bool CrossTileSymbolIndex::addLayer(RenderSymbolLayer& symbolLayer, float lng) {
continue;
}
- auto bucket = renderTile.tile.getBucket(*symbolLayer.baseImpl);
- assert(dynamic_cast<SymbolBucket*>(bucket));
- SymbolBucket& symbolBucket = *reinterpret_cast<SymbolBucket*>(bucket);
+ auto bucket = dynamic_cast<SymbolBucket*>(renderTile.tile.getBucket(*symbolLayer.baseImpl));
+ if (!bucket) {
+ continue;
+ }
+ SymbolBucket& symbolBucket = *bucket;
+
if (symbolBucket.bucketLeaderID != symbolLayer.getID()) {
// Only add this layer if it's the "group leader" for the bucket
continue;
diff --git a/src/mbgl/text/placement.cpp b/src/mbgl/text/placement.cpp
index fd0710d959..96c1873e33 100644
--- a/src/mbgl/text/placement.cpp
+++ b/src/mbgl/text/placement.cpp
@@ -50,12 +50,13 @@ void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatri
}
assert(dynamic_cast<GeometryTile*>(&renderTile.tile));
GeometryTile& geometryTile = static_cast<GeometryTile&>(renderTile.tile);
-
-
- auto bucket = geometryTile.getBucket(*symbolLayer.baseImpl);
- assert(dynamic_cast<SymbolBucket*>(bucket));
- SymbolBucket& symbolBucket = *reinterpret_cast<SymbolBucket*>(bucket);
-
+
+ auto bucket = dynamic_cast<SymbolBucket*>(geometryTile.getBucket(*symbolLayer.baseImpl));
+ if (!bucket) {
+ continue;
+ }
+ SymbolBucket& symbolBucket = *bucket;
+
if (symbolBucket.bucketLeaderID != symbolLayer.getID()) {
// Only place this layer if it's the "group leader" for the bucket
continue;
@@ -231,9 +232,12 @@ void Placement::updateLayerOpacities(RenderSymbolLayer& symbolLayer) {
continue;
}
- auto bucket = renderTile.tile.getBucket(*symbolLayer.baseImpl);
- assert(dynamic_cast<SymbolBucket*>(bucket));
- SymbolBucket& symbolBucket = *reinterpret_cast<SymbolBucket*>(bucket);
+ auto bucket = dynamic_cast<SymbolBucket*>(renderTile.tile.getBucket(*symbolLayer.baseImpl));
+ if (!bucket) {
+ continue;
+ }
+ SymbolBucket& symbolBucket = *bucket;
+
if (symbolBucket.bucketLeaderID != symbolLayer.getID()) {
// Only update opacities this layer if it's the "group leader" for the bucket
continue;