[core] reparse tiles when new data arrives
We're now reparsing tiles when they expire. We're also swapping out buckets atomically to avoid flickering data; i.e. we're displaying the old data as long as we don't have a new parsed bucket for that layer yet. The parsed buckets now live in the *TileData objects rather than in the TileWorker; only partially parsed == pending buckets will remain in the TileWorker. Once they're parsed, they're moved to the *TileData object.
This commit is contained in:
@@ -11,13 +11,13 @@
|
||||
using namespace mbgl;
|
||||
|
||||
RasterTileData::RasterTileData(const TileID& id_,
|
||||
TexturePool &texturePool,
|
||||
TexturePool &texturePool_,
|
||||
const SourceInfo &source_,
|
||||
Worker& worker_)
|
||||
: TileData(id_),
|
||||
texturePool(texturePool_),
|
||||
source(source_),
|
||||
worker(worker_),
|
||||
bucket(texturePool, layout) {
|
||||
worker(worker_) {
|
||||
}
|
||||
|
||||
RasterTileData::~RasterTileData() {
|
||||
@@ -52,15 +52,24 @@ void RasterTileData::request(float pixelRatio,
|
||||
return;
|
||||
}
|
||||
|
||||
state = State::loaded;
|
||||
if (state == State::loading) {
|
||||
// Only overwrite the state when we didn't have a previous tile.
|
||||
state = State::loaded;
|
||||
}
|
||||
|
||||
workRequest = worker.parseRasterTile(bucket, res.data, [this, callback] (TileParseResult result) {
|
||||
workRequest = worker.parseRasterTile(std::make_unique<RasterBucket>(texturePool, layout), res.data, [this, callback] (TileParseResult result) {
|
||||
workRequest.reset();
|
||||
if (state != State::loaded) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (result.is<State>()) {
|
||||
state = result.get<State>();
|
||||
if (result.is<TileParseResultBuckets>()) {
|
||||
auto& buckets = result.get<TileParseResultBuckets>();
|
||||
state = buckets.state;
|
||||
// TODO: Make this less awkward; we're only getting one bucket back.
|
||||
if (!buckets.buckets.empty()) {
|
||||
bucket = std::move(buckets.buckets.front().second);
|
||||
}
|
||||
} else {
|
||||
std::stringstream message;
|
||||
message << "Failed to parse [" << std::string(id) << "]: " << result.get<std::string>();
|
||||
@@ -74,7 +83,7 @@ void RasterTileData::request(float pixelRatio,
|
||||
}
|
||||
|
||||
Bucket* RasterTileData::getBucket(StyleLayer const&) {
|
||||
return &bucket;
|
||||
return bucket.get();
|
||||
}
|
||||
|
||||
void RasterTileData::cancel() {
|
||||
|
||||
Reference in New Issue
Block a user