summaryrefslogtreecommitdiff
path: root/src/mbgl/style/layers/line_layer.cpp
diff options
context:
space:
mode:
authorMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-11-22 15:37:09 +0200
committerMikhail Pozdnyakov <mikhail.pozdnyakov@mapbox.com>2018-11-27 18:10:21 +0200
commit361982fef83a145769da5c04d1c19731df89921c (patch)
treee6212cb782cf9df83ecc3e32cb52beaebeb73ab8 /src/mbgl/style/layers/line_layer.cpp
parentcca37e765bf9b853262783a6f7cc3d1a4c72957d (diff)
downloadqtlocation-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/style/layers/line_layer.cpp')
-rw-r--r--src/mbgl/style/layers/line_layer.cpp36
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