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 | |
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')
-rw-r--r-- | src/mbgl/renderer/group_by_layout.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_background_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_circle_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_custom_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_fill_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_heatmap_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_hillshade_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_line_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_raster_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/layers/render_symbol_layer.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/render_layer.cpp | 46 | ||||
-rw-r--r-- | src/mbgl/renderer/render_layer.hpp | 8 | ||||
-rw-r--r-- | src/mbgl/renderer/renderer_impl.cpp | 2 | ||||
-rw-r--r-- | src/mbgl/renderer/style_diff.cpp | 3 |
15 files changed, 17 insertions, 64 deletions
diff --git a/src/mbgl/renderer/group_by_layout.cpp b/src/mbgl/renderer/group_by_layout.cpp index 3b02727ff8..41a895902c 100644 --- a/src/mbgl/renderer/group_by_layout.cpp +++ b/src/mbgl/renderer/group_by_layout.cpp @@ -18,7 +18,7 @@ std::string layoutKey(const RenderLayer& layer) { rapidjson::Writer<rapidjson::StringBuffer> writer(s); writer.StartArray(); - writer.Uint(static_cast<uint32_t>(layer.type)); + writer.Uint64(reinterpret_cast<uint64_t>(layer.baseImpl->getTypeInfo())); writer.String(layer.baseImpl->source); writer.String(layer.baseImpl->sourceLayer); writer.Double(layer.baseImpl->minZoom); diff --git a/src/mbgl/renderer/layers/render_background_layer.cpp b/src/mbgl/renderer/layers/render_background_layer.cpp index 3e510ef352..d7bf0dc6bd 100644 --- a/src/mbgl/renderer/layers/render_background_layer.cpp +++ b/src/mbgl/renderer/layers/render_background_layer.cpp @@ -14,7 +14,7 @@ namespace mbgl { using namespace style; RenderBackgroundLayer::RenderBackgroundLayer(Immutable<style::BackgroundLayer::Impl> _impl) - : RenderLayer(style::LayerType::Background, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()) { } diff --git a/src/mbgl/renderer/layers/render_circle_layer.cpp b/src/mbgl/renderer/layers/render_circle_layer.cpp index 46db06416d..b984c596d3 100644 --- a/src/mbgl/renderer/layers/render_circle_layer.cpp +++ b/src/mbgl/renderer/layers/render_circle_layer.cpp @@ -15,7 +15,7 @@ namespace mbgl { using namespace style; RenderCircleLayer::RenderCircleLayer(Immutable<style::CircleLayer::Impl> _impl) - : RenderLayer(style::LayerType::Circle, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()) { } diff --git a/src/mbgl/renderer/layers/render_custom_layer.cpp b/src/mbgl/renderer/layers/render_custom_layer.cpp index e80ceda6c7..9e65830faf 100644 --- a/src/mbgl/renderer/layers/render_custom_layer.cpp +++ b/src/mbgl/renderer/layers/render_custom_layer.cpp @@ -13,7 +13,7 @@ namespace mbgl { using namespace style; RenderCustomLayer::RenderCustomLayer(Immutable<style::CustomLayer::Impl> _impl) - : RenderLayer(LayerType::Custom, _impl), host(_impl->host) { + : RenderLayer(std::move(_impl)), host(impl().host) { assert(BackendScope::exists()); host->initialize(); } diff --git a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp index 8f1b961d1a..91d58bf8d6 100644 --- a/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_extrusion_layer.cpp @@ -19,7 +19,7 @@ namespace mbgl { using namespace style; RenderFillExtrusionLayer::RenderFillExtrusionLayer(Immutable<style::FillExtrusionLayer::Impl> _impl) - : RenderLayer(style::LayerType::FillExtrusion, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()) { } diff --git a/src/mbgl/renderer/layers/render_fill_layer.cpp b/src/mbgl/renderer/layers/render_fill_layer.cpp index 83be3ccd57..391c2d5b0f 100644 --- a/src/mbgl/renderer/layers/render_fill_layer.cpp +++ b/src/mbgl/renderer/layers/render_fill_layer.cpp @@ -17,7 +17,7 @@ namespace mbgl { using namespace style; RenderFillLayer::RenderFillLayer(Immutable<style::FillLayer::Impl> _impl) - : RenderLayer(style::LayerType::Fill, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()) { } diff --git a/src/mbgl/renderer/layers/render_heatmap_layer.cpp b/src/mbgl/renderer/layers/render_heatmap_layer.cpp index 4e5e890358..1842cdac93 100644 --- a/src/mbgl/renderer/layers/render_heatmap_layer.cpp +++ b/src/mbgl/renderer/layers/render_heatmap_layer.cpp @@ -17,7 +17,7 @@ namespace mbgl { using namespace style; RenderHeatmapLayer::RenderHeatmapLayer(Immutable<style::HeatmapLayer::Impl> _impl) - : RenderLayer(style::LayerType::Heatmap, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()), colorRamp({256, 1}) { } diff --git a/src/mbgl/renderer/layers/render_hillshade_layer.cpp b/src/mbgl/renderer/layers/render_hillshade_layer.cpp index 835cb3f9f9..ba7e782f16 100644 --- a/src/mbgl/renderer/layers/render_hillshade_layer.cpp +++ b/src/mbgl/renderer/layers/render_hillshade_layer.cpp @@ -16,7 +16,7 @@ namespace mbgl { using namespace style; RenderHillshadeLayer::RenderHillshadeLayer(Immutable<style::HillshadeLayer::Impl> _impl) - : RenderLayer(style::LayerType::Hillshade, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()) { } diff --git a/src/mbgl/renderer/layers/render_line_layer.cpp b/src/mbgl/renderer/layers/render_line_layer.cpp index 94081b5f09..fcdbc0b47a 100644 --- a/src/mbgl/renderer/layers/render_line_layer.cpp +++ b/src/mbgl/renderer/layers/render_line_layer.cpp @@ -18,7 +18,7 @@ namespace mbgl { using namespace style; RenderLineLayer::RenderLineLayer(Immutable<style::LineLayer::Impl> _impl) - : RenderLayer(style::LayerType::Line, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()), colorRamp({256, 1}) { } diff --git a/src/mbgl/renderer/layers/render_raster_layer.cpp b/src/mbgl/renderer/layers/render_raster_layer.cpp index 8e0651b65b..e0a7e427ad 100644 --- a/src/mbgl/renderer/layers/render_raster_layer.cpp +++ b/src/mbgl/renderer/layers/render_raster_layer.cpp @@ -14,7 +14,7 @@ namespace mbgl { using namespace style; RenderRasterLayer::RenderRasterLayer(Immutable<style::RasterLayer::Impl> _impl) - : RenderLayer(style::LayerType::Raster, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()) { } diff --git a/src/mbgl/renderer/layers/render_symbol_layer.cpp b/src/mbgl/renderer/layers/render_symbol_layer.cpp index 2b3a7195c5..11ffd74b10 100644 --- a/src/mbgl/renderer/layers/render_symbol_layer.cpp +++ b/src/mbgl/renderer/layers/render_symbol_layer.cpp @@ -23,7 +23,7 @@ namespace mbgl { using namespace style; RenderSymbolLayer::RenderSymbolLayer(Immutable<style::SymbolLayer::Impl> _impl) - : RenderLayer(style::LayerType::Symbol, _impl), + : RenderLayer(std::move(_impl)), unevaluated(impl().paint.untransitioned()) { } 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 { diff --git a/src/mbgl/renderer/render_layer.hpp b/src/mbgl/renderer/render_layer.hpp index a92d8f5aff..4e0e1913b6 100644 --- a/src/mbgl/renderer/render_layer.hpp +++ b/src/mbgl/renderer/render_layer.hpp @@ -23,13 +23,9 @@ class TransformState; class RenderLayer { protected: - RenderLayer(style::LayerType, Immutable<style::Layer::Impl>); - - const style::LayerType type; + RenderLayer(Immutable<style::Layer::Impl>); public: - static std::unique_ptr<RenderLayer> create(Immutable<style::Layer::Impl>); - virtual ~RenderLayer() = default; // Begin transitions for any properties that have changed since the last frame. @@ -93,8 +89,6 @@ public: // TODO: Only for background layers. virtual optional<Color> getSolidBackground() const; - friend std::string layoutKey(const RenderLayer&); - protected: // Checks whether the current hardware can render this layer. If it can't, we'll show a warning // in the console to inform the developer. diff --git a/src/mbgl/renderer/renderer_impl.cpp b/src/mbgl/renderer/renderer_impl.cpp index 32fcd57332..c4c4851345 100644 --- a/src/mbgl/renderer/renderer_impl.cpp +++ b/src/mbgl/renderer/renderer_impl.cpp @@ -164,7 +164,7 @@ void Renderer::Impl::render(const UpdateParameters& updateParameters) { // Create render layers for newly added layers. for (const auto& entry : layerDiff.added) { - renderLayers.emplace(entry.first, RenderLayer::create(entry.second)); + renderLayers.emplace(entry.first, LayerManager::get()->createRenderLayer(entry.second)); } // Update render layers for changed layers. diff --git a/src/mbgl/renderer/style_diff.cpp b/src/mbgl/renderer/style_diff.cpp index 0017280310..270c4483cd 100644 --- a/src/mbgl/renderer/style_diff.cpp +++ b/src/mbgl/renderer/style_diff.cpp @@ -62,8 +62,7 @@ SourceDifference diffSources(const Immutable<std::vector<ImmutableSource>>& a, LayerDifference diffLayers(const Immutable<std::vector<ImmutableLayer>>& a, const Immutable<std::vector<ImmutableLayer>>& b) { return diff(a, b, [] (const ImmutableLayer& lhs, const ImmutableLayer& rhs) { - return std::tie(lhs->id, lhs->type) - == std::tie(rhs->id, rhs->type); + return (lhs->id == rhs->id) && (lhs->getTypeInfo() == rhs->getTypeInfo()); }); } |