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/background_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/background_layer.cpp')
-rw-r--r-- | src/mbgl/style/layers/background_layer.cpp | 36 |
1 files changed, 20 insertions, 16 deletions
diff --git a/src/mbgl/style/layers/background_layer.cpp b/src/mbgl/style/layers/background_layer.cpp index 1342afd7b1..8beafb0278 100644 --- a/src/mbgl/style/layers/background_layer.cpp +++ b/src/mbgl/style/layers/background_layer.cpp @@ -11,21 +11,27 @@ #include <mbgl/style/conversion_impl.hpp> #include <mbgl/util/fnv_hash.hpp> +#include <mbgl/renderer/layers/render_background_layer.hpp> + namespace mbgl { namespace style { -namespace { - const LayerTypeInfo typeInfoBackground + +// static +const LayerTypeInfo* BackgroundLayer::Impl::staticTypeInfo() noexcept { + const static LayerTypeInfo typeInfo {"background", LayerTypeInfo::Source::NotRequired, LayerTypeInfo::Pass3D::NotRequired, LayerTypeInfo::Layout::NotRequired, LayerTypeInfo::Clipping::NotRequired }; -} // namespace + return &typeInfo; +} + BackgroundLayer::BackgroundLayer(const std::string& layerID) - : Layer(makeMutable<Impl>(LayerType::Background, layerID, std::string())) { + : Layer(makeMutable<Impl>(layerID, std::string())) { } BackgroundLayer::BackgroundLayer(Immutable<Impl> impl_) @@ -52,10 +58,6 @@ std::unique_ptr<Layer> BackgroundLayer::cloneRef(const std::string& id_) const { void BackgroundLayer::Impl::stringifyLayout(rapidjson::Writer<rapidjson::StringBuffer>&) const { } -const LayerTypeInfo* BackgroundLayer::Impl::getTypeInfo() const noexcept { - return &typeInfoBackground; -} - // Layout properties @@ -284,18 +286,20 @@ Mutable<Layer::Impl> BackgroundLayer::mutableBaseImpl() const { return staticMutableCast<Layer::Impl>(mutableImpl()); } -BackgroundLayerFactory::BackgroundLayerFactory() = default; - -BackgroundLayerFactory::~BackgroundLayerFactory() = default; +} // namespace style -const LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept { - return &typeInfoBackground; +const style::LayerTypeInfo* BackgroundLayerFactory::getTypeInfo() const noexcept { + return style::BackgroundLayer::Impl::staticTypeInfo(); } -std::unique_ptr<style::Layer> BackgroundLayerFactory::createLayer(const std::string& id, const conversion::Convertible& value) { +std::unique_ptr<style::Layer> BackgroundLayerFactory::createLayer(const std::string& id, const style::conversion::Convertible& value) noexcept { (void)value; - return std::unique_ptr<style::Layer>(new BackgroundLayer(id)); + return std::unique_ptr<style::Layer>(new style::BackgroundLayer(id)); +} + +std::unique_ptr<RenderLayer> BackgroundLayerFactory::createRenderLayer(Immutable<style::Layer::Impl> impl) noexcept { + assert(impl->getTypeInfo() == getTypeInfo()); + return std::make_unique<RenderBackgroundLayer>(staticImmutableCast<style::BackgroundLayer::Impl>(std::move(impl))); } -} // namespace style } // namespace mbgl |