summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-10-29 14:26:34 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-10-30 11:17:01 -0700
commit8c3b3cb792d0157aee4918c4ece822ec0fcfb381 (patch)
treeb0c684f517005dee5f8d48d64b85ddb31e7cddad
parent7669e02062ccab9e3d908a9eab04f5d13a7b89c0 (diff)
downloadqtlocation-mapboxgl-8c3b3cb792d0157aee4918c4ece822ec0fcfb381.tar.gz
[core] Use current copy of style layers when reparsing tiles
This fixes adding shape annotations after VectorTileData objects have been created for annotations already, and will also be necessary for the dynamic Style API.
-rw-r--r--src/mbgl/map/tile_worker.cpp8
-rw-r--r--src/mbgl/map/tile_worker.hpp12
-rw-r--r--src/mbgl/map/vector_tile_data.cpp8
-rw-r--r--src/mbgl/map/vector_tile_data.hpp1
-rw-r--r--src/mbgl/util/worker.cpp12
-rw-r--r--src/mbgl/util/worker.hpp2
6 files changed, 26 insertions, 17 deletions
diff --git a/src/mbgl/map/tile_worker.cpp b/src/mbgl/map/tile_worker.cpp
index 96300a803f..0262ed420c 100644
--- a/src/mbgl/map/tile_worker.cpp
+++ b/src/mbgl/map/tile_worker.cpp
@@ -18,10 +18,8 @@ using namespace mbgl;
TileWorker::TileWorker(TileID id_,
std::string sourceID_,
Style& style_,
- std::vector<util::ptr<StyleLayer>> layers_,
const std::atomic<TileData::State>& state_)
- : layers(std::move(layers_)),
- id(id_),
+ : id(id_),
sourceID(sourceID_),
parameters(id.z),
style(style_),
@@ -33,7 +31,8 @@ TileWorker::~TileWorker() {
style.glyphAtlas->removeGlyphs(reinterpret_cast<uintptr_t>(this));
}
-TileParseResult TileWorker::parseAllLayers(const GeometryTile& geometryTile,
+TileParseResult TileWorker::parseAllLayers(std::vector<util::ptr<StyleLayer>> layers,
+ const GeometryTile& geometryTile,
PlacementConfig config) {
// We're doing a fresh parse of the tile, because the underlying data has changed.
pending.clear();
@@ -85,6 +84,7 @@ TileParseResult TileWorker::parsePendingLayers() {
}
void TileWorker::redoPlacement(
+ std::vector<util::ptr<StyleLayer>> layers,
const std::unordered_map<std::string, std::unique_ptr<Bucket>>* buckets,
PlacementConfig config) {
diff --git a/src/mbgl/map/tile_worker.hpp b/src/mbgl/map/tile_worker.hpp
index 44868a12ff..fc6844445c 100644
--- a/src/mbgl/map/tile_worker.hpp
+++ b/src/mbgl/map/tile_worker.hpp
@@ -42,16 +42,18 @@ public:
TileWorker(TileID,
std::string sourceID,
Style&,
- std::vector<util::ptr<StyleLayer>>,
const std::atomic<TileData::State>&);
~TileWorker();
- TileParseResult parseAllLayers(const GeometryTile&, PlacementConfig);
+ TileParseResult parseAllLayers(std::vector<util::ptr<StyleLayer>>,
+ const GeometryTile&,
+ PlacementConfig);
+
TileParseResult parsePendingLayers();
- void redoPlacement(const std::unordered_map<std::string, std::unique_ptr<Bucket>>*,
- PlacementConfig);
- std::vector<util::ptr<StyleLayer>> layers;
+ void redoPlacement(std::vector<util::ptr<StyleLayer>>,
+ const std::unordered_map<std::string, std::unique_ptr<Bucket>>*,
+ PlacementConfig);
private:
void parseLayer(const StyleLayer&, const GeometryTile&);
diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp
index 90603c0a64..0f383295fd 100644
--- a/src/mbgl/map/vector_tile_data.cpp
+++ b/src/mbgl/map/vector_tile_data.cpp
@@ -16,16 +16,16 @@ VectorTileData::VectorTileData(const TileID& id_,
Style& style_,
const std::function<void()>& callback)
: TileData(id_),
+ style(style_),
worker(style_.workers),
tileWorker(id_,
sourceID,
style_,
- style_.layers,
state),
monitor(std::move(monitor_))
{
state = State::loading;
- req = monitor->monitorTile([callback, sourceID, this](std::exception_ptr err, std::unique_ptr<GeometryTile> tile) {
+ req = monitor->monitorTile([callback, this](std::exception_ptr err, std::unique_ptr<GeometryTile> tile) {
if (err) {
try {
std::rethrow_exception(err);
@@ -54,7 +54,7 @@ VectorTileData::VectorTileData(const TileID& id_,
// when tile data changed. Replacing the workdRequest will cancel a pending work
// request in case there is one.
workRequest.reset();
- workRequest = worker.parseGeometryTile(tileWorker, std::move(tile), targetConfig, [callback, sourceID, this, config = targetConfig] (TileParseResult result) {
+ workRequest = worker.parseGeometryTile(tileWorker, style.layers, std::move(tile), targetConfig, [callback, this, config = targetConfig] (TileParseResult result) {
workRequest.reset();
if (state == State::obsolete) {
return;
@@ -162,7 +162,7 @@ void VectorTileData::redoPlacement(const PlacementConfig newConfig) {
void VectorTileData::redoPlacement() {
workRequest.reset();
- workRequest = worker.redoPlacement(tileWorker, buckets, targetConfig, [this, config = targetConfig] {
+ workRequest = worker.redoPlacement(tileWorker, style.layers, buckets, targetConfig, [this, config = targetConfig] {
workRequest.reset();
// Persist the configuration we just placed so that we can later check whether we need to
diff --git a/src/mbgl/map/vector_tile_data.hpp b/src/mbgl/map/vector_tile_data.hpp
index 1a082fc610..81064e3133 100644
--- a/src/mbgl/map/vector_tile_data.hpp
+++ b/src/mbgl/map/vector_tile_data.hpp
@@ -36,6 +36,7 @@ public:
void cancel() override;
private:
+ Style& style;
Worker& worker;
TileWorker tileWorker;
diff --git a/src/mbgl/util/worker.cpp b/src/mbgl/util/worker.cpp
index b0005eda6f..9940fb649c 100644
--- a/src/mbgl/util/worker.cpp
+++ b/src/mbgl/util/worker.cpp
@@ -30,11 +30,12 @@ public:
}
void parseGeometryTile(TileWorker* worker,
+ std::vector<util::ptr<StyleLayer>> layers,
std::unique_ptr<GeometryTile> tile,
PlacementConfig config,
std::function<void(TileParseResult)> callback) {
try {
- callback(worker->parseAllLayers(*tile, config));
+ callback(worker->parseAllLayers(layers, *tile, config));
} catch (const std::exception& ex) {
callback(TileParseResult(ex.what()));
}
@@ -50,10 +51,11 @@ public:
}
void redoPlacement(TileWorker* worker,
+ std::vector<util::ptr<StyleLayer>> layers,
const std::unordered_map<std::string, std::unique_ptr<Bucket>>* buckets,
PlacementConfig config,
std::function<void()> callback) {
- worker->redoPlacement(buckets, config);
+ worker->redoPlacement(layers, buckets, config);
callback();
}
};
@@ -78,12 +80,13 @@ Worker::parseRasterTile(std::unique_ptr<RasterBucket> bucket,
std::unique_ptr<WorkRequest>
Worker::parseGeometryTile(TileWorker& worker,
+ std::vector<util::ptr<StyleLayer>> layers,
std::unique_ptr<GeometryTile> tile,
PlacementConfig config,
std::function<void(TileParseResult)> callback) {
current = (current + 1) % threads.size();
return threads[current]->invokeWithCallback(&Worker::Impl::parseGeometryTile, callback, &worker,
- std::move(tile), config);
+ std::move(layers), std::move(tile), config);
}
std::unique_ptr<WorkRequest>
@@ -96,12 +99,13 @@ Worker::parsePendingGeometryTileLayers(TileWorker& worker,
std::unique_ptr<WorkRequest>
Worker::redoPlacement(TileWorker& worker,
+ std::vector<util::ptr<StyleLayer>> layers,
const std::unordered_map<std::string, std::unique_ptr<Bucket>>& buckets,
PlacementConfig config,
std::function<void()> callback) {
current = (current + 1) % threads.size();
return threads[current]->invokeWithCallback(&Worker::Impl::redoPlacement, callback, &worker,
- &buckets, config);
+ layers, &buckets, config);
}
} // end namespace mbgl
diff --git a/src/mbgl/util/worker.hpp b/src/mbgl/util/worker.hpp
index e7bd3daada..f0f291e24c 100644
--- a/src/mbgl/util/worker.hpp
+++ b/src/mbgl/util/worker.hpp
@@ -40,6 +40,7 @@ public:
std::function<void(RasterTileParseResult)> callback);
Request parseGeometryTile(TileWorker&,
+ std::vector<util::ptr<StyleLayer>>,
std::unique_ptr<GeometryTile>,
PlacementConfig,
std::function<void(TileParseResult)> callback);
@@ -48,6 +49,7 @@ public:
std::function<void(TileParseResult)> callback);
Request redoPlacement(TileWorker&,
+ std::vector<util::ptr<StyleLayer>>,
const std::unordered_map<std::string, std::unique_ptr<Bucket>>&,
PlacementConfig config,
std::function<void()> callback);