diff options
Diffstat (limited to 'src/mbgl/style/layers/line_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/line_layer.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/mbgl/style/layers/line_layer.cpp b/src/mbgl/style/layers/line_layer.cpp index aeb0635254..f021a5fd73 100644 --- a/src/mbgl/style/layers/line_layer.cpp +++ b/src/mbgl/style/layers/line_layer.cpp @@ -11,21 +11,27 @@ #include <mbgl/style/conversion_impl.hpp> #include <mbgl/util/fnv_hash.hpp> +#include <mbgl/renderer/layers/render_line_layer.hpp> + namespace mbgl { namespace style { -namespace { - const LayerTypeInfo typeInfoLine + +// static +const LayerTypeInfo* LineLayer::Impl::staticTypeInfo() noexcept { + const static LayerTypeInfo typeInfo {"line", LayerTypeInfo::Source::Required, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::Required, LayerTypeInfo::Clipping::Required }; -} // namespace + return &typeInfo; +} + LineLayer::LineLayer(const std::string& layerID, const std::string& sourceID) - : Layer(makeMutable<Impl>(LayerType::Line, layerID, sourceID)) { + : Layer(makeMutable<Impl>(layerID, sourceID)) { } LineLayer::LineLayer(Immutable<Impl> impl_) @@ -53,10 +59,6 @@ void LineLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer> layout.stringify(writer); } -const LayerTypeInfo* LineLayer::Impl::getTypeInfo() const noexcept { - return &typeInfoLine; -} - // Layout properties PropertyValue<LineCapType> LineLayer::getDefaultLineCap() { @@ -842,26 +844,28 @@ Mutable<Layer::Impl> LineLayer::mutableBaseImpl() const { return staticMutableCast<Layer::Impl>(mutableImpl()); } -LineLayerFactory::LineLayerFactory() = default; - -LineLayerFactory::~LineLayerFactory() = default; +} // namespace style -const LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept { - return &typeInfoLine; +const style::LayerTypeInfo* LineLayerFactory::getTypeInfo() const noexcept { + return style::LineLayer::Impl::staticTypeInfo(); } -std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) { +std::unique_ptr<style::Layer> LineLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept { optional<std::string> source = getSource(value); if (!source) { return nullptr; } - std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new LineLayer(id, *source)); + std::unique_ptr<style::Layer> layer = std::unique_ptr<style::Layer>(new style::LineLayer(id, *source)); if (!initSourceLayerAndFilter(layer.get(), value)) { return nullptr; } return layer; } -} // namespace style +std::unique_ptr<RenderLayer> LineLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept { + assert(impl->getTypeInfo() == getTypeInfo()); + return std::make_unique<RenderLineLayer>(staticImmutableCast<style::LineLayer::Impl>(std::move(impl))); +} + } // namespace mbgl |