[core] add priorities to resources
- priorities can be low or regular - offline downloads should have low priority to not throttle "regular requests"
This commit is contained in:
@@ -24,6 +24,11 @@ public:
|
||||
Image
|
||||
};
|
||||
|
||||
enum class Priority : bool {
|
||||
Regular,
|
||||
Low
|
||||
};
|
||||
|
||||
struct TileData {
|
||||
std::string urlTemplate;
|
||||
uint8_t pixelRatio;
|
||||
@@ -44,34 +49,41 @@ public:
|
||||
|
||||
Resource(Kind kind_,
|
||||
std::string url_,
|
||||
Priority priority_ = Resource::Priority::Regular,
|
||||
optional<TileData> tileData_ = {},
|
||||
LoadingMethod loadingMethod_ = LoadingMethod::All)
|
||||
: kind(kind_),
|
||||
loadingMethod(loadingMethod_),
|
||||
priority(priority_),
|
||||
url(std::move(url_)),
|
||||
tileData(std::move(tileData_)) {
|
||||
}
|
||||
|
||||
void setPriority(Priority p) { priority = p; }
|
||||
|
||||
bool hasLoadingMethod(LoadingMethod method);
|
||||
|
||||
static Resource style(const std::string& url);
|
||||
static Resource source(const std::string& url);
|
||||
static Resource style(const std::string& url, const Priority priority = Resource::Priority::Regular);
|
||||
static Resource source(const std::string& url, const Priority priority = Resource::Priority::Regular);
|
||||
static Resource tile(const std::string& urlTemplate,
|
||||
float pixelRatio,
|
||||
int32_t x,
|
||||
int32_t y,
|
||||
int8_t z,
|
||||
Tileset::Scheme scheme,
|
||||
const Priority priority = Resource::Priority::Regular,
|
||||
LoadingMethod = LoadingMethod::All);
|
||||
static Resource glyphs(const std::string& urlTemplate,
|
||||
const FontStack& fontStack,
|
||||
const std::pair<uint16_t, uint16_t>& glyphRange);
|
||||
static Resource spriteImage(const std::string& base, float pixelRatio);
|
||||
static Resource spriteJSON(const std::string& base, float pixelRatio);
|
||||
static Resource image(const std::string& url);
|
||||
|
||||
const std::pair<uint16_t, uint16_t>& glyphRange,
|
||||
const Priority priority = Resource::Priority::Regular);
|
||||
static Resource spriteImage(const std::string& base, float pixelRatio, const Priority priority = Resource::Priority::Regular);
|
||||
static Resource spriteJSON(const std::string& base, float pixelRatio, const Priority priority = Resource::Priority::Regular);
|
||||
static Resource image(const std::string& url, const Priority priority = Resource::Priority::Regular);
|
||||
|
||||
Kind kind;
|
||||
LoadingMethod loadingMethod;
|
||||
Priority priority;
|
||||
std::string url;
|
||||
|
||||
// Includes auxiliary data if this is a tile request.
|
||||
|
||||
Reference in New Issue
Block a user