summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2014-11-25 17:50:19 -0800
committerJohn Firebaugh <john.firebaugh@gmail.com>2014-11-26 15:13:14 -0800
commit41e90b4150ba8302c0c6f9bec0f53059483fea9e (patch)
tree1febc0cc25c4663ccc49debff79757a751271c4a /src
parent23b61f808cca8d926c11bbb738f384522e41dbbd (diff)
downloadqtlocation-mapboxgl-41e90b4150ba8302c0c6f9bec0f53059483fea9e.tar.gz
Pass SourceInfo as reference
Diffstat (limited to 'src')
-rw-r--r--src/map/map.cpp2
-rw-r--r--src/map/raster_tile_data.cpp2
-rw-r--r--src/map/source.cpp22
-rw-r--r--src/map/tile_data.cpp6
-rw-r--r--src/map/tile_parser.cpp4
-rw-r--r--src/map/vector_tile_data.cpp4
6 files changed, 20 insertions, 20 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp
index eb0a48d8d6..2df3e068fb 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -606,7 +606,7 @@ void Map::updateSources() {
for (const util::ptr<StyleSource> &style_source : activeSources) {
if (style_source->enabled) {
if (!style_source->source) {
- style_source->source = std::make_shared<Source>(style_source->info);
+ style_source->source = std::make_shared<Source>(*style_source->info);
style_source->source->load(*this, *fileSource);
}
} else {
diff --git a/src/map/raster_tile_data.cpp b/src/map/raster_tile_data.cpp
index b2d0cf6a6b..8b29fedcd8 100644
--- a/src/map/raster_tile_data.cpp
+++ b/src/map/raster_tile_data.cpp
@@ -5,7 +5,7 @@
using namespace mbgl;
-RasterTileData::RasterTileData(Tile::ID const& id_, Texturepool& texturepool, const util::ptr<SourceInfo> &source_)
+RasterTileData::RasterTileData(Tile::ID const& id_, Texturepool& texturepool, const SourceInfo& source_)
: TileData(id_, source_),
bucket(texturepool, properties) {
}
diff --git a/src/map/source.cpp b/src/map/source.cpp
index d617d2cdee..5b32cbafb4 100644
--- a/src/map/source.cpp
+++ b/src/map/source.cpp
@@ -22,7 +22,7 @@
namespace mbgl {
-Source::Source(const util::ptr<SourceInfo>& info_)
+Source::Source(SourceInfo& info_)
: info(info_)
{
}
@@ -31,12 +31,12 @@ Source::Source(const util::ptr<SourceInfo>& info_)
// The reason this isn't part of the constructor is that calling shared_from_this() in
// the constructor fails.
void Source::load(Map& map, FileSource& fileSource) {
- if (info->url.empty()) {
+ if (info.url.empty()) {
loaded = true;
return;
}
- std::string url = util::mapbox::normalizeSourceURL(info->url, map.getAccessToken());
+ std::string url = util::mapbox::normalizeSourceURL(info.url, map.getAccessToken());
util::ptr<Source> source = shared_from_this();
fileSource.request(ResourceType::JSON, url)->onload([source, &map](const Response &res) {
@@ -53,7 +53,7 @@ void Source::load(Map& map, FileSource& fileSource) {
return;
}
- source->info->parseTileJSONProperties(d);
+ source->info.parseTileJSONProperties(d);
source->loaded = true;
map.update();
@@ -201,12 +201,12 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
if (!new_tile.data) {
// If we don't find working tile data, we're just going to load it.
- if (info->type == SourceType::Vector) {
+ if (info.type == SourceType::Vector) {
new_tile.data = std::make_shared<VectorTileData>(normalized_id, map.getMaxZoom(), style,
glyphAtlas, glyphStore,
spriteAtlas, sprite,
texturepool, info);
- } else if (info->type == SourceType::Raster) {
+ } else if (info.type == SourceType::Raster) {
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturepool, info);
} else {
throw std::runtime_error("source type not implemented");
@@ -220,7 +220,7 @@ TileData::State Source::addTile(Map& map, uv::worker& worker,
}
double Source::getZoom(const TransformState& state) const {
- double offset = std::log(util::tileSize / info->tile_size) / std::log(2);
+ double offset = std::log(util::tileSize / info.tile_size) / std::log(2);
offset += (state.getPixelRatio() > 1.0 ? 1 :0);
return state.getZoom() + offset;
}
@@ -232,8 +232,8 @@ int32_t Source::coveringZoomLevel(const TransformState& state) const {
std::forward_list<Tile::ID> Source::coveringTiles(const TransformState& state) const {
int32_t z = coveringZoomLevel(state);
- if (z < info->min_zoom) return {{}};
- if (z > info->max_zoom) z = info->max_zoom;
+ if (z < info.min_zoom) return {{}};
+ if (z > info.max_zoom) z = info.max_zoom;
// Map four viewport corners to pixel coordinates
box points = state.cornersToBox(z);
@@ -310,8 +310,8 @@ bool Source::updateTiles(Map& map, uv::worker& worker, util::ptr<Style> style,
std::forward_list<Tile::ID> required = coveringTiles(map.getState());
// Determine the overzooming/underzooming amounts.
- int32_t minCoveringZoom = util::clamp<int32_t>(zoom - 10, info->min_zoom, info->max_zoom);
- int32_t maxCoveringZoom = util::clamp<int32_t>(zoom + 1, info->min_zoom, info->max_zoom);
+ int32_t minCoveringZoom = util::clamp<int32_t>(zoom - 10, info.min_zoom, info.max_zoom);
+ int32_t maxCoveringZoom = util::clamp<int32_t>(zoom + 1, info.min_zoom, info.max_zoom);
// Retain is a list of tiles that we shouldn't delete, even if they are not
// the most ideal tile for the current viewport. This may include tiles like
diff --git a/src/map/tile_data.cpp b/src/map/tile_data.cpp
index 1cbcf00825..c1354d490b 100644
--- a/src/map/tile_data.cpp
+++ b/src/map/tile_data.cpp
@@ -9,7 +9,7 @@
using namespace mbgl;
-TileData::TileData(Tile::ID const& id_, const util::ptr<SourceInfo> &source_)
+TileData::TileData(Tile::ID const& id_, const SourceInfo& source_)
: id(id_),
state(State::initial),
source(source_),
@@ -29,10 +29,10 @@ const std::string TileData::toString() const {
void TileData::request(uv::worker& worker, FileSource& fileSource,
float pixelRatio, std::function<void ()> callback) {
- if (source->tiles.empty())
+ if (source.tiles.empty())
return;
- std::string url = source->tiles[(id.x + id.y) % source->tiles.size()];
+ std::string url = source.tiles[(id.x + id.y) % source.tiles.size()];
url = util::replaceTokens(url, [&](const std::string &token) -> std::string {
if (token == "z") return std::to_string(id.z);
if (token == "x") return std::to_string(id.x);
diff --git a/src/map/tile_parser.cpp b/src/map/tile_parser.cpp
index dcbac71c7c..4e9c320e36 100644
--- a/src/map/tile_parser.cpp
+++ b/src/map/tile_parser.cpp
@@ -44,7 +44,7 @@ TileParser::TileParser(const std::string &data, VectorTileData &tile_,
spriteAtlas(spriteAtlas_),
sprite(sprite_),
texturePool(texturePool_),
- collision(std::make_unique<Collision>(tile.id.z, 4096, tile.source->tile_size, tile.depth)) {
+ collision(std::make_unique<Collision>(tile.id.z, 4096, tile.source.tile_size, tile.depth)) {
assert(&tile != nullptr);
assert(style);
assert(sprite);
@@ -101,7 +101,7 @@ std::unique_ptr<Bucket> TileParser::createBucket(util::ptr<StyleBucket> bucket_d
}
// Skip this bucket if we are to not render this
- if (tile.id.z < std::floor(bucket_desc->min_zoom) && std::floor(bucket_desc->min_zoom) < tile.source->max_zoom) return nullptr;
+ if (tile.id.z < std::floor(bucket_desc->min_zoom) && std::floor(bucket_desc->min_zoom) < tile.source.max_zoom) return nullptr;
if (tile.id.z >= std::ceil(bucket_desc->max_zoom)) return nullptr;
auto layer_it = vector_data.layers.find(bucket_desc->source_layer);
diff --git a/src/map/vector_tile_data.cpp b/src/map/vector_tile_data.cpp
index 8193f7e8a5..1237e3546b 100644
--- a/src/map/vector_tile_data.cpp
+++ b/src/map/vector_tile_data.cpp
@@ -13,7 +13,7 @@ VectorTileData::VectorTileData(Tile::ID const& id_,
GlyphAtlas& glyphAtlas_, GlyphStore& glyphStore_,
SpriteAtlas& spriteAtlas_, util::ptr<Sprite> sprite_,
Texturepool& texturepool_,
- const util::ptr<SourceInfo> &source_)
+ const SourceInfo& source_)
: TileData(id_, source_),
glyphAtlas(glyphAtlas_),
glyphStore(glyphStore_),
@@ -21,7 +21,7 @@ VectorTileData::VectorTileData(Tile::ID const& id_,
sprite(sprite_),
texturepool(texturepool_),
style(style_),
- depth(id.z >= source->max_zoom ? mapMaxZoom - id.z : 1) {
+ depth(id.z >= source.max_zoom ? mapMaxZoom - id.z : 1) {
}
VectorTileData::~VectorTileData() {