summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJohn Firebaugh <john.firebaugh@gmail.com>2015-06-26 14:42:32 -0700
committerJohn Firebaugh <john.firebaugh@gmail.com>2015-06-30 10:13:23 -0700
commit37117dae00474c056a54db975139757a08318cb4 (patch)
tree9f1da013a831a34bec29967cbd41a331229b5cda /src
parentccc631886f684ba24f7de9c149c5c4b1327af38e (diff)
downloadqtlocation-mapboxgl-37117dae00474c056a54db975139757a08318cb4.tar.gz
Eliminate MapData::get/setFullyLoaded
Diffstat (limited to 'src')
-rw-r--r--src/mbgl/map/map.cpp7
-rw-r--r--src/mbgl/map/map_context.cpp34
-rw-r--r--src/mbgl/map/map_context.hpp9
-rw-r--r--src/mbgl/map/map_data.hpp8
4 files changed, 25 insertions, 33 deletions
diff --git a/src/mbgl/map/map.cpp b/src/mbgl/map/map.cpp
index 2097747bc5..c0f7e953a8 100644
--- a/src/mbgl/map/map.cpp
+++ b/src/mbgl/map/map.cpp
@@ -46,11 +46,12 @@ void Map::renderStill(StillImageCallback callback) {
}
void Map::renderSync() {
- bool rerender = context->invokeSync<bool>(&MapContext::renderSync, transform->getState());
+ MapContext::RenderResult result =
+ context->invokeSync<MapContext::RenderResult>(&MapContext::renderSync, transform->getState());
if (transform->needsTransition()) {
update(Update(transform->updateTransitions(Clock::now())));
- } else if (rerender) {
+ } else if (result.needsRerender) {
update();
}
}
@@ -361,7 +362,7 @@ bool Map::getCollisionDebug() const {
}
bool Map::isFullyLoaded() const {
- return data->getFullyLoaded();
+ return context->invokeSync<bool>(&MapContext::isLoaded);
}
void Map::addClass(const std::string& klass) {
diff --git a/src/mbgl/map/map_context.cpp b/src/mbgl/map/map_context.cpp
index e1e57eac81..9dadd05d37 100644
--- a/src/mbgl/map/map_context.cpp
+++ b/src/mbgl/map/map_context.cpp
@@ -249,20 +249,10 @@ void MapContext::update() {
style->update(data, transformState, *texturePool);
- if (style->isLoaded()) {
- if (!data.getFullyLoaded()) {
- data.setFullyLoaded(true);
- }
- } else {
- if (data.getFullyLoaded()) {
- data.setFullyLoaded(false);
- }
- }
-
- if (callback) {
- renderSync(transformState);
- } else {
+ if (data.mode == MapMode::Continuous) {
view.invalidate();
+ } else if (callback && style->isLoaded()) {
+ renderSync(transformState);
}
}
@@ -302,12 +292,12 @@ void MapContext::renderStill(const TransformState& state, StillImageCallback fn)
asyncUpdate->send();
}
-bool MapContext::renderSync(const TransformState& state) {
+MapContext::RenderResult MapContext::renderSync(const TransformState& state) {
assert(util::ThreadContext::currentlyOn(util::ThreadType::Map));
// Style was not loaded yet.
if (!style) {
- return false;
+ return { false, false };
}
transformState = state;
@@ -315,11 +305,6 @@ bool MapContext::renderSync(const TransformState& state) {
// Cleanup OpenGL objects that we abandoned since the last render call.
glObjectStore.performCleanup();
- if (data.mode == MapMode::Still && (!callback || !data.getFullyLoaded())) {
- // We are either not waiting for a map to be rendered, or we don't have all resources yet.
- return false;
- }
-
if (!painter) {
painter = std::make_unique<Painter>();
painter->setup();
@@ -335,7 +320,14 @@ bool MapContext::renderSync(const TransformState& state) {
view.swap();
- return style->hasTransitions();
+ return RenderResult {
+ style->isLoaded(),
+ style->hasTransitions()
+ };
+}
+
+bool MapContext::isLoaded() const {
+ return style->isLoaded();
}
double MapContext::getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol) {
diff --git a/src/mbgl/map/map_context.hpp b/src/mbgl/map/map_context.hpp
index fedafb7d09..715a55bf15 100644
--- a/src/mbgl/map/map_context.hpp
+++ b/src/mbgl/map/map_context.hpp
@@ -33,6 +33,11 @@ public:
MapContext(uv_loop_t*, View&, FileSource&, MapData&);
~MapContext();
+ struct RenderResult {
+ bool fullyLoaded;
+ bool needsRerender;
+ };
+
void pause();
void resize(uint16_t width, uint16_t height, float ratio);
@@ -41,13 +46,15 @@ public:
void triggerUpdate(const TransformState&, Update = Update::Nothing);
void renderStill(const TransformState&, StillImageCallback callback);
- bool renderSync(const TransformState&);
+ RenderResult renderSync(const TransformState&);
void setStyleURL(const std::string&);
void setStyleJSON(const std::string& json, const std::string& base);
std::string getStyleURL() const { return styleURL; }
std::string getStyleJSON() const { return styleJSON; }
+ bool isLoaded() const;
+
double getTopOffsetPixelsForAnnotationSymbol(const std::string& symbol);
void updateAnnotationTiles(const std::unordered_set<TileID, TileID::Hash>&);
diff --git a/src/mbgl/map/map_data.hpp b/src/mbgl/map/map_data.hpp
index 10f33df192..a1ee3c06dc 100644
--- a/src/mbgl/map/map_data.hpp
+++ b/src/mbgl/map/map_data.hpp
@@ -62,13 +62,6 @@ public:
collisionDebug = value;
}
- inline bool getFullyLoaded() const {
- return loaded;
- }
- inline void setFullyLoaded(bool value) {
- loaded = value;
- }
-
inline TimePoint getAnimationTime() const {
// We're casting the TimePoint to and from a Duration because libstdc++
// has a bug that doesn't allow TimePoints to be atomic.
@@ -95,7 +88,6 @@ private:
std::vector<std::string> classes;
std::atomic<uint8_t> debug { false };
std::atomic<uint8_t> collisionDebug { false };
- std::atomic<bool> loaded { false };
std::atomic<Duration> animationTime;
std::atomic<Duration> defaultTransitionDuration;