[core] Remove down-casting of render sources

This commit is contained in:
Mikhail Pozdnyakov
2019-07-03 12:09:28 +03:00
parent 1155121530
commit 8b78398190
10 changed files with 10 additions and 54 deletions

View File

@@ -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

View File

@@ -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) {

View File

@@ -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

View File

@@ -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;

View File

@@ -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

View File

@@ -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

View File

@@ -68,9 +68,4 @@ private:
std::vector<UnwrappedTileID> tileIds;
};
template <>
inline bool RenderSource::is<RenderImageSource>() const {
return baseImpl->type == style::SourceType::Image;
}
} // namespace mbgl

View File

@@ -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

View File

@@ -31,9 +31,4 @@ private:
optional<Tileset> tileset;
};
template <>
inline bool RenderSource::is<RenderRasterSource>() const {
return baseImpl->type == style::SourceType::Raster;
}
} // namespace mbgl

View File

@@ -20,9 +20,4 @@ private:
optional<Tileset> tileset;
};
template <>
inline bool RenderSource::is<RenderVectorSource>() const {
return baseImpl->type == style::SourceType::Vector;
}
} // namespace mbgl