summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-05-30 13:40:36 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-06-05 19:38:08 -0700
commit591af0021bfb8b9fdfd803b55fb6c18a24c46943 (patch)
treeb0952184aca90ddda6ce170c4e2cc287824fbf54 /src/mbgl/annotation
parent32589c271c6f4885dadb6291c4bf637b72659a9f (diff)
downloadqtlocation-mapboxgl-591af0021bfb8b9fdfd803b55fb6c18a24c46943.tar.gz
[core] Refactor RenderSource updates
* Eliminate updateBatch in favor of diffing layers and detecting changes to properties upon which layout depends. * Replace RenderSource::{update,remove,invalidate,reload}Tiles with a single update method * Replace TilePyramid::{update,remove,invalidate,reload}Tiles with a single update method * Remove Style& dependency TODO from GeometryTile and TileParameters
Diffstat (limited to 'src/mbgl/annotation')
-rw-r--r--src/mbgl/annotation/annotation_tile.cpp5
-rw-r--r--src/mbgl/annotation/render_annotation_source.cpp39
-rw-r--r--src/mbgl/annotation/render_annotation_source.hpp18
3 files changed, 25 insertions, 37 deletions
diff --git a/src/mbgl/annotation/annotation_tile.cpp b/src/mbgl/annotation/annotation_tile.cpp
index 1b34026f74..67a2d128ba 100644
--- a/src/mbgl/annotation/annotation_tile.cpp
+++ b/src/mbgl/annotation/annotation_tile.cpp
@@ -3,7 +3,6 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/storage/file_source.hpp>
#include <mbgl/renderer/tile_parameters.hpp>
-#include <mbgl/style/style.hpp>
#include <utility>
@@ -11,9 +10,7 @@ namespace mbgl {
AnnotationTile::AnnotationTile(const OverscaledTileID& overscaledTileID,
const TileParameters& parameters)
- : GeometryTile(overscaledTileID, AnnotationManager::SourceID, parameters,
- *parameters.style.glyphAtlas,
- *parameters.style.spriteAtlas),
+ : GeometryTile(overscaledTileID, AnnotationManager::SourceID, parameters),
annotationManager(parameters.annotationManager) {
annotationManager.addTile(*this);
}
diff --git a/src/mbgl/annotation/render_annotation_source.cpp b/src/mbgl/annotation/render_annotation_source.cpp
index dfb78fb8b1..dce2914e7f 100644
--- a/src/mbgl/annotation/render_annotation_source.cpp
+++ b/src/mbgl/annotation/render_annotation_source.cpp
@@ -22,8 +22,25 @@ bool RenderAnnotationSource::isLoaded() const {
return tilePyramid.isLoaded();
}
-void RenderAnnotationSource::invalidateTiles() {
- tilePyramid.invalidateTiles();
+void RenderAnnotationSource::update(Immutable<style::Source::Impl> baseImpl_,
+ const std::vector<Immutable<Layer::Impl>>& layers,
+ const bool needsRendering,
+ const bool needsRelayout,
+ const TileParameters& parameters) {
+ std::swap(baseImpl, baseImpl_);
+
+ enabled = needsRendering;
+
+ tilePyramid.update(layers,
+ needsRendering,
+ needsRelayout,
+ parameters,
+ SourceType::Annotations,
+ util::tileSize,
+ { 0, 22 },
+ [&] (const OverscaledTileID& tileID) {
+ return std::make_unique<AnnotationTile>(tileID, parameters);
+ });
}
void RenderAnnotationSource::startRender(algorithm::ClipIDGenerator& generator, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
@@ -39,24 +56,6 @@ std::map<UnwrappedTileID, RenderTile>& RenderAnnotationSource::getRenderTiles()
return tilePyramid.getRenderTiles();
}
-void RenderAnnotationSource::updateTiles(const TileParameters& parameters) {
- tilePyramid.updateTiles(parameters,
- SourceType::Annotations,
- util::tileSize,
- { 0, 22 },
- [&] (const OverscaledTileID& tileID) {
- return std::make_unique<AnnotationTile>(tileID, parameters);
- });
-}
-
-void RenderAnnotationSource::removeTiles() {
- tilePyramid.removeTiles();
-}
-
-void RenderAnnotationSource::reloadTiles() {
- tilePyramid.reloadTiles();
-}
-
std::unordered_map<std::string, std::vector<Feature>>
RenderAnnotationSource::queryRenderedFeatures(const ScreenLineString& geometry,
const TransformState& transformState,
diff --git a/src/mbgl/annotation/render_annotation_source.hpp b/src/mbgl/annotation/render_annotation_source.hpp
index c93cfbd7d7..ed30e62381 100644
--- a/src/mbgl/annotation/render_annotation_source.hpp
+++ b/src/mbgl/annotation/render_annotation_source.hpp
@@ -12,19 +12,11 @@ public:
bool isLoaded() const final;
- // Called when the camera has changed. May load new tiles, unload obsolete tiles, or
- // trigger re-placement of existing complete tiles.
- void updateTiles(const TileParameters&) final;
-
- // Removes all tiles (by putting them into the cache).
- void removeTiles() final;
-
- // Remove all tiles and clear the cache.
- void invalidateTiles() final;
-
- // Request that all loaded tiles re-run the layout operation on the existing source
- // data with fresh style information.
- void reloadTiles() final;
+ void update(Immutable<style::Source::Impl>,
+ const std::vector<Immutable<style::Layer::Impl>>&,
+ bool needsRendering,
+ bool needsRelayout,
+ const TileParameters&) final;
void startRender(algorithm::ClipIDGenerator&,
const mat4& projMatrix,