store glyphAtlas by value in Map object, pass by ref
change hasData signiture to expect ```StyleLayer const&```
This commit is contained in:
@@ -3,12 +3,11 @@
|
||||
|
||||
#include <mbgl/map/transform.hpp>
|
||||
#include <mbgl/renderer/painter.hpp>
|
||||
|
||||
#include <mbgl/geometry/glyph_atlas.hpp>
|
||||
#include <mbgl/util/noncopyable.hpp>
|
||||
#include <mbgl/util/time.hpp>
|
||||
#include <mbgl/util/uv.hpp>
|
||||
#include <mbgl/util/ptr.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <atomic>
|
||||
#include <iosfwd>
|
||||
@@ -17,7 +16,6 @@
|
||||
|
||||
namespace mbgl {
|
||||
|
||||
class GlyphAtlas;
|
||||
class GlyphStore;
|
||||
class LayerDescription;
|
||||
class SpriteAtlas;
|
||||
@@ -131,7 +129,7 @@ public:
|
||||
inline const TransformState &getState() const { return state; }
|
||||
inline util::ptr<FileSource> getFileSource() const { return fileSource; }
|
||||
inline util::ptr<Style> getStyle() const { return style; }
|
||||
inline util::ptr<GlyphAtlas> getGlyphAtlas() { return glyphAtlas; }
|
||||
inline GlyphAtlas & getGlyphAtlas() { return glyphAtlas; }
|
||||
inline util::ptr<GlyphStore> getGlyphStore() { return glyphStore; }
|
||||
inline util::ptr<SpriteAtlas> getSpriteAtlas() { return spriteAtlas; }
|
||||
util::ptr<Sprite> getSprite();
|
||||
@@ -203,7 +201,7 @@ private:
|
||||
util::ptr<FileSource> fileSource;
|
||||
|
||||
util::ptr<Style> style;
|
||||
util::ptr<GlyphAtlas> glyphAtlas;
|
||||
GlyphAtlas glyphAtlas;
|
||||
util::ptr<GlyphStore> glyphStore;
|
||||
util::ptr<SpriteAtlas> spriteAtlas;
|
||||
util::ptr<Sprite> sprite;
|
||||
|
||||
@@ -21,7 +21,7 @@ public:
|
||||
|
||||
virtual void parse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
virtual bool hasData(util::ptr<StyleLayer> layer_desc) const;
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const;
|
||||
|
||||
protected:
|
||||
StyleBucketRaster properties;
|
||||
|
||||
@@ -57,7 +57,7 @@ public:
|
||||
virtual void parse() = 0;
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0;
|
||||
virtual bool hasData(util::ptr<StyleLayer> layer_desc) const = 0;
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const = 0;
|
||||
|
||||
|
||||
public:
|
||||
|
||||
@@ -33,7 +33,7 @@ class TileParser {
|
||||
public:
|
||||
TileParser(const std::string &data, VectorTileData &tile,
|
||||
const util::ptr<const Style> &style,
|
||||
const util::ptr<GlyphAtlas> &glyphAtlas,
|
||||
GlyphAtlas & glyphAtlas,
|
||||
const util::ptr<GlyphStore> &glyphStore,
|
||||
const util::ptr<SpriteAtlas> &spriteAtlas,
|
||||
const util::ptr<Sprite> &sprite);
|
||||
@@ -60,7 +60,7 @@ private:
|
||||
|
||||
// Cross-thread shared data.
|
||||
util::ptr<const Style> style;
|
||||
util::ptr<GlyphAtlas> glyphAtlas;
|
||||
GlyphAtlas & glyphAtlas;
|
||||
util::ptr<GlyphStore> glyphStore;
|
||||
util::ptr<SpriteAtlas> spriteAtlas;
|
||||
util::ptr<Sprite> sprite;
|
||||
|
||||
@@ -33,7 +33,7 @@ public:
|
||||
virtual void parse();
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
virtual bool hasData(util::ptr<StyleLayer> layer_desc) const;
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const;
|
||||
|
||||
protected:
|
||||
// Holds the actual geometries in this tile.
|
||||
|
||||
@@ -41,10 +41,10 @@ Map::Map(View& view_)
|
||||
main_thread(uv_thread_self()),
|
||||
#endif
|
||||
transform(view_),
|
||||
glyphAtlas(std::make_shared<GlyphAtlas>(1024, 1024)),
|
||||
glyphAtlas(1024, 1024),
|
||||
spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)),
|
||||
texturepool(std::make_shared<Texturepool>()),
|
||||
painter(*spriteAtlas, *glyphAtlas) {
|
||||
painter(*spriteAtlas, glyphAtlas) {
|
||||
|
||||
view.initialize(this);
|
||||
|
||||
@@ -64,7 +64,6 @@ Map::~Map() {
|
||||
sprite.reset();
|
||||
spriteAtlas.reset();
|
||||
glyphStore.reset();
|
||||
glyphAtlas.reset();
|
||||
style.reset();
|
||||
fileSource.reset();
|
||||
workers.reset();
|
||||
|
||||
@@ -29,6 +29,6 @@ void RasterTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc,
|
||||
bucket.render(painter, layer_desc, id, matrix);
|
||||
}
|
||||
|
||||
bool RasterTileData::hasData(util::ptr<StyleLayer> /*layer_desc*/) const {
|
||||
bool RasterTileData::hasData(StyleLayer const& /*layer_desc*/) const {
|
||||
return bucket.hasData();
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ TileParser::~TileParser() = default;
|
||||
|
||||
TileParser::TileParser(const std::string &data, VectorTileData &tile_,
|
||||
const util::ptr<const Style> &style_,
|
||||
const util::ptr<GlyphAtlas> &glyphAtlas_,
|
||||
GlyphAtlas& glyphAtlas_,
|
||||
const util::ptr<GlyphStore> &glyphStore_,
|
||||
const util::ptr<SpriteAtlas> &spriteAtlas_,
|
||||
const util::ptr<Sprite> &sprite_)
|
||||
@@ -53,7 +53,7 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_,
|
||||
collision(std::make_unique<Collision>(tile.id.z, 4096, tile.source->tile_size, tile.depth)) {
|
||||
assert(&tile != nullptr);
|
||||
assert(style);
|
||||
assert(glyphAtlas);
|
||||
//assert(glyphAtlas);
|
||||
assert(glyphStore);
|
||||
assert(spriteAtlas);
|
||||
assert(sprite);
|
||||
@@ -177,7 +177,7 @@ std::unique_ptr<Bucket> TileParser::createLineBucket(const VectorTileLayer& laye
|
||||
|
||||
std::unique_ptr<Bucket> TileParser::createSymbolBucket(const VectorTileLayer& layer, const FilterExpression &filter, const StyleBucketSymbol &symbol) {
|
||||
std::unique_ptr<SymbolBucket> bucket = std::make_unique<SymbolBucket>(symbol, *collision);
|
||||
bucket->addFeatures(layer, filter, tile.id, *spriteAtlas, *sprite, *glyphAtlas, *glyphStore);
|
||||
bucket->addFeatures(layer, filter, tile.id, *spriteAtlas, *sprite, glyphAtlas, *glyphStore);
|
||||
return obsolete() ? nullptr : std::move(bucket);
|
||||
}
|
||||
|
||||
|
||||
@@ -14,15 +14,12 @@ VectorTileData::VectorTileData(Tile::ID id_, Map &map_, const util::ptr<SourceIn
|
||||
}
|
||||
|
||||
VectorTileData::~VectorTileData() {
|
||||
util::ptr<GlyphAtlas> glyphAtlas = map.getGlyphAtlas();
|
||||
if (glyphAtlas) {
|
||||
glyphAtlas->removeGlyphs(id.to_uint64());
|
||||
}
|
||||
map.getGlyphAtlas().removeGlyphs(id.to_uint64());
|
||||
}
|
||||
|
||||
void VectorTileData::beforeParse() {
|
||||
|
||||
parser = std::make_unique<TileParser>(data, *this, map.getStyle(), map.getGlyphAtlas(), map.getGlyphStore(), map.getSpriteAtlas(), map.getSprite());
|
||||
parser = std::make_unique<TileParser>(data, *this, map.getStyle(), map.getGlyphAtlas(),
|
||||
map.getGlyphStore(), map.getSpriteAtlas(), map.getSprite());
|
||||
}
|
||||
|
||||
void VectorTileData::parse() {
|
||||
@@ -62,9 +59,9 @@ void VectorTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc,
|
||||
}
|
||||
}
|
||||
|
||||
bool VectorTileData::hasData(util::ptr<StyleLayer> layer_desc) const {
|
||||
if (state == State::parsed && layer_desc->bucket) {
|
||||
auto databucket_it = buckets.find(layer_desc->bucket->name);
|
||||
bool VectorTileData::hasData(StyleLayer const& layer_desc) const {
|
||||
if (state == State::parsed && layer_desc.bucket) {
|
||||
auto databucket_it = buckets.find(layer_desc.bucket->name);
|
||||
if (databucket_it != buckets.end()) {
|
||||
assert(databucket_it->second);
|
||||
return databucket_it->second->hasData();
|
||||
|
||||
@@ -356,7 +356,7 @@ void Painter::renderLayer(util::ptr<StyleLayer> layer_desc, const Tile::ID* id,
|
||||
|
||||
void Painter::renderTileLayer(const Tile& tile, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) {
|
||||
assert(tile.data);
|
||||
if (tile.data->hasData(layer_desc) || layer_desc->type == StyleLayerType::Raster) {
|
||||
if (tile.data->hasData(*layer_desc) || layer_desc->type == StyleLayerType::Raster) {
|
||||
gl::group group(util::sprintf<32>("render %d/%d/%d\n", tile.id.z, tile.id.y, tile.id.z));
|
||||
prepareTile(tile);
|
||||
tile.data->render(*this, layer_desc, matrix);
|
||||
|
||||
@@ -100,7 +100,7 @@ std::vector<SymbolFeature> SymbolBucket::processFeatures(const VectorTileLayer &
|
||||
|
||||
void SymbolBucket::addFeatures(const VectorTileLayer &layer, const FilterExpression &filter,
|
||||
const Tile::ID &id, SpriteAtlas &spriteAtlas, Sprite &sprite,
|
||||
GlyphAtlas &glyphAtlas, GlyphStore &glyphStore) {
|
||||
GlyphAtlas & glyphAtlas, GlyphStore &glyphStore) {
|
||||
|
||||
const std::vector<SymbolFeature> features = processFeatures(layer, filter, glyphStore, sprite);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user