summaryrefslogtreecommitdiff
path: root/src/mbgl/style
diff options
context:
space:
mode:
Diffstat (limited to 'src/mbgl/style')
-rw-r--r--src/mbgl/style/source_impl.cpp34
-rw-r--r--src/mbgl/style/source_impl.hpp15
-rw-r--r--src/mbgl/style/source_observer.hpp3
-rw-r--r--src/mbgl/style/style.cpp32
-rw-r--r--src/mbgl/style/style.hpp10
-rw-r--r--src/mbgl/style/update_parameters.hpp11
6 files changed, 31 insertions, 74 deletions
diff --git a/src/mbgl/style/source_impl.cpp b/src/mbgl/style/source_impl.cpp
index e124cde583..58ae3d9f91 100644
--- a/src/mbgl/style/source_impl.cpp
+++ b/src/mbgl/style/source_impl.cpp
@@ -5,6 +5,7 @@
#include <mbgl/renderer/painter.hpp>
#include <mbgl/style/update_parameters.hpp>
#include <mbgl/style/query_parameters.hpp>
+#include <mbgl/text/placement_config.hpp>
#include <mbgl/platform/log.hpp>
#include <mbgl/math/clamp.hpp>
#include <mbgl/util/tile_cover.hpp>
@@ -77,7 +78,7 @@ const std::map<UnwrappedTileID, RenderTile>& Source::Impl::getRenderTiles() cons
return renderTiles;
}
-void Source::Impl::loadTiles(const UpdateParameters& parameters) {
+void Source::Impl::updateTiles(const UpdateParameters& parameters) {
if (!loaded) {
return;
}
@@ -161,28 +162,17 @@ void Source::Impl::loadTiles(const UpdateParameters& parameters) {
++retainIt;
}
}
-}
-bool Source::Impl::parseTiles(const UpdateParameters& parameters) {
- bool allTilesUpdated = true;
- const PlacementConfig newConfig{ parameters.transformState.getAngle(),
- parameters.transformState.getPitch(),
- parameters.debugOptions & MapDebugOptions::Collision };
+ const PlacementConfig config { parameters.transformState.getAngle(),
+ parameters.transformState.getPitch(),
+ parameters.debugOptions & MapDebugOptions::Collision };
+
for (auto& pair : tiles) {
- auto tile = pair.second.get();
- if (parameters.shouldReparsePartialTiles && tile->isIncomplete()) {
- if (!tile->parsePending()) {
- allTilesUpdated = false;
- }
- } else {
- tile->redoPlacement(newConfig);
- }
+ pair.second->setPlacementConfig(config);
}
-
- return allTilesUpdated;
}
-void Source::Impl::reload() {
+void Source::Impl::reloadTiles() {
cache.clear();
for (auto& pair : tiles) {
@@ -258,18 +248,14 @@ void Source::Impl::setObserver(SourceObserver* observer_) {
observer = observer_;
}
-void Source::Impl::onTileLoaded(Tile& tile, TileLoadState loadState) {
- observer->onTileLoaded(base, tile.id, loadState);
+void Source::Impl::onTileChanged(Tile& tile) {
+ observer->onTileChanged(base, tile.id);
}
void Source::Impl::onTileError(Tile& tile, std::exception_ptr error) {
observer->onTileError(base, tile.id, error);
}
-void Source::Impl::onTileUpdated(Tile& tile) {
- observer->onTileUpdated(base, tile.id);
-}
-
void Source::Impl::dumpDebugLogs() const {
Log::Info(Event::General, "Source::id: %s", base.getID().c_str());
Log::Info(Event::General, "Source::loaded: %d", loaded);
diff --git a/src/mbgl/style/source_impl.hpp b/src/mbgl/style/source_impl.hpp
index 5a54f4781a..0de3760fc3 100644
--- a/src/mbgl/style/source_impl.hpp
+++ b/src/mbgl/style/source_impl.hpp
@@ -43,16 +43,14 @@ public:
virtual void loadDescription(FileSource&) = 0;
bool isLoaded() const;
- // Request or parse all the tiles relevant for the "TransformState". This method
- // will return true if all the tiles were scheduled for updating of false if
- // they were not. shouldReparsePartialTiles must be set to "true" if there is
- // new data available that a tile in the "partial" state might be interested at.
- void loadTiles(const UpdateParameters&);
- bool parseTiles(const UpdateParameters&);
+ // Called when the camera has changed or icons or glyphs are loaded. May load new
+ // tiles, unload obsolete tiles, and trigger further parsing of incomplete tiles or
+ // re-placement of existing complete tiles.
+ void updateTiles(const UpdateParameters&);
// Request that all loaded tiles re-run the layout operation on the existing source
// data with fresh style information.
- void reload();
+ void reloadTiles();
void startRender(algorithm::ClipIDGenerator&,
const mat4& projMatrix,
@@ -88,9 +86,8 @@ protected:
private:
// TileObserver implementation.
- void onTileLoaded(Tile&, TileLoadState) override;
+ void onTileChanged(Tile&) override;
void onTileError(Tile&, std::exception_ptr) override;
- void onTileUpdated(Tile&) override;
virtual uint16_t getTileSize() const = 0;
virtual Range<uint8_t> getZoomRange() = 0;
diff --git a/src/mbgl/style/source_observer.hpp b/src/mbgl/style/source_observer.hpp
index 6e0b226c3b..26b25b78da 100644
--- a/src/mbgl/style/source_observer.hpp
+++ b/src/mbgl/style/source_observer.hpp
@@ -19,9 +19,8 @@ public:
virtual void onSourceLoaded(Source&) {}
virtual void onSourceError(Source&, std::exception_ptr) {}
- virtual void onTileLoaded(Source&, const OverscaledTileID&, TileLoadState) {}
+ virtual void onTileChanged(Source&, const OverscaledTileID&) {}
virtual void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) {}
- virtual void onTileUpdated(Source&, const OverscaledTileID&) {}
};
} // namespace style
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 34790683bc..a00c5e4efc 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -43,8 +43,7 @@ Style::Style(FileSource& fileSource_, float pixelRatio)
spriteStore(std::make_unique<SpriteStore>(pixelRatio)),
spriteAtlas(std::make_unique<SpriteAtlas>(1024, 1024, pixelRatio, *spriteStore)),
lineAtlas(std::make_unique<LineAtlas>(256, 512)),
- observer(&nullObserver),
- workers(4) {
+ observer(&nullObserver) {
glyphStore->setObserver(this);
spriteStore->setObserver(this);
}
@@ -215,19 +214,8 @@ double Style::getDefaultPitch() const {
}
void Style::updateTiles(const UpdateParameters& parameters) {
- bool allTilesUpdated = true;
-
for (const auto& source : sources) {
- source->baseImpl->loadTiles(parameters);
- if (!source->baseImpl->parseTiles(parameters)) {
- allTilesUpdated = false;
- }
- }
-
- // We can only stop updating "partial" tiles when all of them
- // were notified of the arrival of the new resources.
- if (allTilesUpdated) {
- shouldReparsePartialTiles = false;
+ source->baseImpl->updateTiles(parameters);
}
}
@@ -235,7 +223,7 @@ void Style::relayout() {
for (const auto& sourceID : updateBatch.sourceIDs) {
Source* source = getSource(sourceID);
if (!source) continue;
- source->baseImpl->reload();
+ source->baseImpl->reloadTiles();
}
updateBatch.sourceIDs.clear();
}
@@ -447,7 +435,6 @@ void Style::setObserver(style::Observer* observer_) {
}
void Style::onGlyphsLoaded(const FontStack& fontStack, const GlyphRange& glyphRange) {
- shouldReparsePartialTiles = true;
observer->onGlyphsLoaded(fontStack, glyphRange);
observer->onUpdate(Update::Repaint);
}
@@ -473,12 +460,8 @@ void Style::onSourceError(Source& source, std::exception_ptr error) {
observer->onResourceError(error);
}
-void Style::onTileLoaded(Source& source, const OverscaledTileID& tileID, TileLoadState loadState) {
- if (loadState == TileLoadState::First) {
- shouldReparsePartialTiles = true;
- }
-
- observer->onTileLoaded(source, tileID, loadState);
+void Style::onTileChanged(Source& source, const OverscaledTileID& tileID) {
+ observer->onTileChanged(source, tileID);
observer->onUpdate(Update::Repaint);
}
@@ -490,12 +473,7 @@ void Style::onTileError(Source& source, const OverscaledTileID& tileID, std::exc
observer->onResourceError(error);
}
-void Style::onTileUpdated(Source&, const OverscaledTileID&) {
- observer->onUpdate(Update::Repaint);
-}
-
void Style::onSpriteLoaded() {
- shouldReparsePartialTiles = true;
observer->onSpriteLoaded();
observer->onUpdate(Update::Repaint);
}
diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp
index 8027313ab9..3e678ec060 100644
--- a/src/mbgl/style/style.hpp
+++ b/src/mbgl/style/style.hpp
@@ -12,25 +12,28 @@
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/chrono.hpp>
-#include <mbgl/util/worker.hpp>
#include <mbgl/util/optional.hpp>
#include <mbgl/util/feature.hpp>
#include <mbgl/util/geo.hpp>
#include <cstdint>
+#include <memory>
#include <string>
#include <vector>
namespace mbgl {
class FileSource;
+class GlyphStore;
class GlyphAtlas;
+class SpriteStore;
class SpriteAtlas;
class LineAtlas;
class RenderData;
namespace style {
+class Layer;
class UpdateParameters;
class QueryParameters;
@@ -134,9 +137,8 @@ private:
// SourceObserver implementation.
void onSourceLoaded(Source&) override;
void onSourceError(Source&, std::exception_ptr) override;
- void onTileLoaded(Source&, const OverscaledTileID&, TileLoadState) override;
+ void onTileChanged(Source&, const OverscaledTileID&) override;
void onTileError(Source&, const OverscaledTileID&, std::exception_ptr) override;
- void onTileUpdated(Source&, const OverscaledTileID&) override;
// LayerObserver implementation.
void onLayerFilterChanged(Layer&) override;
@@ -154,9 +156,7 @@ private:
bool hasPendingTransitions = false;
public:
- bool shouldReparsePartialTiles = false;
bool loaded = false;
- Worker workers;
};
} // namespace style
diff --git a/src/mbgl/style/update_parameters.hpp b/src/mbgl/style/update_parameters.hpp
index 306cddf706..900f4b5183 100644
--- a/src/mbgl/style/update_parameters.hpp
+++ b/src/mbgl/style/update_parameters.hpp
@@ -5,7 +5,7 @@
namespace mbgl {
class TransformState;
-class Worker;
+class Scheduler;
class FileSource;
class AnnotationManager;
@@ -18,18 +18,16 @@ public:
UpdateParameters(float pixelRatio_,
MapDebugOptions debugOptions_,
const TransformState& transformState_,
- Worker& worker_,
+ Scheduler& workerScheduler_,
FileSource& fileSource_,
- bool shouldReparsePartialTiles_,
const MapMode mode_,
AnnotationManager& annotationManager_,
Style& style_)
: pixelRatio(pixelRatio_),
debugOptions(debugOptions_),
transformState(transformState_),
- worker(worker_),
+ workerScheduler(workerScheduler_),
fileSource(fileSource_),
- shouldReparsePartialTiles(shouldReparsePartialTiles_),
mode(mode_),
annotationManager(annotationManager_),
style(style_) {}
@@ -37,9 +35,8 @@ public:
float pixelRatio;
MapDebugOptions debugOptions;
const TransformState& transformState;
- Worker& worker;
+ Scheduler& workerScheduler;
FileSource& fileSource;
- bool shouldReparsePartialTiles;
const MapMode mode;
AnnotationManager& annotationManager;