simplify - remove before/afterParse and create Parser on stack in worker thread
This commit is contained in:
@@ -53,9 +53,7 @@ public:
|
||||
}
|
||||
|
||||
// Override this in the child class.
|
||||
virtual void beforeParse();
|
||||
virtual void parse() = 0;
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) = 0;
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const = 0;
|
||||
|
||||
|
||||
@@ -28,10 +28,7 @@ class VectorTileData : public TileData {
|
||||
public:
|
||||
VectorTileData(Tile::ID id, Map &map, const util::ptr<SourceInfo> &source);
|
||||
~VectorTileData();
|
||||
|
||||
virtual void beforeParse();
|
||||
virtual void parse();
|
||||
virtual void afterParse();
|
||||
virtual void render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix);
|
||||
virtual bool hasData(StyleLayer const& layer_desc) const;
|
||||
|
||||
@@ -49,9 +46,6 @@ protected:
|
||||
// Holds the buckets of this tile.
|
||||
// They contain the location offsets in the buffers stored above
|
||||
std::unordered_map<std::string, std::unique_ptr<Bucket>> buckets;
|
||||
|
||||
std::unique_ptr<TileParser> parser;
|
||||
|
||||
public:
|
||||
const float depth;
|
||||
};
|
||||
|
||||
@@ -79,11 +79,8 @@ void TileData::cancel() {
|
||||
}
|
||||
}
|
||||
|
||||
void TileData::beforeParse() {}
|
||||
|
||||
void TileData::reparse() {
|
||||
beforeParse();
|
||||
|
||||
void TileData::reparse()
|
||||
{
|
||||
// We're creating a new work request. The work request deletes itself after it executed
|
||||
// the after work handler
|
||||
new uv::work<util::ptr<TileData>>(
|
||||
@@ -92,10 +89,7 @@ void TileData::reparse() {
|
||||
tile->parse();
|
||||
},
|
||||
[](util::ptr<TileData> &tile) {
|
||||
tile->afterParse();
|
||||
tile->map.update();
|
||||
},
|
||||
shared_from_this());
|
||||
}
|
||||
|
||||
void TileData::afterParse() {}
|
||||
|
||||
@@ -17,10 +17,6 @@ VectorTileData::~VectorTileData() {
|
||||
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());
|
||||
}
|
||||
|
||||
void VectorTileData::parse() {
|
||||
if (state != State::loaded) {
|
||||
@@ -31,7 +27,9 @@ void VectorTileData::parse() {
|
||||
// Parsing creates state that is encapsulated in TileParser. While parsing,
|
||||
// the TileParser object writes results into this objects. All other state
|
||||
// is going to be discarded afterwards.
|
||||
parser->parse();
|
||||
TileParser parser(data, *this, map.getStyle(), map.getGlyphAtlas(),
|
||||
map.getGlyphStore(), map.getSpriteAtlas(), map.getSprite());
|
||||
parser.parse();
|
||||
} catch (const std::exception& ex) {
|
||||
#if defined(DEBUG)
|
||||
fprintf(stderr, "[%p] exception [%d/%d/%d]... failed: %s\n", this, id.z, id.x, id.y, ex.what());
|
||||
@@ -45,10 +43,6 @@ void VectorTileData::parse() {
|
||||
}
|
||||
}
|
||||
|
||||
void VectorTileData::afterParse() {
|
||||
parser.reset();
|
||||
}
|
||||
|
||||
void VectorTileData::render(Painter &painter, util::ptr<StyleLayer> layer_desc, const mat4 &matrix) {
|
||||
if (state == State::parsed && layer_desc->bucket) {
|
||||
auto databucket_it = buckets.find(layer_desc->bucket->name);
|
||||
|
||||
Reference in New Issue
Block a user