[core] Fix layer impl cast in render layer implementations

This PR puts `impl()` functions definitions into a nameless namespace
to provide internal linkage and to make sure that appropriate cast function
is invoked.
This commit is contained in:
Mikhail Pozdnyakov
2019-08-16 16:34:07 +03:00
parent 5de27d5200
commit c7169e6f8d
10 changed files with 46 additions and 0 deletions

View File

@@ -16,10 +16,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const BackgroundLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == BackgroundLayer::Impl::staticTypeInfo());
return static_cast<const style::BackgroundLayer::Impl&>(*impl);
}
} // namespace
RenderBackgroundLayer::RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl> _impl)
: RenderLayer(makeMutable<BackgroundLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()) {

View File

@@ -15,10 +15,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const style::CircleLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == CircleLayer::Impl::staticTypeInfo());
return static_cast<const style::CircleLayer::Impl&>(*impl);
}
} // namespace
RenderCircleLayer::RenderCircleLayer(Immutable<style::CircleLayer::Impl> _impl)
: RenderLayer(makeMutable<CircleLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()) {

View File

@@ -14,10 +14,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const CustomLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == CustomLayer::Impl::staticTypeInfo());
return static_cast<const CustomLayer::Impl&>(*impl);
}
} // namespace
RenderCustomLayer::RenderCustomLayer(Immutable<style::CustomLayer::Impl> _impl)
: RenderLayer(makeMutable<CustomLayerProperties>(std::move(_impl))),
host(impl(baseImpl).host) {

View File

@@ -20,10 +20,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const FillExtrusionLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == FillExtrusionLayer::Impl::staticTypeInfo());
return static_cast<const FillExtrusionLayer::Impl&>(*impl);
}
} // namespace
RenderFillExtrusionLayer::RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl> _impl)
: RenderLayer(makeMutable<FillExtrusionLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()) {

View File

@@ -21,10 +21,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const FillLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == FillLayer::Impl::staticTypeInfo());
return static_cast<const FillLayer::Impl&>(*impl);
}
} // namespace
RenderFillLayer::RenderFillLayer(Immutable<style::FillLayer::Impl> _impl)
: RenderLayer(makeMutable<FillLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()) {

View File

@@ -19,10 +19,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const HeatmapLayer::Impl& impl(const Immutable<Layer::Impl>& impl) {
assert(impl->getTypeInfo() == HeatmapLayer::Impl::staticTypeInfo());
return static_cast<const HeatmapLayer::Impl&>(*impl);
}
} // namespace
RenderHeatmapLayer::RenderHeatmapLayer(Immutable<HeatmapLayer::Impl> _impl)
: RenderLayer(makeMutable<HeatmapLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()), colorRamp({256, 1}) {

View File

@@ -18,10 +18,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const HillshadeLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == HillshadeLayer::Impl::staticTypeInfo());
return static_cast<const HillshadeLayer::Impl&>(*impl);
}
} // namespace
RenderHillshadeLayer::RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl> _impl)
: RenderLayer(makeMutable<HillshadeLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()) {

View File

@@ -20,10 +20,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const LineLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == LineLayer::Impl::staticTypeInfo());
return static_cast<const LineLayer::Impl&>(*impl);
}
} // namespace
RenderLineLayer::RenderLineLayer(Immutable<style::LineLayer::Impl> _impl)
: RenderLayer(makeMutable<LineLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()),

View File

@@ -14,10 +14,15 @@ namespace mbgl {
using namespace style;
namespace {
inline const RasterLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == RasterLayer::Impl::staticTypeInfo());
return static_cast<const RasterLayer::Impl&>(*impl);
}
} // namespace
RenderRasterLayer::RenderRasterLayer(Immutable<style::RasterLayer::Impl> _impl)
: RenderLayer(makeMutable<RasterLayerProperties>(std::move(_impl))),
unevaluated(impl(baseImpl).paint.untransitioned()) {

View File

@@ -227,6 +227,7 @@ void drawText(const DrawFn& draw,
}
inline const SymbolLayer::Impl& impl(const Immutable<style::Layer::Impl>& impl) {
assert(impl->getTypeInfo() == SymbolLayer::Impl::staticTypeInfo());
return static_cast<const SymbolLayer::Impl&>(*impl);
}