diff options
author | John Firebaugh <john.firebaugh@gmail.com> | 2015-04-23 15:58:27 -0700 |
---|---|---|
committer | John Firebaugh <john.firebaugh@gmail.com> | 2015-04-28 14:32:25 -0400 |
commit | 8bb7fc64ff2dbb4ce58d1a7127b8328fffeaa1de (patch) | |
tree | 4edb6a5092e2ca9618547926a1a243d3c2283108 /src | |
parent | bb7c453b3e29de4a854560dfca34a89fc832a39d (diff) | |
download | qtlocation-mapboxgl-8bb7fc64ff2dbb4ce58d1a7127b8328fffeaa1de.tar.gz |
Move Environment to MapContext
Diffstat (limited to 'src')
-rw-r--r-- | src/mbgl/map/map.cpp | 24 | ||||
-rw-r--r-- | src/mbgl/map/map_context.cpp | 8 | ||||
-rw-r--r-- | src/mbgl/map/map_context.hpp | 10 |
3 files changed, 9 insertions, 33 deletions
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; |