blob: 4b411aa703d2bad2131eddf062eff500fe5c47d1 (
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
|
#include <mbgl/renderer/render_source.hpp>
#include <mbgl/renderer/render_source_observer.hpp>
#include <mbgl/renderer/sources/render_geojson_source.hpp>
#include <mbgl/renderer/sources/render_raster_source.hpp>
#include <mbgl/renderer/sources/render_vector_source.hpp>
#include <mbgl/annotation/render_annotation_source.hpp>
#include <mbgl/tile/tile.hpp>
namespace mbgl {
using namespace style;
std::unique_ptr<RenderSource> RenderSource::create(Immutable<Source::Impl> impl) {
switch (impl->type) {
case SourceType::Vector:
return std::make_unique<RenderVectorSource>(staticImmutableCast<VectorSource::Impl>(impl));
case SourceType::Raster:
return std::make_unique<RenderRasterSource>(staticImmutableCast<RasterSource::Impl>(impl));
case SourceType::GeoJSON:
return std::make_unique<RenderGeoJSONSource>(staticImmutableCast<GeoJSONSource::Impl>(impl));
case SourceType::Video:
assert(false);
return nullptr;
case SourceType::Annotations:
return std::make_unique<RenderAnnotationSource>(staticImmutableCast<AnnotationSource::Impl>(impl));
}
// Not reachable, but placate GCC.
assert(false);
return nullptr;
}
static RenderSourceObserver nullObserver;
RenderSource::RenderSource(Immutable<style::Source::Impl> impl)
: baseImpl(impl),
observer(&nullObserver) {
}
void RenderSource::setObserver(RenderSourceObserver* observer_) {
observer = observer_;
}
void RenderSource::setImpl(Immutable<style::Source::Impl> impl) {
baseImpl = impl;
}
void RenderSource::onTileChanged(Tile& tile) {
observer->onTileChanged(*this, tile.id);
}
void RenderSource::onTileError(Tile& tile, std::exception_ptr error) {
observer->onTileError(*this, tile.id, error);
}
} // namespace mbgl
|