summaryrefslogtreecommitdiff
path: root/src/map
diff options
context:
space:
mode:
authorMike Morris <michael.patrick.morris@gmail.com>2014-07-10 16:29:49 -0700
committerMike Morris <michael.patrick.morris@gmail.com>2014-07-10 17:12:02 -0700
commit4590adc11571e3973998d7d27db52ca9d4d5b6e2 (patch)
treed2767fb2b1e4822962bd29fdb4c8ee03c70da155 /src/map
parent356c9ce7e40421bd81eb3415295caf39600d7a35 (diff)
downloadqtlocation-mapboxgl-4590adc11571e3973998d7d27db52ca9d4d5b6e2.tar.gz
break out StyleSource from Source, move getActiveSources and
updateSources into Map::Map, move getAccessToken from Style to Map Conflicts: include/llmr/style/style.hpp src/map/source.cpp src/style/style_layer.cpp src/style/style_parser.cpp
Diffstat (limited to 'src/map')
-rw-r--r--src/map/map.cpp44
-rw-r--r--src/map/source.cpp7
2 files changed, 43 insertions, 8 deletions
diff --git a/src/map/map.cpp b/src/map/map.cpp
index d65b66f784..08b14bcf38 100644
--- a/src/map/map.cpp
+++ b/src/map/map.cpp
@@ -22,7 +22,7 @@ using namespace llmr;
Map::Map(View& view)
: view(view),
transform(),
- style(std::make_shared<Style>(*this)),
+ style(std::make_shared<Style>()),
glyphAtlas(std::make_shared<GlyphAtlas>(1024, 1024)),
spriteAtlas(std::make_shared<SpriteAtlas>(512, 512)),
texturepool(std::make_shared<Texturepool>()),
@@ -413,8 +413,33 @@ void Map::setDefaultTransitionDuration(uint64_t duration_milliseconds) {
style->setDefaultTransitionDuration(duration_milliseconds);
}
+void Map::updateSources() {
+ activeSources.clear();
+ updateSources(style->layers);
+}
+
+const std::set<std::shared_ptr<Source>> Map::getActiveSources() const {
+ return activeSources;
+}
+
+void Map::updateSources(const std::shared_ptr<StyleLayerGroup> &group) {
+ if (!group) {
+ return;
+ }
+ for (const std::shared_ptr<StyleLayer> &layer : group->layers) {
+ if (!layer) continue;
+ if (layer->bucket) {
+ if (layer->bucket->style_source) {
+ activeSources.emplace(std::make_shared<Source>(*layer->bucket->style_source, this->getAccessToken()));
+ }
+ } else if (layer->layers) {
+ updateSources(layer->layers);
+ }
+ }
+}
+
void Map::updateTiles() {
- for (const std::shared_ptr<Source> &source : style->getActiveSources()) {
+ for (const std::shared_ptr<Source> &source : getActiveSources()) {
source->update(*this);
}
}
@@ -422,14 +447,14 @@ void Map::updateTiles() {
void Map::updateRenderState() {
std::forward_list<Tile::ID> ids;
- for (const std::shared_ptr<Source> &source : style->getActiveSources()) {
+ for (const std::shared_ptr<Source> &source : getActiveSources()) {
ids.splice_after(ids.before_begin(), source->getIDs());
source->updateMatrices(painter.projMatrix, state);
}
const std::map<Tile::ID, ClipID> clipIDs = computeClipIDs(ids);
- for (const std::shared_ptr<Source> &source : style->getActiveSources()) {
+ for (const std::shared_ptr<Source> &source : getActiveSources()) {
source->updateClipIDs(clipIDs);
}
}
@@ -473,6 +498,7 @@ void Map::prepare() {
}
animationTime = util::now();
+ updateSources();
style->updateProperties(state.getNormalizedZoom(), animationTime);
// Allow the sprite atlas to potentially pull new sprite images if needed.
@@ -497,7 +523,7 @@ void Map::render() {
updateRenderState();
- painter.drawClippingMasks(style->getActiveSources());
+ painter.drawClippingMasks(getActiveSources());
// Actually render the layers
if (debug::renderTree) { std::cout << "{" << std::endl; indent++; }
@@ -508,7 +534,7 @@ void Map::render() {
// This guarantees that we have at least one function per tile called.
// When only rendering layers via the stylesheet, it's possible that we don't
// ever visit a tile during rendering.
- for (const std::shared_ptr<Source> &source : style->getActiveSources()) {
+ for (const std::shared_ptr<Source> &source : getActiveSources()) {
source->finishRender(painter);
}
@@ -601,7 +627,7 @@ void Map::renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass) {
return;
}
- if (!layer_desc->bucket->source) {
+ if (!layer_desc->bucket->style_source) {
fprintf(stderr, "[WARNING] can't find source for layer '%s'\n", layer_desc->id.c_str());
return;
}
@@ -637,6 +663,8 @@ void Map::renderLayer(std::shared_ptr<StyleLayer> layer_desc, RenderPass pass) {
<< layer_desc->type << ")" << std::endl;
}
- layer_desc->bucket->source->render(painter, layer_desc);
+ // TODO: THIS IS BAD, FIXME
+ Source source(*layer_desc->bucket->style_source, this->getAccessToken());
+ source.render(painter, layer_desc);
}
}
diff --git a/src/map/source.cpp b/src/map/source.cpp
index 9736d5da5b..cf5a273b05 100644
--- a/src/map/source.cpp
+++ b/src/map/source.cpp
@@ -18,6 +18,13 @@
namespace llmr {
+Source::Source(StyleSource style_source, const std::string &access_token)
+ : type(style_source.type),
+ url(normalizeSourceURL(style_source.url, access_token)),
+ tile_size(style_source.tile_size),
+ min_zoom(style_source.min_zoom),
+ max_zoom(style_source.max_zoom) {}
+
Source::Source(SourceType type, const std::string &url,
uint32_t tile_size, uint32_t min_zoom, uint32_t max_zoom,
const std::string &access_token)