summaryrefslogtreecommitdiff
path: root/src/mbgl
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-03 12:09:28 +0300
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2019-07-04 16:56:43 +0300
commit8b78398190a5a7957d507c33b41af841e112a91b (patch)
treeef549563154e35e6fdcd980edc0cd557a5c58cc0 /src/mbgl
parent115512153064276d23bb865d1947e669eb022b50 (diff)
downloadqtlocation-mapboxgl-8b78398190a5a7957d507c33b41af841e112a91b.tar.gz
[core] Remove down-casting of render sources
Diffstat (limited to 'src/mbgl')
-rw-r--r--src/mbgl/annotation/render_annotation_source.hpp5
-rw-r--r--src/mbgl/renderer/layers/render_hillshade_layer.cpp4
-rw-r--r--src/mbgl/renderer/render_source.cpp6
-rw-r--r--src/mbgl/renderer/render_source.hpp17
-rw-r--r--src/mbgl/renderer/sources/render_custom_geometry_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_geojson_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_image_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_raster_dem_source.hpp7
-rw-r--r--src/mbgl/renderer/sources/render_raster_source.hpp5
-rw-r--r--src/mbgl/renderer/sources/render_vector_source.hpp5
10 files changed, 10 insertions, 54 deletions
diff --git a/src/mbgl/annotation/render_annotation_source.hpp b/src/mbgl/annotation/render_annotation_source.hpp
index e5d5130446..948a0b0d8d 100644
--- a/src/mbgl/annotation/render_annotation_source.hpp
+++ b/src/mbgl/annotation/render_annotation_source.hpp
@@ -29,9 +29,4 @@ private:
const AnnotationSource::Impl& impl() const;
};
-template <>
-inline bool RenderSource::is<RenderAnnotationSource>() const {
- return baseImpl->type == style::SourceType::Annotations;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
index aa34814036..2cbb77f24b 100644
--- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp
+++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp
@@ -67,9 +67,7 @@ bool RenderHillshadeLayer::hasCrossfade() const {
void RenderHillshadeLayer::prepare(const LayerPrepareParameters& params) {
RenderLayer::prepare(params);
- if (auto* demsrc = params.source->as<RenderRasterDEMSource>()) {
- maxzoom = demsrc->getMaxZoom();
- }
+ maxzoom = params.source->getMaxZoom();
}
void RenderHillshadeLayer::render(PaintParameters& parameters) {
diff --git a/src/mbgl/renderer/render_source.cpp b/src/mbgl/renderer/render_source.cpp
index d0f5689a9e..7b47602cd1 100644
--- a/src/mbgl/renderer/render_source.cpp
+++ b/src/mbgl/renderer/render_source.cpp
@@ -11,6 +11,7 @@
#include <mbgl/tile/tile.hpp>
#include <mbgl/layermanager/layer_manager.hpp>
+#include <mbgl/util/constants.hpp>
#include <utility>
namespace mbgl {
@@ -73,4 +74,9 @@ bool RenderSource::isEnabled() const {
return enabled;
}
+uint8_t RenderSource::getMaxZoom() const {
+ assert(false);
+ return util::TERRAIN_RGB_MAXZOOM;
+}
+
} // namespace mbgl
diff --git a/src/mbgl/renderer/render_source.hpp b/src/mbgl/renderer/render_source.hpp
index 2603aa1273..d9af901664 100644
--- a/src/mbgl/renderer/render_source.hpp
+++ b/src/mbgl/renderer/render_source.hpp
@@ -47,21 +47,6 @@ public:
static std::unique_ptr<RenderSource> create(Immutable<style::Source::Impl>);
virtual ~RenderSource();
- // Check whether this source is of the given subtype.
- template <class T>
- bool is() const;
-
- // Dynamically cast this source to the given subtype.
- template <class T>
- T* as() {
- return is<T>() ? reinterpret_cast<T*>(this) : nullptr;
- }
-
- template <class T>
- const T* as() const {
- return is<T>() ? reinterpret_cast<const T*>(this) : nullptr;
- }
-
bool isEnabled() const;
virtual bool isLoaded() const = 0;
@@ -103,6 +88,8 @@ public:
virtual void dumpDebugLogs() const = 0;
+ virtual uint8_t getMaxZoom() const;
+
void setObserver(RenderSourceObserver*);
Immutable<style::Source::Impl> baseImpl;
diff --git a/src/mbgl/renderer/sources/render_custom_geometry_source.hpp b/src/mbgl/renderer/sources/render_custom_geometry_source.hpp
index 331ae455e7..e94af0473f 100644
--- a/src/mbgl/renderer/sources/render_custom_geometry_source.hpp
+++ b/src/mbgl/renderer/sources/render_custom_geometry_source.hpp
@@ -19,9 +19,4 @@ private:
const style::CustomGeometrySource::Impl& impl() const;
};
-template <>
-inline bool RenderSource::is<RenderCustomGeometrySource>() const {
- return baseImpl->type == style::SourceType::CustomVector;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_geojson_source.hpp b/src/mbgl/renderer/sources/render_geojson_source.hpp
index 3896457806..8e923362b9 100644
--- a/src/mbgl/renderer/sources/render_geojson_source.hpp
+++ b/src/mbgl/renderer/sources/render_geojson_source.hpp
@@ -32,9 +32,4 @@ private:
std::weak_ptr<style::GeoJSONData> data;
};
-template <>
-inline bool RenderSource::is<RenderGeoJSONSource>() const {
- return baseImpl->type == style::SourceType::GeoJSON;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_image_source.hpp b/src/mbgl/renderer/sources/render_image_source.hpp
index ac9bdbecb7..804daeef87 100644
--- a/src/mbgl/renderer/sources/render_image_source.hpp
+++ b/src/mbgl/renderer/sources/render_image_source.hpp
@@ -68,9 +68,4 @@ private:
std::vector<UnwrappedTileID> tileIds;
};
-template <>
-inline bool RenderSource::is<RenderImageSource>() const {
- return baseImpl->type == style::SourceType::Image;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_raster_dem_source.hpp b/src/mbgl/renderer/sources/render_raster_dem_source.hpp
index d1e7f03e10..e49ad1d1d4 100644
--- a/src/mbgl/renderer/sources/render_raster_dem_source.hpp
+++ b/src/mbgl/renderer/sources/render_raster_dem_source.hpp
@@ -26,7 +26,7 @@ public:
std::vector<Feature>
querySourceFeatures(const SourceQueryOptions&) const override;
- uint8_t getMaxZoom() const { return maxzoom; }
+ uint8_t getMaxZoom() const override { return maxzoom; }
private:
const style::RasterSource::Impl& impl() const;
@@ -37,9 +37,4 @@ private:
void onTileChanged(Tile&) override;
};
-template <>
-inline bool RenderSource::is<RenderRasterDEMSource>() const {
- return baseImpl->type == style::SourceType::RasterDEM;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_raster_source.hpp b/src/mbgl/renderer/sources/render_raster_source.hpp
index ec6d7f2474..dc80630add 100644
--- a/src/mbgl/renderer/sources/render_raster_source.hpp
+++ b/src/mbgl/renderer/sources/render_raster_source.hpp
@@ -31,9 +31,4 @@ private:
optional<Tileset> tileset;
};
-template <>
-inline bool RenderSource::is<RenderRasterSource>() const {
- return baseImpl->type == style::SourceType::Raster;
-}
-
} // namespace mbgl
diff --git a/src/mbgl/renderer/sources/render_vector_source.hpp b/src/mbgl/renderer/sources/render_vector_source.hpp
index c1ffdd207c..d5ac443e1c 100644
--- a/src/mbgl/renderer/sources/render_vector_source.hpp
+++ b/src/mbgl/renderer/sources/render_vector_source.hpp
@@ -20,9 +20,4 @@ private:
optional<Tileset> tileset;
};
-template <>
-inline bool RenderSource::is<RenderVectorSource>() const {
- return baseImpl->type == style::SourceType::Vector;
-}
-
} // namespace mbgl