From c510c680c059a7b28530603220c65af11a5b934a Mon Sep 17 00:00:00 2001 From: John Firebaugh Date: Fri, 11 Dec 2015 11:06:30 -0800 Subject: [PATCH] [core] Opaque pointer pattern for layers --- include/mbgl/layer/layer.hpp | 24 +++++++++++ include/mbgl/map/map.hpp | 6 +-- src/mbgl/annotation/annotation_manager.cpp | 2 +- src/mbgl/annotation/shape_annotation_impl.cpp | 10 ++--- src/mbgl/layer/background_layer.cpp | 2 +- src/mbgl/layer/background_layer.hpp | 6 +-- src/mbgl/layer/circle_layer.cpp | 2 +- src/mbgl/layer/circle_layer.hpp | 6 +-- src/mbgl/layer/custom_layer.hpp | 4 +- src/mbgl/layer/fill_layer.cpp | 2 +- src/mbgl/layer/fill_layer.hpp | 6 +-- src/mbgl/layer/layer_impl.cpp | 13 ++++++ .../style_layer.hpp => layer/layer_impl.hpp} | 13 +++--- src/mbgl/layer/line_layer.cpp | 2 +- src/mbgl/layer/line_layer.hpp | 6 +-- src/mbgl/layer/raster_layer.cpp | 2 +- src/mbgl/layer/raster_layer.hpp | 6 +-- src/mbgl/layer/symbol_layer.cpp | 2 +- src/mbgl/layer/symbol_layer.hpp | 6 +-- src/mbgl/map/map.cpp | 6 +-- src/mbgl/map/map_context.cpp | 4 +- src/mbgl/map/map_context.hpp | 2 +- src/mbgl/map/raster_tile_data.cpp | 2 +- src/mbgl/map/raster_tile_data.hpp | 4 +- src/mbgl/map/source.cpp | 2 +- src/mbgl/map/tile_data.hpp | 4 +- src/mbgl/map/tile_worker.cpp | 36 ++++++++--------- src/mbgl/map/tile_worker.hpp | 8 ++-- src/mbgl/map/vector_tile_data.cpp | 6 +-- src/mbgl/map/vector_tile_data.hpp | 2 +- src/mbgl/renderer/bucket.hpp | 4 +- src/mbgl/renderer/circle_bucket.cpp | 4 +- src/mbgl/renderer/circle_bucket.hpp | 2 +- src/mbgl/renderer/fill_bucket.cpp | 4 +- src/mbgl/renderer/fill_bucket.hpp | 2 +- src/mbgl/renderer/line_bucket.cpp | 4 +- src/mbgl/renderer/line_bucket.hpp | 2 +- src/mbgl/renderer/painter.cpp | 18 ++++----- src/mbgl/renderer/painter.hpp | 2 +- src/mbgl/renderer/raster_bucket.cpp | 4 +- src/mbgl/renderer/raster_bucket.hpp | 2 +- src/mbgl/renderer/symbol_bucket.cpp | 4 +- src/mbgl/renderer/symbol_bucket.hpp | 2 +- src/mbgl/style/style.cpp | 40 +++++++++---------- src/mbgl/style/style.hpp | 16 ++++---- src/mbgl/style/style_layer.cpp | 13 ------ src/mbgl/style/style_parser.cpp | 8 ++-- src/mbgl/style/style_parser.hpp | 13 +++--- src/mbgl/util/worker.cpp | 6 +-- src/mbgl/util/worker.hpp | 2 +- test/api/custom_layer.cpp | 2 +- test/style/style_layer.cpp | 14 +++---- 52 files changed, 193 insertions(+), 171 deletions(-) create mode 100644 include/mbgl/layer/layer.hpp create mode 100644 src/mbgl/layer/layer_impl.cpp rename src/mbgl/{style/style_layer.hpp => layer/layer_impl.hpp} (90%) delete mode 100644 src/mbgl/style/style_layer.cpp diff --git a/include/mbgl/layer/layer.hpp b/include/mbgl/layer/layer.hpp new file mode 100644 index 00000000000..8d5a110f497 --- /dev/null +++ b/include/mbgl/layer/layer.hpp @@ -0,0 +1,24 @@ +#ifndef MBGL_LAYER +#define MBGL_LAYER + +#include + +#include + +namespace mbgl { + +class Layer : public mbgl::util::noncopyable { +public: + class Impl; + + Layer(std::unique_ptr impl_) + : impl(std::move(impl_)) {} + + virtual ~Layer() = default; + + const std::unique_ptr impl; +}; + +} // namespace mbgl + +#endif diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp index 8057837546d..1e79ed6df96 100644 --- a/include/mbgl/map/map.hpp +++ b/include/mbgl/map/map.hpp @@ -27,7 +27,7 @@ class Transform; class PointAnnotation; class ShapeAnnotation; struct CameraOptions; -class StyleLayer; +class Layer; namespace util { template class Thread; @@ -165,8 +165,8 @@ class Map : private util::noncopyable { LatLngBounds getBoundsForAnnotations(const AnnotationIDs&); // Style API - void addLayer(std::unique_ptr); - void addLayer(std::unique_ptr, const std::string& before); + void addLayer(std::unique_ptr); + void addLayer(std::unique_ptr, const std::string& before); // Memory void setSourceTileCacheSize(size_t); diff --git a/src/mbgl/annotation/annotation_manager.cpp b/src/mbgl/annotation/annotation_manager.cpp index a85021b774a..64c3c05428e 100644 --- a/src/mbgl/annotation/annotation_manager.cpp +++ b/src/mbgl/annotation/annotation_manager.cpp @@ -126,7 +126,7 @@ void AnnotationManager::updateStyle(Style& style) { layer->layout.icon.allowOverlap = true; layer->spriteAtlas = &spriteAtlas; - style.addLayer(std::move(layer)); + style.addLayer(std::make_unique(std::move(layer))); } for (const auto& shape : shapeAnnotations) { diff --git a/src/mbgl/annotation/shape_annotation_impl.cpp b/src/mbgl/annotation/shape_annotation_impl.cpp index 40f5d1997ca..62547bd15a8 100644 --- a/src/mbgl/annotation/shape_annotation_impl.cpp +++ b/src/mbgl/annotation/shape_annotation_impl.cpp @@ -41,7 +41,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { layer->source = AnnotationManager::SourceID; layer->sourceLayer = layer->id; - style.addLayer(std::move(layer), AnnotationManager::PointLayerID); + style.addLayer(std::make_unique(std::move(layer)), AnnotationManager::PointLayerID); } else if (shape.properties.is()) { type = geojsonvt::ProjectedFeatureType::Polygon; @@ -57,13 +57,13 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { layer->source = AnnotationManager::SourceID; layer->sourceLayer = layer->id; - style.addLayer(std::move(layer), AnnotationManager::PointLayerID); + style.addLayer(std::make_unique(std::move(layer)), AnnotationManager::PointLayerID); } else { - const StyleLayer* sourceLayer = style.getLayer(shape.properties.get()); + const Layer::Impl* sourceLayer = style.getLayer(shape.properties.get())->impl.get(); if (!sourceLayer) return; - std::unique_ptr layer = sourceLayer->clone(); + std::unique_ptr layer = sourceLayer->clone(); type = layer->is() ? geojsonvt::ProjectedFeatureType::LineString @@ -75,7 +75,7 @@ void ShapeAnnotationImpl::updateStyle(Style& style) { layer->sourceLayer = layer->id; layer->visibility = VisibilityType::Visible; - style.addLayer(std::move(layer), sourceLayer->id); + style.addLayer(std::make_unique(std::move(layer)), sourceLayer->id); } } diff --git a/src/mbgl/layer/background_layer.cpp b/src/mbgl/layer/background_layer.cpp index cea4c2c9b99..92a7735d75e 100644 --- a/src/mbgl/layer/background_layer.cpp +++ b/src/mbgl/layer/background_layer.cpp @@ -3,7 +3,7 @@ namespace mbgl { -std::unique_ptr BackgroundLayer::clone() const { +std::unique_ptr BackgroundLayer::clone() const { return std::make_unique(*this); } diff --git a/src/mbgl/layer/background_layer.hpp b/src/mbgl/layer/background_layer.hpp index 4a342891935..828100db44f 100644 --- a/src/mbgl/layer/background_layer.hpp +++ b/src/mbgl/layer/background_layer.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_BACKGROUND_LAYER #define MBGL_BACKGROUND_LAYER -#include +#include #include namespace mbgl { @@ -13,9 +13,9 @@ class BackgroundPaintProperties { PaintProperty> pattern { "" }; }; -class BackgroundLayer : public StyleLayer { +class BackgroundLayer : public Layer::Impl { public: - std::unique_ptr clone() const override; + std::unique_ptr clone() const override; void parseLayout(const JSVal&) override {}; void parsePaints(const JSVal&) override; diff --git a/src/mbgl/layer/circle_layer.cpp b/src/mbgl/layer/circle_layer.cpp index 9001723439c..3119d30433a 100644 --- a/src/mbgl/layer/circle_layer.cpp +++ b/src/mbgl/layer/circle_layer.cpp @@ -4,7 +4,7 @@ namespace mbgl { -std::unique_ptr CircleLayer::clone() const { +std::unique_ptr CircleLayer::clone() const { return std::make_unique(*this); } diff --git a/src/mbgl/layer/circle_layer.hpp b/src/mbgl/layer/circle_layer.hpp index 80a94c74013..ee9cce1a3de 100644 --- a/src/mbgl/layer/circle_layer.hpp +++ b/src/mbgl/layer/circle_layer.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_CIRCLE_LAYER #define MBGL_CIRCLE_LAYER -#include +#include #include namespace mbgl { @@ -20,9 +20,9 @@ class CirclePaintProperties { } }; -class CircleLayer : public StyleLayer { +class CircleLayer : public Layer::Impl { public: - std::unique_ptr clone() const override; + std::unique_ptr clone() const override; void parseLayout(const JSVal&) override {}; void parsePaints(const JSVal&) override; diff --git a/src/mbgl/layer/custom_layer.hpp b/src/mbgl/layer/custom_layer.hpp index 172eed30516..7e17283b336 100644 --- a/src/mbgl/layer/custom_layer.hpp +++ b/src/mbgl/layer/custom_layer.hpp @@ -1,13 +1,13 @@ #ifndef MBGL_CUSTOM_LAYER #define MBGL_CUSTOM_LAYER -#include +#include namespace mbgl { class StyleRenderParameters; -class CustomLayer : public StyleLayer { +class CustomLayer : public Layer::Impl { public: CustomLayer(const std::string& id); CustomLayer(const CustomLayer&) = default; diff --git a/src/mbgl/layer/fill_layer.cpp b/src/mbgl/layer/fill_layer.cpp index cde5c268374..f6d76d0334e 100644 --- a/src/mbgl/layer/fill_layer.cpp +++ b/src/mbgl/layer/fill_layer.cpp @@ -4,7 +4,7 @@ namespace mbgl { -std::unique_ptr FillLayer::clone() const { +std::unique_ptr FillLayer::clone() const { return std::make_unique(*this); } diff --git a/src/mbgl/layer/fill_layer.hpp b/src/mbgl/layer/fill_layer.hpp index 93514ee4258..d26b100a249 100644 --- a/src/mbgl/layer/fill_layer.hpp +++ b/src/mbgl/layer/fill_layer.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_FILL_LAYER #define MBGL_FILL_LAYER -#include +#include #include namespace mbgl { @@ -17,9 +17,9 @@ class FillPaintProperties { PaintProperty> pattern { "" }; }; -class FillLayer : public StyleLayer { +class FillLayer : public Layer::Impl { public: - std::unique_ptr clone() const override; + std::unique_ptr clone() const override; void parseLayout(const JSVal&) override {}; void parsePaints(const JSVal&) override; diff --git a/src/mbgl/layer/layer_impl.cpp b/src/mbgl/layer/layer_impl.cpp new file mode 100644 index 00000000000..e37bedefc69 --- /dev/null +++ b/src/mbgl/layer/layer_impl.cpp @@ -0,0 +1,13 @@ +#include + +namespace mbgl { + +const std::string& Layer::Impl::bucketName() const { + return ref.empty() ? id : ref; +} + +bool Layer::Impl::hasRenderPass(RenderPass pass) const { + return bool(passes & pass); +} + +} // namespace mbgl diff --git a/src/mbgl/style/style_layer.hpp b/src/mbgl/layer/layer_impl.hpp similarity index 90% rename from src/mbgl/style/style_layer.hpp rename to src/mbgl/layer/layer_impl.hpp index 4f9649a28b2..227bd8c93e7 100644 --- a/src/mbgl/style/style_layer.hpp +++ b/src/mbgl/layer/layer_impl.hpp @@ -1,6 +1,7 @@ #ifndef MBGL_STYLE_STYLE_LAYER #define MBGL_STYLE_STYLE_LAYER +#include #include #include #include @@ -21,9 +22,9 @@ class Bucket; using JSVal = rapidjson::Value; -class StyleLayer { +class Layer::Impl { public: - virtual ~StyleLayer() = default; + virtual ~Impl() = default; // Check whether this layer is of the given subtype. template bool is() const { return dynamic_cast(this); } @@ -33,7 +34,7 @@ class StyleLayer { template const T* as() const { return dynamic_cast(this); } // Create a copy of this layer. - virtual std::unique_ptr clone() const = 0; + virtual std::unique_ptr clone() const = 0; virtual void parseLayout(const JSVal& value) = 0; virtual void parsePaints(const JSVal& value) = 0; @@ -64,9 +65,9 @@ class StyleLayer { VisibilityType visibility = VisibilityType::Visible; protected: - StyleLayer() = default; - StyleLayer(const StyleLayer&) = default; - StyleLayer& operator=(const StyleLayer&) = delete; + Impl() = default; + Impl(const Impl&) = default; + Impl& operator=(const Impl&) = delete; // Stores what render passes this layer is currently enabled for. This depends on the // evaluated StyleProperties object and is updated accordingly. diff --git a/src/mbgl/layer/line_layer.cpp b/src/mbgl/layer/line_layer.cpp index 136721fb015..25993eda728 100644 --- a/src/mbgl/layer/line_layer.cpp +++ b/src/mbgl/layer/line_layer.cpp @@ -5,7 +5,7 @@ namespace mbgl { -std::unique_ptr LineLayer::clone() const { +std::unique_ptr LineLayer::clone() const { return std::make_unique(*this); } diff --git a/src/mbgl/layer/line_layer.hpp b/src/mbgl/layer/line_layer.hpp index b1917b4ca3c..bb48288eb84 100644 --- a/src/mbgl/layer/line_layer.hpp +++ b/src/mbgl/layer/line_layer.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_LINE_LAYER #define MBGL_LINE_LAYER -#include +#include #include #include @@ -36,9 +36,9 @@ class LinePaintProperties { } }; -class LineLayer : public StyleLayer { +class LineLayer : public Layer::Impl { public: - std::unique_ptr clone() const override; + std::unique_ptr clone() const override; void parseLayout(const JSVal&) override; void parsePaints(const JSVal&) override; diff --git a/src/mbgl/layer/raster_layer.cpp b/src/mbgl/layer/raster_layer.cpp index 3ce9ed36e87..04e41e072dc 100644 --- a/src/mbgl/layer/raster_layer.cpp +++ b/src/mbgl/layer/raster_layer.cpp @@ -3,7 +3,7 @@ namespace mbgl { -std::unique_ptr RasterLayer::clone() const { +std::unique_ptr RasterLayer::clone() const { return std::make_unique(*this); } diff --git a/src/mbgl/layer/raster_layer.hpp b/src/mbgl/layer/raster_layer.hpp index fc571617ab4..1a1c91d792f 100644 --- a/src/mbgl/layer/raster_layer.hpp +++ b/src/mbgl/layer/raster_layer.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_RASTER_LAYER #define MBGL_RASTER_LAYER -#include +#include #include namespace mbgl { @@ -17,9 +17,9 @@ class RasterPaintProperties { PaintProperty fadeDuration { 0.0f }; }; -class RasterLayer : public StyleLayer { +class RasterLayer : public Layer::Impl { public: - std::unique_ptr clone() const override; + std::unique_ptr clone() const override; void parseLayout(const JSVal&) override {}; void parsePaints(const JSVal&) override; diff --git a/src/mbgl/layer/symbol_layer.cpp b/src/mbgl/layer/symbol_layer.cpp index dd810941d93..07869106022 100644 --- a/src/mbgl/layer/symbol_layer.cpp +++ b/src/mbgl/layer/symbol_layer.cpp @@ -5,7 +5,7 @@ namespace mbgl { -std::unique_ptr SymbolLayer::clone() const { +std::unique_ptr SymbolLayer::clone() const { return std::make_unique(*this); } diff --git a/src/mbgl/layer/symbol_layer.hpp b/src/mbgl/layer/symbol_layer.hpp index 42d0bb9c74b..597207c8c6a 100644 --- a/src/mbgl/layer/symbol_layer.hpp +++ b/src/mbgl/layer/symbol_layer.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_SYMBOL_LAYER #define MBGL_SYMBOL_LAYER -#include +#include #include #include @@ -82,9 +82,9 @@ class SymbolPaintProperties { PaintProperties text { 16.0f }; }; -class SymbolLayer : public StyleLayer { +class SymbolLayer : public Layer::Impl { public: - std::unique_ptr clone() const override; + std::unique_ptr clone() const override; void parseLayout(const JSVal&) override; void parsePaints(const JSVal&) override; diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp index 1896e7d29bb..120f8cdc461 100644 --- a/src/mbgl/map/map.cpp +++ b/src/mbgl/map/map.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include @@ -425,11 +425,11 @@ LatLngBounds Map::getBoundsForAnnotations(const AnnotationIDs& annotations) { #pragma mark - Style API -void Map::addLayer(std::unique_ptr layer) { +void Map::addLayer(std::unique_ptr layer) { context->invoke(&MapContext::addLayer, std::move(layer), mapbox::util::optional()); } -void Map::addLayer(std::unique_ptr layer, const std::string& before) { +void Map::addLayer(std::unique_ptr layer, const std::string& before) { context->invoke(&MapContext::addLayer, std::move(layer), before); } diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp index c5fcc7ff0ed..bfd902ab0ef 100644 --- a/src/mbgl/map/map_context.cpp +++ b/src/mbgl/map/map_context.cpp @@ -11,7 +11,7 @@ #include #include -#include +#include #include #include @@ -278,7 +278,7 @@ double MapContext::getTopOffsetPixelsForAnnotationIcon(const std::string& name) return data.getAnnotationManager()->getTopOffsetPixelsForIcon(name); } -void MapContext::addLayer(std::unique_ptr layer, mapbox::util::optional after) { +void MapContext::addLayer(std::unique_ptr layer, mapbox::util::optional after) { style->addLayer(std::move(layer), after); } diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp index 8e0dbd80c09..f41bc984511 100644 --- a/src/mbgl/map/map_context.hpp +++ b/src/mbgl/map/map_context.hpp @@ -56,7 +56,7 @@ class MapContext : public Style::Observer { void updateAnnotations(); // Style API - void addLayer(std::unique_ptr, + void addLayer(std::unique_ptr, const mapbox::util::optional before); void setSourceTileCacheSize(size_t size); diff --git a/src/mbgl/map/raster_tile_data.cpp b/src/mbgl/map/raster_tile_data.cpp index 7ef13301e8b..fe220d05a75 100644 --- a/src/mbgl/map/raster_tile_data.cpp +++ b/src/mbgl/map/raster_tile_data.cpp @@ -79,7 +79,7 @@ void RasterTileData::request(float pixelRatio, }); } -Bucket* RasterTileData::getBucket(StyleLayer const&) { +Bucket* RasterTileData::getBucket(const Layer&) { return bucket.get(); } diff --git a/src/mbgl/map/raster_tile_data.hpp b/src/mbgl/map/raster_tile_data.hpp index 54330b73a80..03120d0756f 100644 --- a/src/mbgl/map/raster_tile_data.hpp +++ b/src/mbgl/map/raster_tile_data.hpp @@ -8,7 +8,7 @@ namespace mbgl { class SourceInfo; class FileRequest; -class StyleLayer; +class Layer; class TexturePool; class WorkRequest; @@ -24,7 +24,7 @@ class RasterTileData : public TileData { void cancel() override; - Bucket* getBucket(StyleLayer const &layer_desc) override; + Bucket* getBucket(const Layer&) override; private: TexturePool& texturePool; diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp index 16e2630a946..62e02de13fa 100644 --- a/src/mbgl/map/source.cpp +++ b/src/mbgl/map/source.cpp @@ -14,7 +14,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/src/mbgl/map/tile_data.hpp b/src/mbgl/map/tile_data.hpp index ed3426cf80e..2ced90d424e 100644 --- a/src/mbgl/map/tile_data.hpp +++ b/src/mbgl/map/tile_data.hpp @@ -14,7 +14,7 @@ namespace mbgl { -class StyleLayer; +class Layer; class Worker; class DebugBucket; @@ -75,7 +75,7 @@ class TileData : private util::noncopyable { // Mark this tile as no longer needed and cancel any pending work. virtual void cancel() = 0; - virtual Bucket* getBucket(const StyleLayer&) = 0; + virtual Bucket* getBucket(const Layer&) = 0; virtual bool parsePending(std::function) { return true; } virtual void redoPlacement(PlacementConfig) {} diff --git a/src/mbgl/map/tile_worker.cpp b/src/mbgl/map/tile_worker.cpp index c35b3d8b3cd..27f40fb387a 100644 --- a/src/mbgl/map/tile_worker.cpp +++ b/src/mbgl/map/tile_worker.cpp @@ -1,7 +1,7 @@ #include #include #include -#include +#include #include #include #include @@ -34,7 +34,7 @@ TileWorker::~TileWorker() { glyphAtlas.removeGlyphs(reinterpret_cast(this)); } -TileParseResult TileWorker::parseAllLayers(std::vector> layers_, +TileParseResult TileWorker::parseAllLayers(std::vector> layers_, const GeometryTile& geometryTile, PlacementConfig config) { // We're doing a fresh parse of the tile, because the underlying data has changed. @@ -52,9 +52,9 @@ TileParseResult TileWorker::parseAllLayers(std::vector parsed; for (auto i = layers.rbegin(); i != layers.rend(); i++) { - const StyleLayer* layer = i->get(); - if (parsed.find(layer->bucketName()) == parsed.end()) { - parsed.emplace(layer->bucketName()); + const Layer* layer = i->get(); + if (parsed.find(layer->impl->bucketName()) == parsed.end()) { + parsed.emplace(layer->impl->bucketName()); parseLayer(layer, geometryTile); } } @@ -98,36 +98,36 @@ void TileWorker::redoPlacement( collisionTile = std::make_unique(config); for (auto i = layers.rbegin(); i != layers.rend(); i++) { - const auto it = buckets->find((*i)->id); + const auto it = buckets->find((*i)->impl->id); if (it != buckets->end()) { it->second->placeFeatures(*collisionTile); } } } -void TileWorker::parseLayer(const StyleLayer* layer, const GeometryTile& geometryTile) { +void TileWorker::parseLayer(const Layer* layer, const GeometryTile& geometryTile) { // Cancel early when parsing. if (state == TileData::State::obsolete) return; // Background and custom layers are special cases. - if (layer->is() || layer->is()) + if (layer->impl->is() || layer->impl->is()) return; // Skip this bucket if we are to not render this - if ((layer->source != sourceID) || - (id.z < std::floor(layer->minZoom)) || - (id.z >= std::ceil(layer->maxZoom)) || - (layer->visibility == VisibilityType::None)) { + if ((layer->impl->source != sourceID) || + (id.z < std::floor(layer->impl->minZoom)) || + (id.z >= std::ceil(layer->impl->maxZoom)) || + (layer->impl->visibility == VisibilityType::None)) { return; } - auto geometryLayer = geometryTile.getLayer(layer->sourceLayer); + auto geometryLayer = geometryTile.getLayer(layer->impl->sourceLayer); if (!geometryLayer) { // The layer specified in the bucket does not exist. Do nothing. if (debug::tileParseWarnings) { Log::Warning(Event::ParseTile, "layer '%s' does not exist in tile %d/%d/%d", - layer->sourceLayer.c_str(), id.z, id.x, id.y); + layer->impl->sourceLayer.c_str(), id.z, id.x, id.y); } return; } @@ -142,13 +142,13 @@ void TileWorker::parseLayer(const StyleLayer* layer, const GeometryTile& geometr glyphStore, *collisionTile); - std::unique_ptr bucket = layer->createBucket(parameters); + std::unique_ptr bucket = layer->impl->createBucket(parameters); - if (layer->is() && partialParse) { + if (layer->impl->is() && partialParse) { // We cannot parse this bucket yet. Instead, we're saving it for later. - pending.emplace_back(layer->as(), std::move(bucket)); + pending.emplace_back(layer->impl->as(), std::move(bucket)); } else { - insertBucket(layer->bucketName(), std::move(bucket)); + insertBucket(layer->impl->bucketName(), std::move(bucket)); } } diff --git a/src/mbgl/map/tile_worker.hpp b/src/mbgl/map/tile_worker.hpp index 14f996c1b0b..bd5c708a9fd 100644 --- a/src/mbgl/map/tile_worker.hpp +++ b/src/mbgl/map/tile_worker.hpp @@ -22,7 +22,7 @@ class SpriteStore; class GlyphAtlas; class GlyphStore; class Bucket; -class StyleLayer; +class Layer; class SymbolLayer; // We're using this class to shuttle the resulting buckets from the worker thread to the MapContext @@ -46,7 +46,7 @@ class TileWorker : public util::noncopyable { const std::atomic&); ~TileWorker(); - TileParseResult parseAllLayers(std::vector>, + TileParseResult parseAllLayers(std::vector>, const GeometryTile&, PlacementConfig); @@ -56,7 +56,7 @@ class TileWorker : public util::noncopyable { PlacementConfig); private: - void parseLayer(const StyleLayer*, const GeometryTile&); + void parseLayer(const Layer*, const GeometryTile&); void insertBucket(const std::string& name, std::unique_ptr); const TileID id; @@ -69,7 +69,7 @@ class TileWorker : public util::noncopyable { bool partialParse = false; - std::vector> layers; + std::vector> layers; std::unique_ptr collisionTile; // Contains buckets that we couldn't parse so far due to missing resources. diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp index 708ded02cc4..3bad1c6f136 100644 --- a/src/mbgl/map/vector_tile_data.cpp +++ b/src/mbgl/map/vector_tile_data.cpp @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include #include @@ -142,8 +142,8 @@ bool VectorTileData::parsePending(std::function callback) { return true; } -Bucket* VectorTileData::getBucket(const StyleLayer& layer) { - const auto it = buckets.find(layer.bucketName()); +Bucket* VectorTileData::getBucket(const Layer& layer) { + const auto it = buckets.find(layer.impl->bucketName()); if (it == buckets.end()) { return nullptr; } diff --git a/src/mbgl/map/vector_tile_data.hpp b/src/mbgl/map/vector_tile_data.hpp index 1b31f3db861..732576befd9 100644 --- a/src/mbgl/map/vector_tile_data.hpp +++ b/src/mbgl/map/vector_tile_data.hpp @@ -26,7 +26,7 @@ class VectorTileData : public TileData { ~VectorTileData(); - Bucket* getBucket(const StyleLayer&) override; + Bucket* getBucket(const Layer&) override; bool parsePending(std::function callback) override; diff --git a/src/mbgl/renderer/bucket.hpp b/src/mbgl/renderer/bucket.hpp index b7cbfdf0fe4..26294211270 100644 --- a/src/mbgl/renderer/bucket.hpp +++ b/src/mbgl/renderer/bucket.hpp @@ -14,7 +14,7 @@ namespace mbgl { class Painter; -class StyleLayer; +class Layer; class TileID; class CollisionTile; @@ -28,7 +28,7 @@ class Bucket : private util::noncopyable { // Every time this bucket is getting rendered, this function is called. This happens either // once or twice (for Opaque and Transparent render passes). - virtual void render(Painter&, const StyleLayer&, const TileID&, const mat4&) = 0; + virtual void render(Painter&, const Layer&, const TileID&, const mat4&) = 0; virtual ~Bucket() = default; diff --git a/src/mbgl/renderer/circle_bucket.cpp b/src/mbgl/renderer/circle_bucket.cpp index 13a3cebafe2..d452752fcc6 100644 --- a/src/mbgl/renderer/circle_bucket.cpp +++ b/src/mbgl/renderer/circle_bucket.cpp @@ -20,10 +20,10 @@ void CircleBucket::upload() { } void CircleBucket::render(Painter& painter, - const StyleLayer& layer, + const Layer& layer, const TileID& id, const mat4& matrix) { - painter.renderCircle(*this, *layer.as(), id, matrix); + painter.renderCircle(*this, *layer.impl->as(), id, matrix); } bool CircleBucket::hasData() const { diff --git a/src/mbgl/renderer/circle_bucket.hpp b/src/mbgl/renderer/circle_bucket.hpp index f85c9267d3a..58357cb30d8 100644 --- a/src/mbgl/renderer/circle_bucket.hpp +++ b/src/mbgl/renderer/circle_bucket.hpp @@ -21,7 +21,7 @@ class CircleBucket : public Bucket { ~CircleBucket() override; void upload() override; - void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; + void render(Painter&, const Layer&, const TileID&, const mat4&) override; bool hasData() const override; void addGeometry(const GeometryCollection&); diff --git a/src/mbgl/renderer/fill_bucket.cpp b/src/mbgl/renderer/fill_bucket.cpp index ff976c24507..a7f773872d6 100644 --- a/src/mbgl/renderer/fill_bucket.cpp +++ b/src/mbgl/renderer/fill_bucket.cpp @@ -196,10 +196,10 @@ void FillBucket::upload() { } void FillBucket::render(Painter& painter, - const StyleLayer& layer, + const Layer& layer, const TileID& id, const mat4& matrix) { - painter.renderFill(*this, *layer.as(), id, matrix); + painter.renderFill(*this, *layer.impl->as(), id, matrix); } bool FillBucket::hasData() const { diff --git a/src/mbgl/renderer/fill_bucket.hpp b/src/mbgl/renderer/fill_bucket.hpp index 674c41f7d1c..bdbc0d3bf2f 100644 --- a/src/mbgl/renderer/fill_bucket.hpp +++ b/src/mbgl/renderer/fill_bucket.hpp @@ -33,7 +33,7 @@ class FillBucket : public Bucket { ~FillBucket() override; void upload() override; - void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; + void render(Painter&, const Layer&, const TileID&, const mat4&) override; bool hasData() const override; void addGeometry(const GeometryCollection&); diff --git a/src/mbgl/renderer/line_bucket.cpp b/src/mbgl/renderer/line_bucket.cpp index 83c5b437769..006592c4c5e 100644 --- a/src/mbgl/renderer/line_bucket.cpp +++ b/src/mbgl/renderer/line_bucket.cpp @@ -387,10 +387,10 @@ void LineBucket::upload() { } void LineBucket::render(Painter& painter, - const StyleLayer& layer, + const Layer& layer, const TileID& id, const mat4& matrix) { - painter.renderLine(*this, *layer.as(), id, matrix); + painter.renderLine(*this, *layer.impl->as(), id, matrix); } bool LineBucket::hasData() const { diff --git a/src/mbgl/renderer/line_bucket.hpp b/src/mbgl/renderer/line_bucket.hpp index 7d662aac021..065d4a904fb 100644 --- a/src/mbgl/renderer/line_bucket.hpp +++ b/src/mbgl/renderer/line_bucket.hpp @@ -28,7 +28,7 @@ class LineBucket : public Bucket { ~LineBucket() override; void upload() override; - void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; + void render(Painter&, const Layer&, const TileID&, const mat4&) override; bool hasData() const override; void addGeometry(const GeometryCollection&); diff --git a/src/mbgl/renderer/painter.cpp b/src/mbgl/renderer/painter.cpp index cab9d492125..33a626a8326 100644 --- a/src/mbgl/renderer/painter.cpp +++ b/src/mbgl/renderer/painter.cpp @@ -9,7 +9,7 @@ #include #include -#include +#include #include #include @@ -219,9 +219,9 @@ void Painter::renderPass(RenderPass pass_, currentLayer = i; const auto& item = *it; - const StyleLayer& layer = item.layer; + const Layer& layer = item.layer; - if (!layer.hasRenderPass(pass)) + if (!layer.impl->hasRenderPass(pass)) continue; if (pass == RenderPass::Translucent) { @@ -234,15 +234,15 @@ void Painter::renderPass(RenderPass pass_, config.colorMask = { GL_TRUE, GL_TRUE, GL_TRUE, GL_TRUE }; config.stencilMask = 0x0; - if (layer.is()) { + if (layer.impl->is()) { MBGL_DEBUG_GROUP("background"); - renderBackground(*layer.as()); - } else if (layer.is()) { - MBGL_DEBUG_GROUP(layer.id + " - custom"); - layer.as()->render(StyleRenderParameters(state)); + renderBackground(*layer.impl->as()); + } else if (layer.impl->is()) { + MBGL_DEBUG_GROUP(layer.impl->id + " - custom"); + layer.impl->as()->render(StyleRenderParameters(state)); config.setDirty(); } else { - MBGL_DEBUG_GROUP(layer.id + " - " + std::string(item.tile->id)); + MBGL_DEBUG_GROUP(layer.impl->id + " - " + std::string(item.tile->id)); prepareTile(*item.tile); item.bucket->render(*this, layer, item.tile->id, item.tile->matrix); } diff --git a/src/mbgl/renderer/painter.hpp b/src/mbgl/renderer/painter.hpp index 7189bcc19be..1d3257339d1 100644 --- a/src/mbgl/renderer/painter.hpp +++ b/src/mbgl/renderer/painter.hpp @@ -26,7 +26,7 @@ namespace mbgl { class Style; -class StyleLayer; +class Layer; class Tile; class SpriteAtlas; class GlyphAtlas; diff --git a/src/mbgl/renderer/raster_bucket.cpp b/src/mbgl/renderer/raster_bucket.cpp index 7a3e27acddd..f2d8ddcdaa8 100644 --- a/src/mbgl/renderer/raster_bucket.cpp +++ b/src/mbgl/renderer/raster_bucket.cpp @@ -17,10 +17,10 @@ void RasterBucket::upload() { } void RasterBucket::render(Painter& painter, - const StyleLayer& layer, + const Layer& layer, const TileID& id, const mat4& matrix) { - painter.renderRaster(*this, *layer.as(), id, matrix); + painter.renderRaster(*this, *layer.impl->as(), id, matrix); } bool RasterBucket::setImage(PremultipliedImage image) { diff --git a/src/mbgl/renderer/raster_bucket.hpp b/src/mbgl/renderer/raster_bucket.hpp index 0f4263ec959..e7a7f4e02f9 100644 --- a/src/mbgl/renderer/raster_bucket.hpp +++ b/src/mbgl/renderer/raster_bucket.hpp @@ -15,7 +15,7 @@ class RasterBucket : public Bucket { RasterBucket(TexturePool&); void upload() override; - void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; + void render(Painter&, const Layer&, const TileID&, const mat4&) override; bool hasData() const override; bool setImage(PremultipliedImage); diff --git a/src/mbgl/renderer/symbol_bucket.cpp b/src/mbgl/renderer/symbol_bucket.cpp index cb8b29b471c..5753c399595 100644 --- a/src/mbgl/renderer/symbol_bucket.cpp +++ b/src/mbgl/renderer/symbol_bucket.cpp @@ -75,10 +75,10 @@ void SymbolBucket::upload() { } void SymbolBucket::render(Painter& painter, - const StyleLayer& layer, + const Layer& layer, const TileID& id, const mat4& matrix) { - painter.renderSymbol(*this, *layer.as(), id, matrix); + painter.renderSymbol(*this, *layer.impl->as(), id, matrix); } bool SymbolBucket::hasData() const { return hasTextData() || hasIconData() || !symbolInstances.empty(); } diff --git a/src/mbgl/renderer/symbol_bucket.hpp b/src/mbgl/renderer/symbol_bucket.hpp index 7150c9808c5..83cc252ace4 100644 --- a/src/mbgl/renderer/symbol_bucket.hpp +++ b/src/mbgl/renderer/symbol_bucket.hpp @@ -69,7 +69,7 @@ class SymbolBucket : public Bucket { ~SymbolBucket() override; void upload() override; - void render(Painter&, const StyleLayer&, const TileID&, const mat4&) override; + void render(Painter&, const Layer&, const TileID&, const mat4&) override; bool hasData() const override; bool hasTextData() const; bool hasIconData() const; diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp index 10e5c02d827..d6492441a74 100644 --- a/src/mbgl/style/style.cpp +++ b/src/mbgl/style/style.cpp @@ -7,7 +7,7 @@ #include #include #include -#include +#include #include #include #include @@ -57,7 +57,7 @@ void Style::setJSON(const std::string& json, const std::string&) { } for (auto& layer : parser.layers) { - addLayer(std::move(layer)); + addLayer(std::make_unique(std::move(layer))); } glyphStore->setURL(parser.glyphURL); @@ -81,34 +81,34 @@ void Style::addSource(std::unique_ptr source) { sources.emplace_back(std::move(source)); } -std::vector> Style::getLayers() const { - std::vector> result; +std::vector> Style::getLayers() const { + std::vector> result; result.reserve(layers.size()); for (const auto& layer : layers) { - result.push_back(layer->clone()); + result.push_back(std::make_unique(layer->impl->clone())); } return result; } -std::vector>::const_iterator Style::findLayer(const std::string& id) const { +std::vector>::const_iterator Style::findLayer(const std::string& id) const { return std::find_if(layers.begin(), layers.end(), [&](const auto& layer) { - return layer->id == id; + return layer->impl->id == id; }); } -StyleLayer* Style::getLayer(const std::string& id) const { +Layer* Style::getLayer(const std::string& id) const { auto it = findLayer(id); return it != layers.end() ? it->get() : nullptr; } -void Style::addLayer(std::unique_ptr layer, mapbox::util::optional before) { - if (SymbolLayer* symbolLayer = layer->as()) { +void Style::addLayer(std::unique_ptr layer, mapbox::util::optional before) { + if (SymbolLayer* symbolLayer = layer->impl->as()) { if (!symbolLayer->spriteAtlas) { symbolLayer->spriteAtlas = spriteAtlas.get(); } } - if (CustomLayer* customLayer = layer->as()) { + if (CustomLayer* customLayer = layer->impl->as()) { customLayer->initialize(); } @@ -164,7 +164,7 @@ void Style::cascade() { data.getDefaultTransitionDelay() }); for (const auto& layer : layers) { - layer->cascade(parameters); + layer->impl->cascade(parameters); } } @@ -181,9 +181,9 @@ void Style::recalculate(float z) { data.getDefaultFadeDuration()); for (const auto& layer : layers) { - hasPendingTransitions |= layer->recalculate(parameters); + hasPendingTransitions |= layer->impl->recalculate(parameters); - Source* source = getSource(layer->source); + Source* source = getSource(layer->impl->source); if (!source) { continue; } @@ -232,10 +232,10 @@ RenderData Style::getRenderData() const { } for (const auto& layer : layers) { - if (layer->visibility == VisibilityType::None) + if (layer->impl->visibility == VisibilityType::None) continue; - if (const BackgroundLayer* background = layer->as()) { + if (const BackgroundLayer* background = layer->impl->as()) { if (background->paint.pattern.value.from.empty()) { // This is a solid background. We can use glClear(). result.backgroundColor = background->paint.color; @@ -250,14 +250,14 @@ RenderData Style::getRenderData() const { continue; } - if (layer->is()) { + if (layer->impl->is()) { result.order.emplace_back(*layer); continue; } - Source* source = getSource(layer->source); + Source* source = getSource(layer->impl->source); if (!source) { - Log::Warning(Event::Render, "can't find source for layer '%s'", layer->id.c_str()); + Log::Warning(Event::Render, "can't find source for layer '%s'", layer->impl->id.c_str()); continue; } @@ -268,7 +268,7 @@ RenderData Style::getRenderData() const { // We're not clipping symbol layers, so when we have both parents and children of symbol // layers, we drop all children in favor of their parent to avoid duplicate labels. // See https://github.com/mapbox/mapbox-gl-native/issues/2482 - if (layer->is()) { + if (layer->impl->is()) { bool skip = false; // Look back through the buckets we decided to render to find out whether there is // already a bucket from this layer that is a parent of this tile. Tiles are ordered diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp index ed5df042568..f9da7f62e45 100644 --- a/src/mbgl/style/style.hpp +++ b/src/mbgl/style/style.hpp @@ -25,7 +25,7 @@ class GlyphStore; class SpriteStore; class SpriteAtlas; class LineAtlas; -class StyleLayer; +class Layer; class TransformState; class TexturePool; @@ -33,7 +33,7 @@ class Tile; class Bucket; struct RenderItem { - inline RenderItem(const StyleLayer& layer_, + inline RenderItem(const Layer& layer_, const Tile* tile_ = nullptr, Bucket* bucket_ = nullptr) : tile(tile_), bucket(bucket_), layer(layer_) { @@ -41,7 +41,7 @@ struct RenderItem { const Tile* const tile; Bucket* const bucket; - const StyleLayer& layer; + const Layer& layer; }; struct RenderData { @@ -88,9 +88,9 @@ class Style : public GlyphStore::Observer, Source* getSource(const std::string& id) const; void addSource(std::unique_ptr); - std::vector> getLayers() const; - StyleLayer* getLayer(const std::string& id) const; - void addLayer(std::unique_ptr, + std::vector> getLayers() const; + Layer* getLayer(const std::string& id) const; + void addLayer(std::unique_ptr, mapbox::util::optional beforeLayerID = {}); void removeLayer(const std::string& layerID); @@ -110,9 +110,9 @@ class Style : public GlyphStore::Observer, private: std::vector> sources; - std::vector> layers; + std::vector> layers; - std::vector>::const_iterator findLayer(const std::string& layerID) const; + std::vector>::const_iterator findLayer(const std::string& layerID) const; // GlyphStore::Observer implementation. void onGlyphRangeLoaded() override; diff --git a/src/mbgl/style/style_layer.cpp b/src/mbgl/style/style_layer.cpp deleted file mode 100644 index c9d2733faed..00000000000 --- a/src/mbgl/style/style_layer.cpp +++ /dev/null @@ -1,13 +0,0 @@ -#include - -namespace mbgl { - -const std::string& StyleLayer::bucketName() const { - return ref.empty() ? id : ref; -} - -bool StyleLayer::hasRenderPass(RenderPass pass) const { - return bool(passes & pass); -} - -} // namespace mbgl diff --git a/src/mbgl/style/style_parser.cpp b/src/mbgl/style/style_parser.cpp index a22615d4356..d986f6b8526 100644 --- a/src/mbgl/style/style_parser.cpp +++ b/src/mbgl/style/style_parser.cpp @@ -141,7 +141,7 @@ void StyleParser::parseLayers(const JSVal& value) { continue; } - layersMap.emplace(layerID, std::pair> { layerValue, nullptr }); + layersMap.emplace(layerID, std::pair> { layerValue, nullptr }); ids.push_back(layerID); } @@ -162,7 +162,7 @@ void StyleParser::parseLayers(const JSVal& value) { } } -void StyleParser::parseLayer(const std::string& id, const JSVal& value, std::unique_ptr& layer) { +void StyleParser::parseLayer(const std::string& id, const JSVal& value, std::unique_ptr& layer) { if (layer) { // Skip parsing this again. We already have a valid layer definition. return; @@ -196,7 +196,7 @@ void StyleParser::parseLayer(const std::string& id, const JSVal& value, std::uni it->second.second); stack.pop_front(); - StyleLayer* reference = it->second.second.get(); + Layer::Impl* reference = it->second.second.get(); if (!reference) { return; } @@ -292,7 +292,7 @@ void StyleParser::parseLayer(const std::string& id, const JSVal& value, std::uni layer->parsePaints(value); } -void StyleParser::parseVisibility(StyleLayer& layer, const JSVal& value) { +void StyleParser::parseVisibility(Layer::Impl& layer, const JSVal& value) { if (!value.HasMember("visibility")) { return; } else if (!value["visibility"].IsString()) { diff --git a/src/mbgl/style/style_parser.hpp b/src/mbgl/style/style_parser.hpp index 2c5a43065da..d804d4cf55e 100644 --- a/src/mbgl/style/style_parser.hpp +++ b/src/mbgl/style/style_parser.hpp @@ -1,7 +1,7 @@ #ifndef MBGL_STYLE_STYLE_PARSER #define MBGL_STYLE_STYLE_PARSER -#include +#include #include #include @@ -14,9 +14,6 @@ namespace mbgl { -class StyleLayer; -class Source; - using JSVal = rapidjson::Value; class StyleParser { @@ -29,16 +26,16 @@ class StyleParser { std::string glyphURL; std::vector> sources; - std::vector> layers; + std::vector> layers; private: void parseSources(const JSVal&); void parseLayers(const JSVal&); - void parseLayer(const std::string& id, const JSVal&, std::unique_ptr&); - void parseVisibility(StyleLayer&, const JSVal& value); + void parseLayer(const std::string& id, const JSVal&, std::unique_ptr&); + void parseVisibility(Layer::Impl&, const JSVal& value); std::unordered_map sourcesMap; - std::unordered_map>> layersMap; + std::unordered_map>> layersMap; // Store a stack of layer IDs we're parsing right now. This is to prevent reference cycles. std::forward_list stack; diff --git a/src/mbgl/util/worker.cpp b/src/mbgl/util/worker.cpp index 34f18dd3f4d..3759f6b1f9a 100644 --- a/src/mbgl/util/worker.cpp +++ b/src/mbgl/util/worker.cpp @@ -4,7 +4,7 @@ #include #include #include -#include +#include #include #include @@ -34,7 +34,7 @@ class Worker::Impl { } void parseGeometryTile(TileWorker* worker, - std::vector> layers, + std::vector> layers, std::unique_ptr tile, PlacementConfig config, std::function callback) { @@ -83,7 +83,7 @@ Worker::parseRasterTile(std::unique_ptr bucket, std::unique_ptr Worker::parseGeometryTile(TileWorker& worker, - std::vector> layers, + std::vector> layers, std::unique_ptr tile, PlacementConfig config, std::function callback) { diff --git a/src/mbgl/util/worker.hpp b/src/mbgl/util/worker.hpp index 5ba477491de..ad94d32e359 100644 --- a/src/mbgl/util/worker.hpp +++ b/src/mbgl/util/worker.hpp @@ -40,7 +40,7 @@ class Worker : public mbgl::util::noncopyable { std::function callback); Request parseGeometryTile(TileWorker&, - std::vector>, + std::vector>, std::unique_ptr, PlacementConfig, std::function callback); diff --git a/test/api/custom_layer.cpp b/test/api/custom_layer.cpp index 816a53dd35e..48de64241f6 100644 --- a/test/api/custom_layer.cpp +++ b/test/api/custom_layer.cpp @@ -59,7 +59,7 @@ class TestLayer : public CustomLayer { MBGL_CHECK_ERROR(glDrawArrays(GL_TRIANGLE_STRIP, 0, 4)); } - std::unique_ptr clone() const override { + std::unique_ptr clone() const override { return std::make_unique(*this); } diff --git a/test/style/style_layer.cpp b/test/style/style_layer.cpp index 40c4df2b438..be14ae16d66 100644 --- a/test/style/style_layer.cpp +++ b/test/style/style_layer.cpp @@ -1,23 +1,23 @@ #include "../fixtures/util.hpp" -#include +#include #include using namespace mbgl; -TEST(StyleLayer, Create) { - std::unique_ptr layer = std::make_unique(); +TEST(Layer::Impl, Create) { + std::unique_ptr layer = std::make_unique(); EXPECT_TRUE(reinterpret_cast(layer.get())); } -TEST(StyleLayer, Clone) { - std::unique_ptr layer = std::make_unique(); - std::unique_ptr clone = layer->clone(); +TEST(Layer::Impl, Clone) { + std::unique_ptr layer = std::make_unique(); + std::unique_ptr clone = layer->clone(); EXPECT_NE(layer.get(), clone.get()); EXPECT_TRUE(reinterpret_cast(layer.get())); } -TEST(StyleLayer, CloneCopiesBaseProperties) { +TEST(Layer::Impl, CloneCopiesBaseProperties) { std::unique_ptr layer = std::make_unique(); layer->id = "test"; EXPECT_EQ("test", layer->clone()->id);