summaryrefslogtreecommitdiff
path: root/src/mbgl/tile/raster_tile_worker.cpp
blob: 80cc57c5d557582a7c47814d6f0aa7683e921a79 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#include <mbgl/tile/raster_tile_worker.hpp>
#include <mbgl/tile/raster_tile.hpp>
#include <mbgl/renderer/buckets/raster_bucket.hpp>
#include <mbgl/actor/actor.hpp>
#include <mbgl/util/premultiply.hpp>

namespace mbgl {

RasterTileWorker::RasterTileWorker(ActorRef<RasterTileWorker>, ActorRef<RasterTile> parent_)
    : parent(std::move(parent_)) {
}

void RasterTileWorker::parse(std::shared_ptr<const std::string> data, const uint64_t correlationID) {
    if (!data) {
        parent.invoke(&RasterTile::onParsed, nullptr, correlationID); // No data; empty tile.
        return;
    }

    try {
        auto bucket = std::make_unique<RasterBucket>(decodeImage(*data));
//        sleep(2);
        parent.invoke(&RasterTile::onParsed, std::move(bucket), correlationID);
    } catch (...) {
        parent.invoke(&RasterTile::onError, std::current_exception(), correlationID);
    }
}

} // namespace mbgl