summaryrefslogtreecommitdiff
path: root/src/mbgl/annotation
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2017-04-20 17:11:50 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2017-05-02 08:45:09 -0700
commit3f0c89d633a5056006557ad5f4b9e446807d00ee (patch)
tree5405c50dd26a5a393a982e8e0f76b764dbbccf48 /src/mbgl/annotation
parent197751bace6181f2c2dbe4c890f277a0dc7e58b1 (diff)
downloadqtlocation-mapboxgl-3f0c89d633a5056006557ad5f4b9e446807d00ee.tar.gz
[core] Refactor Source::*Impls into RenderSources and TilePyramid
Diffstat (limited to 'src/mbgl/annotation')
-rw-r--r--src/mbgl/annotation/annotation_source.cpp11
-rw-r--r--src/mbgl/annotation/annotation_source.hpp8
-rw-r--r--src/mbgl/annotation/render_annotation_source.cpp79
-rw-r--r--src/mbgl/annotation/render_annotation_source.hpp53
4 files changed, 136 insertions, 15 deletions
diff --git a/src/mbgl/annotation/annotation_source.cpp b/src/mbgl/annotation/annotation_source.cpp
index c52836c500..9956140179 100644
--- a/src/mbgl/annotation/annotation_source.cpp
+++ b/src/mbgl/annotation/annotation_source.cpp
@@ -1,6 +1,6 @@
#include <mbgl/annotation/annotation_source.hpp>
#include <mbgl/annotation/annotation_manager.hpp>
-#include <mbgl/annotation/annotation_tile.hpp>
+#include <mbgl/annotation/render_annotation_source.hpp>
namespace mbgl {
@@ -14,17 +14,12 @@ AnnotationSource::Impl::Impl(Source& base_)
: Source::Impl(SourceType::Annotations, AnnotationManager::SourceID, base_) {
}
-optional<Range<uint8_t>> AnnotationSource::Impl::getZoomRange() const {
- return { { 0, 22 } };
-}
-
void AnnotationSource::Impl::loadDescription(FileSource&) {
loaded = true;
}
-std::unique_ptr<Tile> AnnotationSource::Impl::createTile(const OverscaledTileID& tileID,
- const style::UpdateParameters& parameters) {
- return std::make_unique<AnnotationTile>(tileID, parameters);
+std::unique_ptr<RenderSource> AnnotationSource::Impl::createRenderSource() const {
+ return std::make_unique<RenderAnnotationSource>(*this);
}
} // namespace mbgl
diff --git a/src/mbgl/annotation/annotation_source.hpp b/src/mbgl/annotation/annotation_source.hpp
index 07e00dc52d..46c9564443 100644
--- a/src/mbgl/annotation/annotation_source.hpp
+++ b/src/mbgl/annotation/annotation_source.hpp
@@ -17,13 +17,7 @@ public:
Impl(Source&);
void loadDescription(FileSource&) final;
-
- optional<Range<uint8_t>> getZoomRange() const final;
-
-private:
- uint16_t getTileSize() const final { return util::tileSize; }
-
- std::unique_ptr<Tile> createTile(const OverscaledTileID&, const style::UpdateParameters&) final;
+ std::unique_ptr<RenderSource> createRenderSource() const final;
};
} // namespace mbgl
diff --git a/src/mbgl/annotation/render_annotation_source.cpp b/src/mbgl/annotation/render_annotation_source.cpp
new file mode 100644
index 0000000000..f926b6ce9a
--- /dev/null
+++ b/src/mbgl/annotation/render_annotation_source.cpp
@@ -0,0 +1,79 @@
+#include <mbgl/annotation/render_annotation_source.hpp>
+#include <mbgl/annotation/annotation_tile.hpp>
+#include <mbgl/renderer/render_tile.hpp>
+
+#include <mbgl/algorithm/generate_clip_ids.hpp>
+#include <mbgl/algorithm/generate_clip_ids_impl.hpp>
+
+namespace mbgl {
+
+using namespace style;
+
+RenderAnnotationSource::RenderAnnotationSource(const AnnotationSource::Impl& impl_)
+ : RenderSource(impl_) {
+ tilePyramid.setObserver(this);
+}
+
+bool RenderAnnotationSource::isLoaded() const {
+ return tilePyramid.isLoaded();
+}
+
+void RenderAnnotationSource::invalidateTiles() {
+ tilePyramid.invalidateTiles();
+}
+
+void RenderAnnotationSource::startRender(algorithm::ClipIDGenerator& generator, const mat4& projMatrix, const mat4& clipMatrix, const TransformState& transform) {
+ generator.update(tilePyramid.getRenderTiles());
+ tilePyramid.startRender(projMatrix, clipMatrix, transform);
+}
+
+void RenderAnnotationSource::finishRender(Painter& painter) {
+ tilePyramid.finishRender(painter);
+}
+
+std::map<UnwrappedTileID, RenderTile>& RenderAnnotationSource::getRenderTiles() {
+ return tilePyramid.getRenderTiles();
+}
+
+void RenderAnnotationSource::updateTiles(const UpdateParameters& 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,
+ const RenderedQueryOptions& options) const {
+ return tilePyramid.queryRenderedFeatures(geometry, transformState, options);
+}
+
+std::vector<Feature> RenderAnnotationSource::querySourceFeatures(const SourceQueryOptions&) const {
+ return {};
+}
+
+void RenderAnnotationSource::setCacheSize(size_t size) {
+ tilePyramid.setCacheSize(size);
+}
+
+void RenderAnnotationSource::onLowMemory() {
+ tilePyramid.onLowMemory();
+}
+
+void RenderAnnotationSource::dumpDebugLogs() const {
+ tilePyramid.dumpDebugLogs();
+}
+
+} // namespace mbgl
diff --git a/src/mbgl/annotation/render_annotation_source.hpp b/src/mbgl/annotation/render_annotation_source.hpp
new file mode 100644
index 0000000000..394acc5108
--- /dev/null
+++ b/src/mbgl/annotation/render_annotation_source.hpp
@@ -0,0 +1,53 @@
+#pragma once
+
+#include <mbgl/renderer/render_source.hpp>
+#include <mbgl/renderer/tile_pyramid.hpp>
+#include <mbgl/annotation/annotation_source.hpp>
+
+namespace mbgl {
+
+class RenderAnnotationSource : public RenderSource {
+public:
+ RenderAnnotationSource(const AnnotationSource::Impl&);
+
+ 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 style::UpdateParameters&) 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 startRender(algorithm::ClipIDGenerator&,
+ const mat4& projMatrix,
+ const mat4& clipMatrix,
+ const TransformState&) final;
+ void finishRender(Painter&) final;
+
+ std::map<UnwrappedTileID, RenderTile>& getRenderTiles() final;
+
+ std::unordered_map<std::string, std::vector<Feature>>
+ queryRenderedFeatures(const ScreenLineString& geometry,
+ const TransformState& transformState,
+ const RenderedQueryOptions& options) const final;
+
+ std::vector<Feature>
+ querySourceFeatures(const SourceQueryOptions&) const final;
+
+ void setCacheSize(size_t) final;
+ void onLowMemory() final;
+ void dumpDebugLogs() const final;
+
+private:
+ TilePyramid tilePyramid;
+};
+
+} // namespace mbgl