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-27 18:10:21 +0200 |
commit | 361982fef83a145769da5c04d1c19731df89921c (patch) | |
tree | e6212cb782cf9df83ecc3e32cb52beaebeb73ab8 /src/mbgl/renderer/render_layer.cpp | |
parent | cca37e765bf9b853262783a6f7cc3d1a4c72957d (diff) | |
download | qtlocation-mapboxgl-361982fef83a145769da5c04d1c19731df89921c.tar.gz |
[core][Android][Darwin] LayerManager creates RenderLayer instances
`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/renderer/render_layer.cpp')
-rw-r--r-- | src/mbgl/renderer/render_layer.cpp | 46 |
1 files changed, 3 insertions, 43 deletions
diff --git a/src/mbgl/renderer/render_layer.cpp b/src/mbgl/renderer/render_layer.cpp index 3e9a7caf24..033df02282 100644 --- a/src/mbgl/renderer/render_layer.cpp +++ b/src/mbgl/renderer/render_layer.cpp @@ -1,14 +1,4 @@ #include <mbgl/renderer/render_layer.hpp> -#include <mbgl/renderer/layers/render_background_layer.hpp> -#include <mbgl/renderer/layers/render_circle_layer.hpp> -#include <mbgl/renderer/layers/render_custom_layer.hpp> -#include <mbgl/renderer/layers/render_fill_extrusion_layer.hpp> -#include <mbgl/renderer/layers/render_fill_layer.hpp> -#include <mbgl/renderer/layers/render_hillshade_layer.hpp> -#include <mbgl/renderer/layers/render_line_layer.hpp> -#include <mbgl/renderer/layers/render_raster_layer.hpp> -#include <mbgl/renderer/layers/render_symbol_layer.hpp> -#include <mbgl/renderer/layers/render_heatmap_layer.hpp> #include <mbgl/renderer/paint_parameters.hpp> #include <mbgl/renderer/render_tile.hpp> #include <mbgl/style/types.hpp> @@ -19,42 +9,12 @@ namespace mbgl { using namespace style; -std::unique_ptr<RenderLayer> RenderLayer::create(Immutable<Layer::Impl> impl) { - switch (impl->type) { - case LayerType::Fill: - return std::make_unique<RenderFillLayer>(staticImmutableCast<FillLayer::Impl>(impl)); - case LayerType::Line: - return std::make_unique<RenderLineLayer>(staticImmutableCast<LineLayer::Impl>(impl)); - case LayerType::Circle: - return std::make_unique<RenderCircleLayer>(staticImmutableCast<CircleLayer::Impl>(impl)); - case LayerType::Symbol: - return std::make_unique<RenderSymbolLayer>(staticImmutableCast<SymbolLayer::Impl>(impl)); - case LayerType::Raster: - return std::make_unique<RenderRasterLayer>(staticImmutableCast<RasterLayer::Impl>(impl)); - case LayerType::Hillshade: - return std::make_unique<RenderHillshadeLayer>(staticImmutableCast<HillshadeLayer::Impl>(impl)); - case LayerType::Background: - return std::make_unique<RenderBackgroundLayer>(staticImmutableCast<BackgroundLayer::Impl>(impl)); - case LayerType::Custom: - return std::make_unique<RenderCustomLayer>(staticImmutableCast<CustomLayer::Impl>(impl)); - case LayerType::FillExtrusion: - return std::make_unique<RenderFillExtrusionLayer>(staticImmutableCast<FillExtrusionLayer::Impl>(impl)); - case LayerType::Heatmap: - return std::make_unique<RenderHeatmapLayer>(staticImmutableCast<HeatmapLayer::Impl>(impl)); - } - - // Not reachable, but placate GCC. - assert(false); - return nullptr; -} - -RenderLayer::RenderLayer(style::LayerType type_, Immutable<style::Layer::Impl> baseImpl_) - : type(type_), - baseImpl(baseImpl_) { +RenderLayer::RenderLayer(Immutable<style::Layer::Impl> baseImpl_) + : baseImpl(std::move(baseImpl_)) { } void RenderLayer::setImpl(Immutable<style::Layer::Impl> impl) { - baseImpl = impl; + baseImpl = std::move(impl); } const std::string& RenderLayer::getID() const { |