summaryrefslogtreecommitdiff
path: root/src/mbgl/map
diff options
context:
space:
mode:
authorLeith Bade <leith@mapbox.com>2015-05-06 12:47:15 +1000
committerLeith Bade <leith@mapbox.com>2015-05-09 12:02:39 +1000
commit703e0bc2ee609a59e90b7ba3ddefffaf17291bf4 (patch)
tree4582e6a53eacf62bb59b76fe8d195e7fe99cd245 /src/mbgl/map
parentfd099593dc0a8fe8cb156fa22bf3739a7c325036 (diff)
downloadqtlocation-mapboxgl-703e0bc2ee609a59e90b7ba3ddefffaf17291bf4.tar.gz
Ignore deactivate when no valid EGL display. Fixes #1435
Initialise NativeMapView's EGL variables before Map Fix hang Add check for double pause Add test for double pause
Diffstat (limited to 'src/mbgl/map')
-rw-r--r--src/mbgl/map/map.cpp18
-rw-r--r--src/mbgl/map/map_context.cpp24
-rw-r--r--src/mbgl/map/map_context.hpp2
3 files changed, 20 insertions, 24 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 91b43f7b7b..8514c6ecb2 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -9,9 +9,9 @@
namespace mbgl {
-Map::Map(View& view, FileSource& fileSource, MapMode mode, bool startPaused)
+Map::Map(View& view, FileSource& fileSource, MapMode mode)
: data(util::make_unique<MapData>(view, mode)),
- context(util::make_unique<util::Thread<MapContext>>("Map", util::ThreadPriority::Regular, view, fileSource, *data, startPaused))
+ context(util::make_unique<util::Thread<MapContext>>("Map", util::ThreadPriority::Regular, view, fileSource, *data))
{
view.initialize(this);
}
@@ -23,13 +23,17 @@ Map::~Map() {
void Map::pause() {
assert(data->mode == MapMode::Continuous);
- std::unique_lock<std::mutex> lockPause(data->mutexPause);
- context->invoke(&MapContext::pause);
- data->condPaused.wait(lockPause);
+ if (!paused) {
+ std::unique_lock<std::mutex> lockPause(data->mutexPause);
+ context->invoke(&MapContext::pause);
+ data->condPaused.wait(lockPause);
+ paused = true;
+ }
}
void Map::resume() {
data->condResume.notify_all();
+ paused = false;
}
void Map::renderStill(StillImageCallback callback) {
@@ -274,12 +278,12 @@ LatLngBounds Map::getBoundsForAnnotations(const std::vector<uint32_t>& annotatio
void Map::setDebug(bool value) {
data->setDebug(value);
- update(Update::Debug);
+ update();
}
void Map::toggleDebug() {
data->toggleDebug();
- update(Update::Debug);
+ update();
}
bool Map::getDebug() const {
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index 2352e09c2b..b239eb18a8 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -29,7 +29,7 @@
namespace mbgl {
-MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, MapData& data_, bool startPaused)
+MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, MapData& data_)
: view(view_),
data(data_),
env(fileSource),
@@ -40,20 +40,12 @@ MapContext::MapContext(uv_loop_t* loop, View& view_, FileSource& fileSource, Map
glyphAtlas(util::make_unique<GlyphAtlas>(1024, 1024)),
spriteAtlas(util::make_unique<SpriteAtlas>(512, 512)),
lineAtlas(util::make_unique<LineAtlas>(512, 512)),
- texturePool(util::make_unique<TexturePool>()),
- painter(util::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas))
-{
+ texturePool(util::make_unique<TexturePool>()) {
assert(Environment::currentlyOn(ThreadType::Map));
asyncUpdate->unref();
view.activate();
-
- if (startPaused) {
- pause();
- }
-
- painter->setup();
}
MapContext::~MapContext() {
@@ -173,11 +165,6 @@ void MapContext::update() {
updated |= data.transform.updateTransitions(now);
transformState = data.transform.currentState();
- if (updated & static_cast<UpdateType>(Update::Debug)) {
- assert(painter);
- painter->setDebug(data.getDebug());
- }
-
if (style) {
if (updated & static_cast<UpdateType>(Update::DefaultTransitionDuration)) {
style->setDefaultTransitionDuration(data.getDefaultTransitionDuration());
@@ -230,8 +217,13 @@ void MapContext::render() {
env.performCleanup();
assert(style);
- assert(painter);
+ if (!painter) {
+ painter = util::make_unique<Painter>(*spriteAtlas, *glyphAtlas, *lineAtlas);
+ painter->setup();
+ }
+
+ painter->setDebug(data.getDebug());
painter->render(*style, transformState, data.getAnimationTime());
if (data.mode == MapMode::Still && callback && style->isLoaded() && resourceLoader->getSprite()->isLoaded()) {
diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp
index 0463d076b6..09b2db0b42 100644
--- a/src/mbgl/map/map_context.hpp
+++ b/src/mbgl/map/map_context.hpp
@@ -35,7 +35,7 @@ struct LatLngBounds;
class MapContext : public ResourceLoader::Observer {
public:
- MapContext(uv_loop_t*, View&, FileSource&, MapData&, bool startPaused);
+ MapContext(uv_loop_t*, View&, FileSource&, MapData&);
~MapContext();
void pause();