blob: 92ca74330fcd4a672dadec42e508ded1dcfdfa97 (
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
|
#pragma once
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/storage/resource.hpp>
#include <mbgl/tile/tile.hpp>
namespace mbgl {
class FileSource;
class AsyncRequest;
class Response;
class Tileset;
class TileParameters;
template <typename T>
class TileLoader : private util::noncopyable {
public:
TileLoader(T&,
const OverscaledTileID&,
const TileParameters&,
const Tileset&);
~TileLoader();
void setNecessity(TileNecessity newNecessity) {
if (newNecessity != necessity) {
necessity = newNecessity;
if (necessity == TileNecessity::Required) {
makeRequired();
} else {
makeOptional();
}
}
}
private:
// called when the tile is one of the ideal tiles that we want to show definitely. the tile source
// should try to make every effort (e.g. fetch from internet, or revalidate existing resources).
void makeRequired();
// called when the zoom level no longer corresponds to the displayed one, but
// we're still interested in retaining the tile, e.g. for backfill.
// subclassed TileSources should cancel actions they are taking to provide
// an up-to-date version or load new data
void makeOptional();
void loadFromCache();
void loadedData(const Response&);
void loadFromNetwork();
T& tile;
TileNecessity necessity;
Resource resource;
FileSource& fileSource;
std::unique_ptr<AsyncRequest> request;
};
} // namespace mbgl
|