diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-22 15:37:09 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-11-26 22:11:28 +0200 |
commit | ff390189a8887b57780cc3bea3b7f30bbecc0fec (patch) | |
tree | fce4c858652596e6ce6331ef3a1a8e466391a8d4 /src/mbgl/style/layers/line_layer.cpp | |
parent | 6bb1e977eafc61af39d47df083bb3de13205fae9 (diff) | |
download | qtlocation-mapboxgl-upstream/mikhail_render_layer_factory.tar.gz |
[core][Android][Darwin] LayerManager creates RenderLayer instancesupstream/mikhail_render_layer_factory
`LayerManager` is now responsible for `RenderLayer` instances creation,
so that there is a single entry point for creating of objects, which
correspond to a certain layer type.
The `LayerType type` field is dropped from `Layer::Impl`.
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 |