summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--include/mbgl/map/map.hpp6
-rw-r--r--src/mbgl/map/map.cpp24
-rw-r--r--src/mbgl/map/map_context.cpp8
-rw-r--r--src/mbgl/map/map_context.hpp10
4 files changed, 10 insertions, 38 deletions
diff --git a/include/mbgl/map/map.hpp b/include/mbgl/map/map.hpp
index 32b4afae7f..a15da5178b 100644
--- a/include/mbgl/map/map.hpp
+++ b/include/mbgl/map/map.hpp
@@ -18,8 +18,6 @@ namespace mbgl {
class FileSource;
class View;
-class Environment;
-class EnvironmentScope;
class MapData;
class MapContext;
class StillImage;
@@ -136,10 +134,8 @@ public:
bool getDebug() const;
private:
- const std::unique_ptr<Environment> env;
- std::unique_ptr<EnvironmentScope> scope;
const std::unique_ptr<MapData> data;
- std::unique_ptr<util::Thread<MapContext>> context;
+ const std::unique_ptr<util::Thread<MapContext>> context;
};
}
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index f0e47e9d89..be2355206c 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -1,5 +1,4 @@
#include <mbgl/map/map.hpp>
-#include <mbgl/map/environment.hpp>
#include <mbgl/map/map_context.hpp>
#include <mbgl/map/view.hpp>
#include <mbgl/map/map_data.hpp>
@@ -11,10 +10,8 @@
namespace mbgl {
Map::Map(View& view, FileSource& fileSource, MapMode mode, bool startPaused)
- : env(util::make_unique<Environment>(fileSource)),
- scope(util::make_unique<EnvironmentScope>(*env, ThreadType::Main, "Main")),
- data(util::make_unique<MapData>(view, mode)),
- context(util::make_unique<util::Thread<MapContext>>("Map", *env, view, *data, startPaused))
+ : data(util::make_unique<MapData>(view, mode)),
+ context(util::make_unique<util::Thread<MapContext>>("Map", view, fileSource, *data, startPaused))
{
view.initialize(this);
}
@@ -24,7 +21,6 @@ Map::~Map() {
}
void Map::pause(bool waitForPause) {
- assert(Environment::currentlyOn(ThreadType::Main));
assert(data->mode == MapMode::Continuous);
std::unique_lock<std::mutex> lockPause(data->mutexPause);
@@ -36,8 +32,6 @@ void Map::pause(bool waitForPause) {
}
void Map::resume() {
- assert(Environment::currentlyOn(ThreadType::Main));
-
data->condResume.notify_all();
}
@@ -46,14 +40,10 @@ void Map::renderStill(StillImageCallback callback) {
}
void Map::renderSync() {
- assert(Environment::currentlyOn(ThreadType::Main));
-
context->invokeSync(&MapContext::render);
}
void Map::renderAsync() {
- assert(Environment::currentlyOn(ThreadType::Main));
-
context->invoke(&MapContext::render);
}
@@ -248,12 +238,10 @@ const LatLng Map::latLngForPixel(const vec2<double> pixel) const {
#pragma mark - Annotations
void Map::setDefaultPointAnnotationSymbol(const std::string& symbol) {
- assert(Environment::currentlyOn(ThreadType::Main));
data->annotationManager.setDefaultPointAnnotationSymbol(symbol);
}
double Map::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) {
- assert(Environment::currentlyOn(ThreadType::Main));
return context->invokeSync<double>(&MapContext::getTopOffsetPixelsForAnnotationSymbol, symbol);
}
@@ -262,30 +250,25 @@ uint32_t Map::addPointAnnotation(const LatLng& point, const std::string& symbol)
}
std::vector<uint32_t> Map::addPointAnnotations(const std::vector<LatLng>& points, const std::vector<std::string>& symbols) {
- assert(Environment::currentlyOn(ThreadType::Main));
auto result = data->annotationManager.addPointAnnotations(points, symbols, *data);
context->invoke(&MapContext::updateAnnotationTiles, result.first);
return result.second;
}
void Map::removeAnnotation(uint32_t annotation) {
- assert(Environment::currentlyOn(ThreadType::Main));
removeAnnotations({ annotation });
}
void Map::removeAnnotations(const std::vector<uint32_t>& annotations) {
- assert(Environment::currentlyOn(ThreadType::Main));
auto result = data->annotationManager.removeAnnotations(annotations, *data);
context->invoke(&MapContext::updateAnnotationTiles, result);
}
std::vector<uint32_t> Map::getAnnotationsInBounds(const LatLngBounds& bounds) {
- assert(Environment::currentlyOn(ThreadType::Main));
return data->annotationManager.getAnnotationsInBounds(bounds, *data);
}
LatLngBounds Map::getBoundsForAnnotations(const std::vector<uint32_t>& annotations) {
- assert(Environment::currentlyOn(ThreadType::Main));
return data->annotationManager.getBoundsForAnnotations(annotations);
}
@@ -332,14 +315,11 @@ std::vector<std::string> Map::getClasses() const {
}
void Map::setDefaultTransitionDuration(Duration duration) {
- assert(Environment::currentlyOn(ThreadType::Main));
-
data->setDefaultTransitionDuration(duration);
update(Update::DefaultTransitionDuration);
}
Duration Map::getDefaultTransitionDuration() {
- assert(Environment::currentlyOn(ThreadType::Main));
return data->getDefaultTransitionDuration();
}
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index fa99dec7e7..e10a46e99b 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -30,11 +30,11 @@
namespace mbgl {
-MapContext::MapContext(uv_loop_t* loop, Environment& env_, View& view_, MapData& data_, bool startPaused)
- : env(env_),
- view(view_),
+MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, MapData& data_, bool startPaused)
+ : view(view_),
data(data_),
- mapScope(env, ThreadType::Map, "Map"),
+ env(fileSource),
+ 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>(loop, 4)),
diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp
index b3a9b9f33f..6e7b082f2a 100644
--- a/src/mbgl/map/map_context.hpp
+++ b/src/mbgl/map/map_context.hpp
@@ -8,9 +8,6 @@
#include <mbgl/util/ptr.hpp>
#include <vector>
-#include <queue>
-#include <future>
-#include <thread>
typedef struct uv_loop_s uv_loop_t;
@@ -20,7 +17,6 @@ class async;
namespace mbgl {
-class Environment;
class View;
class MapData;
class GlyphStore;
@@ -38,7 +34,7 @@ struct LatLngBounds;
class MapContext {
public:
- MapContext(uv_loop_t*, Environment&, View&, MapData&, bool startPaused);
+ MapContext(uv_loop_t*, View&, FileSource&, MapData&, bool startPaused);
~MapContext();
void pause();
@@ -72,11 +68,11 @@ private:
// Loads the actual JSON object an creates a new Style object.
void loadStyleJSON(const std::string& json, const std::string& base);
- Environment& env;
View& view;
MapData& data;
- EnvironmentScope mapScope;
+ Environment env;
+ EnvironmentScope envScope;
std::atomic<UpdateType> updated { static_cast<UpdateType>(Update::Nothing) };
std::unique_ptr<uv::async> asyncUpdate;