[core] Don't share Style& across threads
This commit is contained in:
@@ -1,7 +1,6 @@
|
||||
#include <mbgl/text/collision_tile.hpp>
|
||||
#include <mbgl/map/tile_worker.hpp>
|
||||
#include <mbgl/map/geometry_tile.hpp>
|
||||
#include <mbgl/style/style.hpp>
|
||||
#include <mbgl/style/style_layer.hpp>
|
||||
#include <mbgl/style/style_bucket_parameters.hpp>
|
||||
#include <mbgl/sprite/sprite_atlas.hpp>
|
||||
@@ -15,16 +14,20 @@ using namespace mbgl;
|
||||
|
||||
TileWorker::TileWorker(TileID id_,
|
||||
std::string sourceID_,
|
||||
Style& style_,
|
||||
SpriteStore& spriteStore_,
|
||||
GlyphAtlas& glyphAtlas_,
|
||||
GlyphStore& glyphStore_,
|
||||
const std::atomic<TileData::State>& state_)
|
||||
: id(id_),
|
||||
sourceID(sourceID_),
|
||||
style(style_),
|
||||
spriteStore(spriteStore_),
|
||||
glyphAtlas(glyphAtlas_),
|
||||
glyphStore(glyphStore_),
|
||||
state(state_) {
|
||||
}
|
||||
|
||||
TileWorker::~TileWorker() {
|
||||
style.glyphAtlas->removeGlyphs(reinterpret_cast<uintptr_t>(this));
|
||||
glyphAtlas.removeGlyphs(reinterpret_cast<uintptr_t>(this));
|
||||
}
|
||||
|
||||
TileParseResult TileWorker::parseAllLayers(std::vector<util::ptr<StyleLayer>> layers,
|
||||
@@ -63,11 +66,13 @@ TileParseResult TileWorker::parsePendingLayers() {
|
||||
|
||||
if (layer.type == StyleLayerType::Symbol) {
|
||||
auto symbolBucket = dynamic_cast<SymbolBucket*>(bucket.get());
|
||||
if (!symbolBucket->needsDependencies(*style.glyphStore, *style.spriteStore)) {
|
||||
if (!symbolBucket->needsDependencies(glyphStore, spriteStore)) {
|
||||
const SymbolLayer* symbolLayer = dynamic_cast<const SymbolLayer*>(&layer);
|
||||
symbolBucket->addFeatures(reinterpret_cast<uintptr_t>(this),
|
||||
*symbolLayer->spriteAtlas,
|
||||
*style.glyphAtlas, *style.glyphStore, *collisionTile);
|
||||
glyphAtlas,
|
||||
glyphStore,
|
||||
*collisionTile);
|
||||
insertBucket(layer.bucketName(), std::move(bucket));
|
||||
pending.erase(it++);
|
||||
continue;
|
||||
@@ -130,10 +135,9 @@ void TileWorker::parseLayer(const StyleLayer& layer, const GeometryTile& geometr
|
||||
state,
|
||||
reinterpret_cast<uintptr_t>(this),
|
||||
partialParse,
|
||||
*style.spriteAtlas,
|
||||
*style.spriteStore,
|
||||
*style.glyphAtlas,
|
||||
*style.glyphStore,
|
||||
spriteStore,
|
||||
glyphAtlas,
|
||||
glyphStore,
|
||||
*collisionTile);
|
||||
|
||||
std::unique_ptr<Bucket> bucket = layer.createBucket(parameters);
|
||||
|
||||
@@ -18,7 +18,9 @@ namespace mbgl {
|
||||
|
||||
class CollisionTile;
|
||||
class GeometryTile;
|
||||
class Style;
|
||||
class SpriteStore;
|
||||
class GlyphAtlas;
|
||||
class GlyphStore;
|
||||
class Bucket;
|
||||
class StyleLayer;
|
||||
|
||||
@@ -37,7 +39,9 @@ class TileWorker : public util::noncopyable {
|
||||
public:
|
||||
TileWorker(TileID,
|
||||
std::string sourceID,
|
||||
Style&,
|
||||
SpriteStore&,
|
||||
GlyphAtlas&,
|
||||
GlyphStore&,
|
||||
const std::atomic<TileData::State>&);
|
||||
~TileWorker();
|
||||
|
||||
@@ -58,7 +62,9 @@ private:
|
||||
const TileID id;
|
||||
const std::string sourceID;
|
||||
|
||||
Style& style;
|
||||
SpriteStore& spriteStore;
|
||||
GlyphAtlas& glyphAtlas;
|
||||
GlyphStore& glyphStore;
|
||||
const std::atomic<TileData::State>& state;
|
||||
|
||||
bool partialParse = false;
|
||||
|
||||
@@ -20,7 +20,9 @@ VectorTileData::VectorTileData(const TileID& id_,
|
||||
worker(style_.workers),
|
||||
tileWorker(id_,
|
||||
sourceID,
|
||||
style_,
|
||||
*style_.spriteStore,
|
||||
*style_.glyphAtlas,
|
||||
*style_.glyphStore,
|
||||
state),
|
||||
monitor(std::move(monitor_))
|
||||
{
|
||||
|
||||
@@ -11,7 +11,6 @@ namespace mbgl {
|
||||
class TileID;
|
||||
class GeometryTileLayer;
|
||||
class GeometryTileFeature;
|
||||
class SpriteAtlas;
|
||||
class SpriteStore;
|
||||
class GlyphAtlas;
|
||||
class GlyphStore;
|
||||
@@ -24,7 +23,6 @@ public:
|
||||
const std::atomic<TileData::State>& state_,
|
||||
uintptr_t tileUID_,
|
||||
bool& partialParse_,
|
||||
SpriteAtlas& spriteAtlas_,
|
||||
SpriteStore& spriteStore_,
|
||||
GlyphAtlas& glyphAtlas_,
|
||||
GlyphStore& glyphStore_,
|
||||
@@ -34,7 +32,6 @@ public:
|
||||
state(state_),
|
||||
tileUID(tileUID_),
|
||||
partialParse(partialParse_),
|
||||
spriteAtlas(spriteAtlas_),
|
||||
spriteStore(spriteStore_),
|
||||
glyphAtlas(glyphAtlas_),
|
||||
glyphStore(glyphStore_),
|
||||
@@ -51,7 +48,6 @@ public:
|
||||
const std::atomic<TileData::State>& state;
|
||||
uintptr_t tileUID;
|
||||
bool& partialParse;
|
||||
SpriteAtlas& spriteAtlas;
|
||||
SpriteStore& spriteStore;
|
||||
GlyphAtlas& glyphAtlas;
|
||||
GlyphStore& glyphStore;
|
||||
|
||||
Reference in New Issue
Block a user