[core] Remove down-casting of render sources
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -68,9 +68,4 @@ private:
|
||||
std::vector<UnwrappedTileID> tileIds;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline bool RenderSource::is<RenderImageSource>() const {
|
||||
return baseImpl->type == style::SourceType::Image;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -31,9 +31,4 @@ private:
|
||||
optional<Tileset> tileset;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline bool RenderSource::is<RenderRasterSource>() const {
|
||||
return baseImpl->type == style::SourceType::Raster;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
@@ -20,9 +20,4 @@ private:
|
||||
optional<Tileset> tileset;
|
||||
};
|
||||
|
||||
template <>
|
||||
inline bool RenderSource::is<RenderVectorSource>() const {
|
||||
return baseImpl->type == style::SourceType::Vector;
|
||||
}
|
||||
|
||||
} // namespace mbgl
|
||||
|
||||
Reference in New Issue
Block a user