summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation/shape_annotation_impl.cpp
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-10-19 15:24:22 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-10-22 09:34:40 -0700
commit3afc8b4a2939da70c76dc5b2eb5d007fc917d348 (patch)
tree176372e3631a81303f379f30de235996f22212f2 /src/mbgl/annotation/shape_annotation_impl.cpp
parentdf89de5cc5bf043ca2fe57ef4dd9a7b5d25464cb (diff)
downloadqtlocation-mapboxgl-3afc8b4a2939da70c76dc5b2eb5d007fc917d348.tar.gz
[core] Introduce StyleLayer subclasses
Diffstat (limited to 'src/mbgl/annotation/shape_annotation_impl.cpp')
-rw-r--r--src/mbgl/annotation/shape_annotation_impl.cpp63
1 files changed, 38 insertions, 25 deletions
diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp
index 74daf849ec..5b3c07fbc9 100644
--- a/src/mbgl/annotation/shape_annotation_impl.cpp
+++ b/src/mbgl/annotation/shape_annotation_impl.cpp
@@ -6,7 +6,8 @@
#include <mbgl/util/string.hpp>
#include <mbgl/style/style.hpp>
#include <mbgl/style/style_bucket.hpp>
-#include <mbgl/style/style_layer.hpp>
+#include <mbgl/layer/line_layer.hpp>
+#include <mbgl/layer/fill_layer.hpp>
namespace mbgl {
@@ -55,35 +56,47 @@ void ShapeAnnotationImpl::updateStyle(Style& style) {
if (style.getLayer(layerID))
return;
- ClassProperties paintProperties;
-
if (shape.styleProperties.is<LinePaintProperties>()) {
- const LinePaintProperties& lineProperties = shape.styleProperties.get<LinePaintProperties>();
- paintProperties.set(PropertyKey::LineOpacity, ConstantFunction<float>(lineProperties.opacity));
- paintProperties.set(PropertyKey::LineWidth, ConstantFunction<float>(lineProperties.width));
- paintProperties.set(PropertyKey::LineColor, ConstantFunction<Color>(lineProperties.color));
+ const LinePaintProperties& properties = shape.styleProperties.get<LinePaintProperties>();
+
+ std::unique_ptr<LineLayer> layer = std::make_unique<LineLayer>();
+ layer->id = layerID;
+ layer->type = StyleLayerType::Line;
+
+ ClassProperties paintProperties;
+ paintProperties.set(PropertyKey::LineOpacity, ConstantFunction<float>(properties.opacity));
+ paintProperties.set(PropertyKey::LineWidth, ConstantFunction<float>(properties.width));
+ paintProperties.set(PropertyKey::LineColor, ConstantFunction<Color>(properties.color));
+ layer->styles.emplace(ClassID::Default, std::move(paintProperties));
+
+ layer->bucket = std::make_shared<StyleBucket>(layer->type);
+ layer->bucket->name = layer->id;
+ layer->bucket->source = AnnotationManager::SourceID;
+ layer->bucket->source_layer = layer->id;
+ layer->bucket->layout.set(PropertyKey::LineJoin, ConstantFunction<JoinType>(JoinType::Round));
+
+ style.addLayer(std::move(layer), AnnotationManager::PointLayerID);
+
} else if (shape.styleProperties.is<FillPaintProperties>()) {
- const FillPaintProperties& fillProperties = shape.styleProperties.get<FillPaintProperties>();
- paintProperties.set(PropertyKey::FillOpacity, ConstantFunction<float>(fillProperties.opacity));
- paintProperties.set(PropertyKey::FillColor, ConstantFunction<Color>(fillProperties.fill_color));
- paintProperties.set(PropertyKey::FillOutlineColor, ConstantFunction<Color>(fillProperties.stroke_color));
- }
+ const FillPaintProperties& properties = shape.styleProperties.get<FillPaintProperties>();
- std::map<ClassID, ClassProperties> shapePaints;
- shapePaints.emplace(ClassID::Default, std::move(paintProperties));
- std::unique_ptr<StyleLayer> shapeLayer = std::make_unique<StyleLayer>(layerID, std::move(shapePaints));
- shapeLayer->type = (shape.styleProperties.is<LinePaintProperties>() ? StyleLayerType::Line : StyleLayerType::Fill);
+ std::unique_ptr<FillLayer> layer = std::make_unique<FillLayer>();
+ layer->id = layerID;
+ layer->type = StyleLayerType::Fill;
- util::ptr<StyleBucket> shapeBucket = std::make_shared<StyleBucket>(shapeLayer->type);
- shapeBucket->name = shapeLayer->id;
- shapeBucket->source = AnnotationManager::SourceID;
- shapeBucket->source_layer = shapeLayer->id;
- if (shape.styleProperties.is<LinePaintProperties>()) {
- shapeBucket->layout.set(PropertyKey::LineJoin, ConstantFunction<JoinType>(JoinType::Round));
- }
+ ClassProperties paintProperties;
+ paintProperties.set(PropertyKey::FillOpacity, ConstantFunction<float>(properties.opacity));
+ paintProperties.set(PropertyKey::FillColor, ConstantFunction<Color>(properties.fill_color));
+ paintProperties.set(PropertyKey::FillOutlineColor, ConstantFunction<Color>(properties.stroke_color));
+ layer->styles.emplace(ClassID::Default, std::move(paintProperties));
- shapeLayer->bucket = shapeBucket;
- style.addLayer(std::move(shapeLayer), AnnotationManager::PointLayerID);
+ layer->bucket = std::make_shared<StyleBucket>(layer->type);
+ layer->bucket->name = layer->id;
+ layer->bucket->source = AnnotationManager::SourceID;
+ layer->bucket->source_layer = layer->id;
+
+ style.addLayer(std::move(layer), AnnotationManager::PointLayerID);
+ }
}
void ShapeAnnotationImpl::updateTile(const TileID& tileID, AnnotationTile& tile) {