summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-04-23 17:05:37 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-04-28 14:32:26 -0400
commit0c280adebcb9b1dd050aacb1dda1ad3715128ced (patch)
treec7d4ca2e8710f006db1770397911dcc1024086e5 /src
parent4ccf246c10b8def2707fec11e8cff565bba90db7 (diff)
downloadqtlocation-mapboxgl-0c280adebcb9b1dd050aacb1dda1ad3715128ced.tar.gz
Move Worker to Style
This ensures that worker tasks are entirely complete by the time the style is destructed, and enables us to pass Style& rather than a shared pointer.
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/map_context.cpp3
-rw-r--r--src/mbgl/map/map_context.hpp1
-rw-r--r--src/mbgl/map/source.cpp11
-rw-r--r--src/mbgl/map/source.hpp3
-rw-r--r--src/mbgl/map/tile_parser.cpp2
-rw-r--r--src/mbgl/style/style.cpp3
-rw-r--r--src/mbgl/style/style.hpp4
7 files changed, 13 insertions, 14 deletions
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index ccd2392536..15541a84d1 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -37,7 +37,6 @@ MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, Map
envScope(env, ThreadType::Map, "Map"),
updated(static_cast<UpdateType>(Update::Nothing)),
asyncUpdate(util::make_unique<uv::async>(loop, [this] { update(); })),
- workers(util::make_unique<Worker>(4)),
glyphStore(util::make_unique<GlyphStore>(env)),
glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)),
spriteAtlas(util::make_unique<SpriteAtlas>(512, 512)),
@@ -163,7 +162,7 @@ void MapContext::updateTiles() {
assert(Environment::currentlyOn(ThreadType::Map));
if (!style) return;
for (const auto& source : style->sources) {
- source->update(data, transformState, *workers, style, *glyphAtlas, *glyphStore, *spriteAtlas,
+ source->update(data, transformState, style, *glyphAtlas, *glyphStore, *spriteAtlas,
getSprite(), *texturePool, [this]() {
assert(Environment::currentlyOn(ThreadType::Map));
triggerUpdate();
diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp
index 2c9f287086..ba8a4db9d7 100644
--- a/src/mbgl/map/map_context.hpp
+++ b/src/mbgl/map/map_context.hpp
@@ -77,7 +77,6 @@ private:
UpdateType updated { static_cast<UpdateType>(Update::Nothing) };
std::unique_ptr<uv::async> asyncUpdate;
- std::unique_ptr<Worker> workers;
std::unique_ptr<GlyphStore> glyphStore;
std::unique_ptr<GlyphAtlas> glyphAtlas;
std::unique_ptr<SpriteAtlas> spriteAtlas;
diff --git a/src/mbgl/map/source.cpp b/src/mbgl/map/source.cpp
index 93761255bf..2d4c4ec50c 100644
--- a/src/mbgl/map/source.cpp
+++ b/src/mbgl/map/source.cpp
@@ -20,6 +20,7 @@
#include <mbgl/map/vector_tile_data.hpp>
#include <mbgl/map/raster_tile_data.hpp>
#include <mbgl/map/live_tile_data.hpp>
+#include <mbgl/style/style.hpp>
#include <algorithm>
@@ -226,7 +227,6 @@ TileData::State Source::hasTile(const TileID& id) {
TileData::State Source::addTile(MapData& data,
const TransformState& transformState,
- Worker& worker,
util::ptr<Style> style,
GlyphAtlas& glyphAtlas,
GlyphStore& glyphStore,
@@ -269,15 +269,15 @@ TileData::State Source::addTile(MapData& data,
new_tile.data =
std::make_shared<VectorTileData>(normalized_id, data.transform.getMaxZoom(), style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info);
- new_tile.data->request(worker, transformState.getPixelRatio(), callback);
+ new_tile.data->request(style->workers, transformState.getPixelRatio(), callback);
} else if (info.type == SourceType::Raster) {
new_tile.data = std::make_shared<RasterTileData>(normalized_id, texturePool, info);
- new_tile.data->request(worker, transformState.getPixelRatio(), callback);
+ new_tile.data->request(style->workers, transformState.getPixelRatio(), callback);
} else if (info.type == SourceType::Annotations) {
new_tile.data = std::make_shared<LiveTileData>(normalized_id, data.annotationManager,
data.transform.getMaxZoom(), style, glyphAtlas,
glyphStore, spriteAtlas, sprite, info);
- new_tile.data->reparse(worker, callback);
+ new_tile.data->reparse(style->workers, callback);
} else {
throw std::runtime_error("source type not implemented");
}
@@ -368,7 +368,6 @@ bool Source::findLoadedParent(const TileID& id, int32_t minCoveringZoom, std::fo
void Source::update(MapData& data,
const TransformState& transformState,
- Worker& worker,
util::ptr<Style> style,
GlyphAtlas& glyphAtlas,
GlyphStore& glyphStore,
@@ -394,7 +393,7 @@ void Source::update(MapData& data,
// Add existing child/parent tiles if the actual tile is not yet loaded
for (const auto& id : required) {
- const TileData::State state = addTile(data, transformState, worker, style, glyphAtlas, glyphStore,
+ const TileData::State state = addTile(data, transformState, style, glyphAtlas, glyphStore,
spriteAtlas, sprite, texturePool, id, callback);
if (state != TileData::State::parsed) {
diff --git a/src/mbgl/map/source.hpp b/src/mbgl/map/source.hpp
index 6383e101fd..2e889ccd74 100644
--- a/src/mbgl/map/source.hpp
+++ b/src/mbgl/map/source.hpp
@@ -22,7 +22,6 @@ namespace mbgl {
class MapData;
class Environment;
-class Worker;
class GlyphAtlas;
class GlyphStore;
class SpriteAtlas;
@@ -65,7 +64,6 @@ public:
void load(MapData&, Environment&, std::function<void()> callback);
void update(MapData&,
const TransformState&,
- Worker&,
util::ptr<Style>,
GlyphAtlas&,
GlyphStore&,
@@ -97,7 +95,6 @@ private:
TileData::State addTile(MapData&,
const TransformState&,
- Worker&,
util::ptr<Style>,
GlyphAtlas&,
GlyphStore&,
diff --git a/src/mbgl/map/tile_parser.cpp b/src/mbgl/map/tile_parser.cpp
index 8bcb4c462e..60228974b0 100644
--- a/src/mbgl/map/tile_parser.cpp
+++ b/src/mbgl/map/tile_parser.cpp
@@ -1,7 +1,6 @@
#include <mbgl/map/tile_parser.hpp>
#include <mbgl/map/vector_tile_data.hpp>
#include <mbgl/platform/log.hpp>
-#include <mbgl/style/style.hpp>
#include <mbgl/style/style_layer.hpp>
#include <mbgl/map/source.hpp>
#include <mbgl/renderer/fill_bucket.hpp>
@@ -10,6 +9,7 @@
#include <mbgl/util/constants.hpp>
#include <mbgl/text/collision.hpp>
#include <mbgl/util/std.hpp>
+#include <mbgl/style/style.hpp>
#include <locale>
diff --git a/src/mbgl/style/style.cpp b/src/mbgl/style/style.cpp
index 4f26ee0106..d592e61317 100644
--- a/src/mbgl/style/style.cpp
+++ b/src/mbgl/style/style.cpp
@@ -17,7 +17,8 @@
namespace mbgl {
Style::Style()
- : mtx(util::make_unique<uv::rwlock>()) {
+ : mtx(util::make_unique<uv::rwlock>()),
+ workers(4) {
}
// Note: This constructor is seemingly empty, but we need to declare it anyway
diff --git a/src/mbgl/style/style.hpp b/src/mbgl/style/style.hpp
index 849376b560..42e94984dd 100644
--- a/src/mbgl/style/style.hpp
+++ b/src/mbgl/style/style.hpp
@@ -8,6 +8,7 @@
#include <mbgl/util/ptr.hpp>
#include <mbgl/util/noncopyable.hpp>
#include <mbgl/util/chrono.hpp>
+#include <mbgl/util/worker.hpp>
#include <cstdint>
#include <string>
@@ -44,6 +45,9 @@ private:
PropertyTransition defaultTransition;
std::unique_ptr<uv::rwlock> mtx;
ZoomHistory zoomHistory;
+
+public:
+ Worker workers;
};
}