summaryrefslogtreecommitdiff
path: root/src/mbgl/map/vector_tile_data.cpp
diff options
context:
space:
mode:
authorThiago Marcos P. Santos <thiago@mapbox.com>2015-06-17 16:41:36 +0300
committerThiago Marcos P. Santos <thiago@mapbox.com>2015-06-18 13:39:18 +0300
commit044454417b61bdd102a376c1125ad6ee3a5eacd4 (patch)
tree60110593b32ceb3a1670d9f40be7e72d13647ab9 /src/mbgl/map/vector_tile_data.cpp
parent1f12bcee900732064e6956ac2c23c9066ab5779f (diff)
downloadqtlocation-mapboxgl-044454417b61bdd102a376c1125ad6ee3a5eacd4.tar.gz
Do not hold a reference to the Style at the [Live|Vector]TileData
Layers are added and removed dynamically on the Map thread when we use shape annotations and we are iterating style.layers on the Worker thread without any lock. Now when we create a [Live|Vector]TileData at the Map thread we give it a layers list (instead of the Style) and [Live|Vector]TileData will ultimately make a copy of this list (on the Map thread, so no concurrency with adding shape annotations). The copy should be relatively cheap because we are using a shared pointer for storing the layers on the list.
Diffstat (limited to 'src/mbgl/map/vector_tile_data.cpp')
-rw-r--r--src/mbgl/map/vector_tile_data.cpp16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/mbgl/map/vector_tile_data.cpp b/src/mbgl/map/vector_tile_data.cpp
index 6dc6e8e9b3..017d3ecb7c 100644
--- a/src/mbgl/map/vector_tile_data.cpp
+++ b/src/mbgl/map/vector_tile_data.cpp
@@ -9,12 +9,12 @@
#include <mbgl/util/pbf.hpp>
#include <mbgl/util/worker.hpp>
#include <mbgl/util/work_request.hpp>
-#include <mbgl/style/style.hpp>
using namespace mbgl;
VectorTileData::VectorTileData(const TileID& id_,
- Style& style_,
+ const std::vector<util::ptr<StyleLayer>>& layers_,
+ Worker& workers_,
GlyphAtlas& glyphAtlas_,
GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_,
@@ -23,11 +23,12 @@ VectorTileData::VectorTileData(const TileID& id_,
float angle,
bool collisionDebug)
: TileData(id_, source_),
+ layers(layers_),
+ workers(workers_),
glyphAtlas(glyphAtlas_),
glyphStore(glyphStore_),
spriteAtlas(spriteAtlas_),
sprite(sprite_),
- style(style_),
collision(std::make_unique<CollisionTile>(id_.z, 4096, source_.tile_size * id.overscaling, angle, collisionDebug)),
lastAngle(angle),
currentAngle(angle) {
@@ -51,7 +52,7 @@ void VectorTileData::parse() {
// is going to be discarded afterwards.
VectorTile vectorTile(pbf((const uint8_t *)data.data(), data.size()));
const VectorTile* vt = &vectorTile;
- TileParser parser(*vt, *this, style, glyphAtlas, glyphStore, spriteAtlas, sprite);
+ TileParser parser(*vt, *this, layers, glyphAtlas, glyphStore, spriteAtlas, sprite);
parser.parse();
if (getState() == State::obsolete) {
@@ -128,15 +129,14 @@ void VectorTileData::redoPlacement(float angle, bool collisionDebug) {
currentCollisionDebug = collisionDebug;
auto callback = std::bind(&VectorTileData::endRedoPlacement, this);
- workRequest = style.workers.send([this, angle, collisionDebug] { workerRedoPlacement(angle, collisionDebug); }, callback);
-
+ workRequest = workers.send([this, angle, collisionDebug] { workerRedoPlacement(angle, collisionDebug); }, callback);
}
}
void VectorTileData::workerRedoPlacement(float angle, bool collisionDebug) {
collision->reset(angle, 0);
collision->setDebug(collisionDebug);
- for (const auto& layer_desc : style.layers) {
+ for (const auto& layer_desc : layers) {
auto bucket = getBucket(*layer_desc);
if (bucket) {
bucket->placeFeatures();
@@ -145,7 +145,7 @@ void VectorTileData::workerRedoPlacement(float angle, bool collisionDebug) {
}
void VectorTileData::endRedoPlacement() {
- for (const auto& layer_desc : style.layers) {
+ for (const auto& layer_desc : layers) {
auto bucket = getBucket(*layer_desc);
if (bucket) {
bucket->swapRenderData();