[core] Replace remaining dynamic_cast with static_cast
This commit is contained in:
@@ -59,8 +59,8 @@ bool RenderHillshadeLayer::hasTransition() const {
|
||||
void RenderHillshadeLayer::render(PaintParameters& parameters, RenderSource* src) {
|
||||
if (parameters.pass != RenderPass::Translucent && parameters.pass != RenderPass::Pass3D)
|
||||
return;
|
||||
|
||||
RenderRasterDEMSource* demsrc = dynamic_cast<RenderRasterDEMSource*>(src);
|
||||
|
||||
RenderRasterDEMSource* demsrc = static_cast<RenderRasterDEMSource*>(src);
|
||||
const uint8_t TERRAIN_RGB_MAXZOOM = 15;
|
||||
const uint8_t maxzoom = demsrc != nullptr ? demsrc->getMaxZoom() : TERRAIN_RGB_MAXZOOM;
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ void RenderSymbolLayer::render(PaintParameters& parameters, RenderSource*) {
|
||||
);
|
||||
};
|
||||
|
||||
assert(dynamic_cast<GeometryTile*>(&tile.tile));
|
||||
assert(tile.tile.kind == Tile::Kind::Geometry);
|
||||
GeometryTile& geometryTile = static_cast<GeometryTile&>(tile.tile);
|
||||
|
||||
if (bucket.hasIconData()) {
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
bool CircleLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
|
||||
assert(dynamic_cast<const CircleLayer::Impl*>(&other));
|
||||
assert(other.type == LayerType::Circle);
|
||||
const auto& impl = static_cast<const style::CircleLayer::Impl&>(other);
|
||||
return filter != impl.filter ||
|
||||
visibility != impl.visibility ||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
bool FillExtrusionLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
|
||||
assert(dynamic_cast<const FillExtrusionLayer::Impl*>(&other));
|
||||
assert(other.type == LayerType::FillExtrusion);
|
||||
const auto& impl = static_cast<const style::FillExtrusionLayer::Impl&>(other);
|
||||
return filter != impl.filter ||
|
||||
visibility != impl.visibility ||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
bool FillLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
|
||||
assert(dynamic_cast<const FillLayer::Impl*>(&other));
|
||||
assert(other.type == LayerType::Fill);
|
||||
const auto& impl = static_cast<const style::FillLayer::Impl&>(other);
|
||||
return filter != impl.filter ||
|
||||
visibility != impl.visibility ||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
bool HeatmapLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
|
||||
assert(dynamic_cast<const HeatmapLayer::Impl*>(&other));
|
||||
assert(other.type == LayerType::Heatmap);
|
||||
const auto& impl = static_cast<const style::HeatmapLayer::Impl&>(other);
|
||||
return filter != impl.filter ||
|
||||
visibility != impl.visibility ||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
bool LineLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
|
||||
assert(dynamic_cast<const LineLayer::Impl*>(&other));
|
||||
assert(other.type == LayerType::Line);
|
||||
const auto& impl = static_cast<const style::LineLayer::Impl&>(other);
|
||||
return filter != impl.filter ||
|
||||
visibility != impl.visibility ||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace mbgl {
|
||||
namespace style {
|
||||
|
||||
bool SymbolLayer::Impl::hasLayoutDifference(const Layer::Impl& other) const {
|
||||
assert(dynamic_cast<const SymbolLayer::Impl*>(&other));
|
||||
assert(other.type == LayerType::Symbol);
|
||||
const auto& impl = static_cast<const style::SymbolLayer::Impl&>(other);
|
||||
return filter != impl.filter ||
|
||||
visibility != impl.visibility ||
|
||||
|
||||
@@ -48,7 +48,7 @@ void Placement::placeLayer(RenderSymbolLayer& symbolLayer, const mat4& projMatri
|
||||
if (!renderTile.tile.isRenderable()) {
|
||||
continue;
|
||||
}
|
||||
assert(dynamic_cast<GeometryTile*>(&renderTile.tile));
|
||||
assert(renderTile.tile.kind == Tile::Kind::Geometry);
|
||||
GeometryTile& geometryTile = static_cast<GeometryTile&>(renderTile.tile);
|
||||
|
||||
auto bucket = renderTile.tile.getBucket<SymbolBucket>(*symbolLayer.baseImpl);
|
||||
|
||||
@@ -44,7 +44,7 @@ using namespace style;
|
||||
GeometryTile::GeometryTile(const OverscaledTileID& id_,
|
||||
std::string sourceID_,
|
||||
const TileParameters& parameters)
|
||||
: Tile(id_),
|
||||
: Tile(Kind::Geometry, id_),
|
||||
sourceID(std::move(sourceID_)),
|
||||
mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
|
||||
worker(parameters.workerScheduler,
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mbgl {
|
||||
RasterDEMTile::RasterDEMTile(const OverscaledTileID& id_,
|
||||
const TileParameters& parameters,
|
||||
const Tileset& tileset)
|
||||
: Tile(id_),
|
||||
: Tile(Kind::RasterDEM, id_),
|
||||
loader(*this, id_, parameters, tileset),
|
||||
mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
|
||||
worker(parameters.workerScheduler,
|
||||
|
||||
@@ -15,7 +15,7 @@ namespace mbgl {
|
||||
RasterTile::RasterTile(const OverscaledTileID& id_,
|
||||
const TileParameters& parameters,
|
||||
const Tileset& tileset)
|
||||
: Tile(id_),
|
||||
: Tile(Kind::Raster, id_),
|
||||
loader(*this, id_, parameters, tileset),
|
||||
mailbox(std::make_shared<Mailbox>(*Scheduler::GetCurrent())),
|
||||
worker(parameters.workerScheduler,
|
||||
|
||||
@@ -9,7 +9,7 @@ namespace mbgl {
|
||||
|
||||
static TileObserver nullObserver;
|
||||
|
||||
Tile::Tile(OverscaledTileID id_) : id(std::move(id_)), observer(&nullObserver) {
|
||||
Tile::Tile(Kind kind_, OverscaledTileID id_) : kind(kind_), id(std::move(id_)), observer(&nullObserver) {
|
||||
}
|
||||
|
||||
Tile::~Tile() = default;
|
||||
@@ -27,6 +27,14 @@ void Tile::setTriedCache() {
|
||||
}
|
||||
|
||||
void Tile::dumpDebugLogs() const {
|
||||
std::string kindString;
|
||||
switch (kind) {
|
||||
case Kind::Geometry: kindString = "Geometry"; break;
|
||||
case Kind::Raster: kindString = "Raster"; break;
|
||||
case Kind::RasterDEM: kindString = "RasterDEM"; break;
|
||||
default: kindString = "Unknown"; break;
|
||||
}
|
||||
Log::Info(Event::General, "Tile::Kind: %s", kindString.c_str());
|
||||
Log::Info(Event::General, "Tile::id: %s", util::toString(id).c_str());
|
||||
Log::Info(Event::General, "Tile::renderable: %s", isRenderable() ? "yes" : "no");
|
||||
Log::Info(Event::General, "Tile::complete: %s", isComplete() ? "yes" : "no");
|
||||
|
||||
@@ -35,7 +35,13 @@ class Context;
|
||||
|
||||
class Tile : private util::noncopyable {
|
||||
public:
|
||||
Tile(OverscaledTileID);
|
||||
enum class Kind : uint8_t {
|
||||
Geometry,
|
||||
Raster,
|
||||
RasterDEM
|
||||
};
|
||||
|
||||
Tile(Kind, OverscaledTileID);
|
||||
virtual ~Tile();
|
||||
|
||||
void setObserver(TileObserver* observer);
|
||||
@@ -119,6 +125,7 @@ public:
|
||||
|
||||
void dumpDebugLogs() const;
|
||||
|
||||
const Kind kind;
|
||||
OverscaledTileID id;
|
||||
optional<Timestamp> modified;
|
||||
optional<Timestamp> expires;
|
||||
|
||||
@@ -207,7 +207,7 @@ TEST(Map, SetStyleInvalidJSON) {
|
||||
EXPECT_TRUE(fail);
|
||||
|
||||
auto observer = Log::removeObserver();
|
||||
auto flo = dynamic_cast<FixtureLogObserver*>(observer.get());
|
||||
auto flo = static_cast<FixtureLogObserver*>(observer.get());
|
||||
EXPECT_EQ(1u, flo->count({ EventSeverity::Error, Event::ParseStyle, -1,
|
||||
"Failed to parse style: 0 - Invalid value." }));
|
||||
auto unchecked = flo->unchecked();
|
||||
|
||||
Reference in New Issue
Block a user