summaryrefslogtreecommitdiff
path: root/src/mbgl/renderer/sources/render_raster_source.cpp
blob: e2d641c4e4c26557165c109b779a34688adb77d7 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <mbgl/renderer/sources/render_raster_source.hpp>
#include <mbgl/renderer/render_tile.hpp>
#include <mbgl/tile/raster_tile.hpp>

namespace mbgl {

using namespace style;

RenderRasterSource::RenderRasterSource(Immutable<style::RasterSource::Impl> impl_)
    : RenderSource(impl_) {
    tilePyramid.setObserver(this);
}

const style::RasterSource::Impl& RenderRasterSource::impl() const {
    return static_cast<const style::RasterSource::Impl&>(*baseImpl);
}

bool RenderRasterSource::isLoaded() const {
    return tilePyramid.isLoaded();
}

void RenderRasterSource::invalidateTiles() {
    tilePyramid.invalidateTiles();
}

void RenderRasterSource::startRender(algorithm::ClipIDGenerator&, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
    tilePyramid.startRender(projMatrix, clipMatrix, transform);
}

void RenderRasterSource::finishRender(Painter& painter) {
    tilePyramid.finishRender(painter);
}

std::map<UnwrappedTileID, RenderTile>& RenderRasterSource::getRenderTiles() {
    return tilePyramid.getRenderTiles();
}

void RenderRasterSource::updateTiles(const TileParameters& parameters) {
    optional<Tileset> tileset = impl().getTileset();

    if (!tileset) {
        return;
    }

    if (tileURLTemplates != tileset->tiles) {
        tileURLTemplates = tileset->tiles;
        tilePyramid.invalidateTiles();
    }

    tilePyramid.updateTiles(parameters,
                            SourceType::Raster,
                            impl().getTileSize(),
                            tileset->zoomRange,
                            [&] (const OverscaledTileID& tileID) {
                                return std::make_unique<RasterTile>(tileID, parameters, *tileset);
                            });
}

void RenderRasterSource::removeTiles() {
    tilePyramid.removeTiles();
}

void RenderRasterSource::reloadTiles() {
    tilePyramid.reloadTiles();
}

std::unordered_map<std::string, std::vector<Feature>>
RenderRasterSource::queryRenderedFeatures(const ScreenLineString&,
                                          const TransformState&,
                                          const RenderedQueryOptions&) const {
    return {};
}

std::vector<Feature> RenderRasterSource::querySourceFeatures(const SourceQueryOptions&) const {
    return {};
}

void RenderRasterSource::setCacheSize(size_t size) {
    tilePyramid.setCacheSize(size);
}

void RenderRasterSource::onLowMemory() {
    tilePyramid.onLowMemory();
}

void RenderRasterSource::dumpDebugLogs() const {
    tilePyramid.dumpDebugLogs();
}

} // namespace mbgl