diff options
author | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-12-10 17:21:08 +0200 |
---|---|---|
committer | Mikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com> | 2018-12-10 18:20:32 +0200 |
commit | ebd87a5442772e9e840cd5c00be56cccfddb5c68 (patch) | |
tree | b65309b89e2d63f063369e97ccced610fd025a60 /src/mbgl/layermanager/fill_layer_factory.cpp | |
parent | cbcd0875e375b06cbd163af105e8f1e0226f2df0 (diff) | |
download | qtlocation-mapboxgl-ebd87a5442772e9e840cd5c00be56cccfddb5c68.tar.gz |
[core, android, darwin] Move layer factories to separate files
Diffstat (limited to 'src/mbgl/layermanager/fill_layer_factory.cpp')
-rw-r--r-- | src/mbgl/layermanager/fill_layer_factory.cpp | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/src/mbgl/layermanager/fill_layer_factory.cpp b/src/mbgl/layermanager/fill_layer_factory.cpp new file mode 100644 index 0000000000..664788de17 --- /dev/null +++ b/src/mbgl/layermanager/fill_layer_factory.cpp @@ -0,0 +1,31 @@ +#include <mbgl/layermanager/fill_layer_factory.hpp> + +#include <mbgl/renderer/layers/render_fill_layer.hpp> +#include <mbgl/style/layers/fill_layer.hpp> +#include <mbgl/style/layers/fill_layer_impl.hpp> + +namespace mbgl { + +const style::LayerTypeInfo* FillLayerFactory::getTypeInfo() const noexcept { + return style::FillLayer::Impl::staticTypeInfo(); +} + +std::unique_ptr<style::Layer> FillLayerFactory::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 style::FillLayer(id, *source)); + if (!initSourceLayerAndFilter(layer.get(), value)) { + return nullptr; + } + return layer; +} + +std::unique_ptr<RenderLayer> FillLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept { + assert(impl->getTypeInfo() == getTypeInfo()); + return std::make_unique<RenderFillLayer>(staticImmutableCast<style::FillLayer::Impl>(std::move(impl))); +} + +} // namespace mbgl |