Files
MapLibreParticleLab/src/mbgl/style/sources/custom_geometry_source.cpp
Thiago Marcos P. Santos 06f1dc48a2 [core] Make the BackgroundScheduler a singleton
- Do not carry it over everywhere as parameter, it is a shared
  instance anyway and the lifecycle is pretty much the app lifecycle
  from the moment we instantiate a map.
- Rename to BackgroundScheduler because it is a Scheduler that will
  do tasks in the background, we don't make assumptions if it is a
  thread pool or a single thread.
- Most importantly, remove the dependency from `core` on `platform`.
2019-05-10 14:20:38 +03:00

45 lines
1.6 KiB
C++

#include <mbgl/style/sources/custom_geometry_source.hpp>
#include <mbgl/style/custom_tile_loader.hpp>
#include <mbgl/style/sources/custom_geometry_source_impl.hpp>
#include <mbgl/actor/actor.hpp>
#include <mbgl/actor/scheduler.hpp>
#include <mbgl/tile/tile_id.hpp>
#include <tuple>
#include <map>
namespace mbgl {
namespace style {
CustomGeometrySource::CustomGeometrySource(std::string id,
const CustomGeometrySource::Options options)
: Source(makeMutable<CustomGeometrySource::Impl>(std::move(id), options)),
loader(std::make_unique<Actor<CustomTileLoader>>(Scheduler::GetBackground(), options.fetchTileFunction, options.cancelTileFunction)) {
}
CustomGeometrySource::~CustomGeometrySource() = default;
const CustomGeometrySource::Impl& CustomGeometrySource::impl() const {
return static_cast<const CustomGeometrySource::Impl&>(*baseImpl);
}
void CustomGeometrySource::loadDescription(FileSource&) {
baseImpl = makeMutable<CustomGeometrySource::Impl>(impl(), loader->self());
loaded = true;
}
void CustomGeometrySource::setTileData(const CanonicalTileID& tileID,
const GeoJSON& data) {
loader->self().invoke(&CustomTileLoader::setTileData, tileID, data);
}
void CustomGeometrySource::invalidateTile(const CanonicalTileID& tileID) {
loader->self().invoke(&CustomTileLoader::invalidateTile, tileID);
}
void CustomGeometrySource::invalidateRegion(const LatLngBounds& bounds) {
loader->self().invoke(&CustomTileLoader::invalidateRegion, bounds, impl().getZoomRange());
}
} // namespace style
} // namespace mbgl